API Reference for Enthought Tool Suite 3.2.0
Tools for parsing/unparsing python code to discover information about it.
KW_ARGS = 8
Flags for func_code.co_flags that indicate whether we have a variable number of arguments or keyword arguments for the function.
VAR_ARGS = 4
finds the funtion node, optionally matching the name
Given Block's ast, return a dictionary of def names and the Function ast that represents them. This will be used to create a LocalFunctionInfo.
Convert the inputs found in the AST into InputVariable objects.
This handles finding the keyword arguments and trying to convert them from their AST representation into something that is useful as a default argument. We also track whether the input arguments include a varargs (*args) and kwargs (**kw) style argument. If they do, we assign the names to the varargs and kwargs traits on the class.
Given a function, return its args, keywords, and full argument list.
Returns function names and input/output binding information from the CallFunc.
Find the function returns from a function's ast.
Find the function returns from its source
Find the return values names from a function by looking at its source.
This isn't always possible, but this function gets the source code, looks for return statements for variable names. If all values in the return statement are variable names, it returns these names. If it is more complex, or it is unable to find the source code, it returns None.
Example:
>>> from ftplib import parse227 >>> function_returns_from_function(parse227) ['host', 'port']
Find the outputs by parsing the return statement in the ast and getting the names of the returned arguments.
| Local name | Refers to |
|---|---|
| _pkgutil | enthought.block_canvas.function_tools._pkgutil |
| ASTVisitor | compiler.visitor.ASTVisitor |
| compiler | compiler |
| Function | compiler.ast.Function |
| getsource | enthought.block_canvas.function_tools.decorator_tools.getsource |
| inspect | inspect |
| Module | compiler.ast.Module |
| OutputVariable | enthought.block_canvas.function_tools.function_variables.OutputVariable |
| Stmt | compiler.ast.Stmt |
| sys | sys |
| unparse | enthought.blocks.compiler_unparse.unparse |
| walk | enthought.blocks.analysis.walk |
| warnings | warnings |
© Copyright 2002-2009 Enthought, Inc.