class Builder: (source)
Coordinate the process of parsing and analysing the ast trees.
Note | |
The approach is to proceed incrementally, and outside-in. First, you add the top-level directory structure, this computes the whole package/module structure. Then, each modules are parse, it creates all object instances, then it does some analysis on what we’ve found in post-processing. |
Method | add |
Add a module or package from a system path. If the path is pointing to a directory, reccursively add all submodules. |
Method | add |
Add a module to the builder from a simple string. |
Method | build |
Drives the building, builds modules until there is no unprocessed modules anymore. |
Method | get |
Returns the processed or processing (in case of cylces) module or None if the name cannot be found. |
Instance Variable | astroid |
Astroid inference system tweaks. |
Instance Variable | options |
Options |
Instance Variable | pprocessor |
Post processor. |
Instance Variable | processing |
Mapping from module's full_name to the processing state |
Instance Variable | root |
Tree root. |
Instance Variable | visitor |
AST build visitor extensions. |
Property | introspect |
Optionally instrospect C modules enabled? |
Property | unprocessed |
Undocumented |
Method | _add |
Create a new empty module and add it to the tree. Initiate it's state in the AST processing map. |
Method | _add |
Handles '__init__.py' files and reccursively calls itself when traversing subdirectories. |
Method | _discard |
Runs before adding a new module to the root. Check if a module already has the same name. |
Method | _maybe |
Ignores the files that are not recognized as python files. |
Method | _post |
Undocumented |
Method | _process |
Parse the module file to an AST and create it's members. At the time this method is called, not all objects are created. But all module instances already exist and are added to root.all_objects , including nested modules. |
Method | _process |
Undocumented |
Instance Variable | _added |
Undocumented |
Instance Variable | _processing |
Undocumented |
Add a module or package from a system path. If the path is pointing to a directory, reccursively add all submodules.
Parameters | |
path:Path | Undocumented |
Add a module to the builder from a simple string.
Parameters | |
text:str | The module string |
modname:str | The module short name |
parentOptional[ | The fully qualified name of the parent package of this module. The package should be added to the builder first. |
path:str | Undocumented |
isbool | Whether this module is a package. |
Drives the building, builds modules until there is no unprocessed modules anymore.
Runs post-build operations after.
Note | |
This method should only be run once per Builder instance. |
Returns the processed or processing (in case of cylces) module or None if the name cannot be found.
Parameters | |
modname:str | Undocumented |
raisebool | Undocumented |
Returns | |
Optional[ | Undocumented |
Create a new empty module and add it to the tree. Initiate it's state in the AST processing map.
Parameters | |
path:Union[ | path where we can find the module file(s). |
modname:str | the name of the new module (local name, not qname). |
parent:Optional[ | the parent package, if any. |
isbool | whether this module is a package. |
isbool | whether this module is c extension. |
pyOptional[ | the live module, usually None because it parses
the source code file instead. |
pyOptional[ | the module's string, usually None because it directly
gets the AST from the file path.
This is used when calling add_module_string(). |
Returns | |
_model.Module | Undocumented |
Handles '__init__.py' files and reccursively calls itself when traversing subdirectories.
Parameters | |
path:Path | Undocumented |
parent:Optional[ | Undocumented |
Runs before adding a new module to the root. Check if a module already has the same name.
Parameters | |
mod:_model.Module | Undocumented |
modstr | Undocumented |
Returns | |
Optional[ | The older module (already present) if the new module has been discarded. This should stop the new module from beeing added, it's a duplicate module. |
Note | |
The rule is that the package/directory wins over the regular module, also, c-modules wins over regular modules. |
Ignores the files that are not recognized as python files.
Parameters | |
path:Path | Undocumented |
parent:Optional[ | Undocumented |
Parse the module file to an AST and create it's members. At the time this method is called, not all objects are created.
But all module instances already exist and are added to root.all_objects
, including nested modules.
Parameters | |
mod:_model.Module | Undocumented |