| 269 | |
| 270 | |
| 271 | def build_call(callstr, node): |
| 272 | if isinstance(node, ast.FunctionDef): # function name |
| 273 | func_expr = ast.Name(id=node.name, ctx=ast.Load()) |
| 274 | argstr = "`%s`" % callstr.replace("f", node.name) |
| 275 | elif isinstance(node, ast.Lambda): # lambda body expr |
| 276 | func_expr = node |
| 277 | argstr = "it with the arguments `%s`" % callstr.replace("f", "") |
| 278 | else: |
| 279 | raise TypeError("Can't handle AST that is passed.") |
| 280 | |
| 281 | parsed = ast.parse(callstr).body[0].value |
| 282 | parsed.func = func_expr |
| 283 | ast.fix_missing_locations(parsed) |
| 284 | return parsed, argstr |
| 285 | |
| 286 | |
| 287 | def check_call(state, callstr, argstr=None, expand_msg=None): |