262 |
264 |
263 def concatString(node, stop=None): |
265 def concatString(node, stop=None): |
264 """ |
266 """ |
265 Function to build a string from an ast.BinOp chain. |
267 Function to build a string from an ast.BinOp chain. |
266 |
268 |
267 This will build a string from a series of ast.Str nodes wrapped in |
269 This will build a string from a series of ast.Str/ast.Constant nodes |
268 ast.BinOp nodes. Something like "a" + "b" + "c" or "a %s" % val etc. |
270 wrapped in ast.BinOp nodes. Something like "a" + "b" + "c" or "a %s" % val |
269 The provided node can be any participant in the BinOp chain. |
271 etc. The provided node can be any participant in the BinOp chain. |
270 |
272 |
271 @param node node to be processed |
273 @param node node to be processed |
272 @type ast.BinOp or ast.Str |
274 @type ast.BinOp or ast.Str/ast.Constant |
273 @param stop base node to stop at |
275 @param stop base node to stop at |
274 @type ast.BinOp or ast.Str |
276 @type ast.BinOp or ast.Str/ast.Constant |
275 @return tuple containing the root node of the expression and the string |
277 @return tuple containing the root node of the expression and the string |
276 value |
278 value |
277 @rtype tuple of (ast.AST, str) |
279 @rtype tuple of (ast.AST, str) |
278 """ |
280 """ |
279 def _get(node, bits, stop=None): |
281 def _get(node, bits, stop=None): |
295 if isinstance(node, ast.BinOp): |
297 if isinstance(node, ast.BinOp): |
296 _get(node, bits, stop) |
298 _get(node, bits, stop) |
297 |
299 |
298 return ( |
300 return ( |
299 node, |
301 node, |
300 " ".join([x.s for x in bits if isinstance(x, ast.Str)]) |
302 " ".join([x.s for x in bits if AstUtilities.isString(x)]) |
301 ) |
303 ) |
302 |
304 |
303 |
305 |
304 def getCalledName(node): |
306 def getCalledName(node): |
305 """ |
307 """ |