class documentation

class CodeToAst(object): (source)

View In Hierarchy

Given a module, or a function that was compiled as part of a module, re-compile the module into an AST and extract the sub-AST for the function. Allow caching to reduce number of compiles. Also contains static helper utility functions to look for python files, to parse python files, and to extract the file/line information from a code object.

Static Method find_py_files Return all the python files in a source tree
Static Method get_file_info Returns the file and line number of a code object.
Static Method parse_file Parse a python file into an AST.
Method __call__ Undocumented
Method __init__ Undocumented
Instance Variable cache Undocumented
@staticmethod
def find_py_files(srctree, ignore=None): (source)

Return all the python files in a source tree Ignores any path that contains the ignore string This is not used by other class methods, but is designed to be used in code that uses this class.

@staticmethod
def get_file_info(codeobj): (source)

Returns the file and line number of a code object. If the code object has a __file__ attribute (e.g. if it is a module), then the returned line number will be 0

@staticmethod
def parse_file(fname): (source)

Parse a python file into an AST. This is a very thin wrapper around ast.parse TODO: Handle encodings other than the default for Python 2 (issue #26)

def __call__(self, codeobj): (source)

Undocumented

def __init__(self, cache=None): (source)

Undocumented

cache = (source)

Undocumented