257 |
257 |
258 def concatString(node, stop=None): |
258 def concatString(node, stop=None): |
259 """ |
259 """ |
260 Function to build a string from an ast.BinOp chain. |
260 Function to build a string from an ast.BinOp chain. |
261 |
261 |
262 This will build a string from a series of ast.Str/ast.Constant nodes |
262 This will build a string from a series of ast.Constant nodes |
263 wrapped in ast.BinOp nodes. Something like "a" + "b" + "c" or "a %s" % val |
263 wrapped in ast.BinOp nodes. Something like "a" + "b" + "c" or "a %s" % val |
264 etc. The provided node can be any participant in the BinOp chain. |
264 etc. The provided node can be any participant in the BinOp chain. |
265 |
265 |
266 @param node node to be processed |
266 @param node node to be processed |
267 @type ast.BinOp or ast.Str/ast.Constant |
267 @type ast.BinOp or ast.Constant |
268 @param stop base node to stop at |
268 @param stop base node to stop at |
269 @type ast.BinOp or ast.Str/ast.Constant |
269 @type ast.BinOp or ast.Constant |
270 @return tuple containing the root node of the expression and the string |
270 @return tuple containing the root node of the expression and the string |
271 value |
271 value |
272 @rtype tuple of (ast.AST, str) |
272 @rtype tuple of (ast.AST, str) |
273 """ |
273 """ |
274 |
274 |
289 while isinstance(node._securityParent, ast.BinOp): |
289 while isinstance(node._securityParent, ast.BinOp): |
290 node = node._securityParent |
290 node = node._securityParent |
291 if isinstance(node, ast.BinOp): |
291 if isinstance(node, ast.BinOp): |
292 _get(node, bits, stop) |
292 _get(node, bits, stop) |
293 |
293 |
294 return (node, " ".join([x.s for x in bits if AstUtilities.isString(x)])) |
294 return (node, " ".join([x.value for x in bits if AstUtilities.isString(x)])) |
295 |
295 |
296 |
296 |
297 def getCalledName(node): |
297 def getCalledName(node): |
298 """ |
298 """ |
299 Function to get the function name from an ast.Call node. |
299 Function to get the function name from an ast.Call node. |