The Import Graph class is a data structure that allows users to manipulate different files under a Python project. It leverage import relations in each of source files.
| Static Method | extract |
To parse import statements from the AST tree Args: source: source code text Returns: class/function definitions, ast tree and alias pairs |
| Static Method | find |
To locate a child node using node name |
| Static Method | find |
To locate a node using node name |
| Static Method | leaf2root |
To generate the full path to the top level module from the given node. Args: node: the tree node Returns: the full path name in the form of dotted string. |
| Static Method | parse |
To parse import statements from the AST tree Args: tree: Python AST object Returns: an import map data structure |
| Method | __init__ |
To constuct an import graph. Args: entry_point: the top level folder path such as "my-python-projects/homework1". The argument must not endswith slash! |
| Method | build |
To build enhanced directory tree for further analysis |
| Method | get |
To return all the leaf nodes in this tree. Each of leaf nodes represents a single Python script. |
| Method | go |
To locate a particular node from the tree from the current node given a visit path from import statement. For instance, a visit path of [example, module_a, func] means, if we can locate the function definition ... |
| Instance Variable | entry |
Undocumented |
| Instance Variable | root |
Undocumented |
| Method | _build |
Undocumented |
To parse import statements from the AST tree Args: source: source code text Returns: class/function definitions, ast tree and alias pairs
To generate the full path to the top level module from the given node. Args: node: the tree node Returns: the full path name in the form of dotted string.
To parse import statements from the AST tree Args: tree: Python AST object Returns: an import map data structure
To constuct an import graph. Args: entry_point: the top level folder path such as "my-python-projects/homework1". The argument must not endswith slash!
To locate a particular node from the tree from the current node given a visit path from import statement.
For instance, a visit path of [example, module_a, func] means, if we can locate the function definition func from module_a under example folder.
The function tries to locate the given path using both relative and absolute import path.
Args:
visit_path: a list of names that represent different level python modules.