Undocumented
Class |
|
Undocumented |
Class |
|
No class docstring; 0/8 instance variable, 1/75 method documented |
Function | extract |
Parses some Python code as a module and extracts a designated AST node. |
Constant | BASE |
Undocumented |
Function | _bin |
Undocumented |
Function | _bool |
Undocumented |
Function | _comp |
Undocumented |
Function | _context |
Undocumented |
Function | _unary |
Undocumented |
Constant | _STATEMENT |
Undocumented |
Parses some Python code as a module and extracts a designated AST node. # DISCLIAMER: Inspiration taken from astroid project Statements: To extract one or more statement nodes, append #@ to the end of the line To give the extraction a name, append a name after #@ Examples: >>> def x(): >>> def y(): >>> x = 1 #@ x_constant (value) >>> return 1 #@ an_int_constant The return statement will be extracted with a name tuple, constant >>> class X(object): >>> def meth(self): #@ >>> pass The function object 'meth' will be extracted. If no statements or expressions are selected, the last toplevel statement will be returned. If the selected statement is a discard statement, (i.e. an expression turned into a statement), the wrapped expression is returned instead. For convenience, singleton lists are unpacked. :param str code: A piece of Python code that is parsed as a module. Will be passed through textwrap.dedent first. :param py2: flag to determine ast version :returns: The designated node from the parse tree, or a list of nodes, wrapped with namedtuple :rtype: namedtuple