Evaluation Structure Generation
eval_structure_generation
Contains all functionality relating to loading and parsing python source code and creating custom import objects representing the dependencies between the modules.
file_filter
FileFilter
Uses a regex pattern to determine whether a file or directory should be excluded.
is_excluded(obj)
Returns True if the object matches one of the pre-configured exclusion patterns.
import_filter
ExternalImportFilter
Filters out imports of (some) external modules from the list of all imports. External modules are all modules that are not submodules of the configured module to search for imports.
Two possibilities: either all external modules are filtered out, or only those matching given regex patterns.
__init__(exclude_external_libraries, root_module_name, external_exclusions)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exclude_external_libraries |
bool
|
If True, external modules will be filtered out, otherwise this class implements a no-op. |
required |
root_module_name |
str
|
name of the module that determines which modules are considered external. If a module is a submodule of this module, it is considered internal. |
required |
external_exclusions |
tuple[str, ...]
|
regex pattern: all external modules that match it shall be filtered out. |
required |
filter(imports)
According to the configuration, imports will be filtered.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
imports |
Sequence[Import]
|
list of imports to be filtered |
required |
Returns: filtered list of imports
import_types
AbsoluteImport
Bases: Import
Represents an absolute import.
NamedModule
dataclass
Contains an ast module with its name.
Attributes:
Name | Type | Description |
---|---|---|
module |
Module
|
ast module object |
name |
str
|
module name |
RelativeImport
Bases: Import
Represents a relative import.
importee_module_calculator
ImporteeModuleCalculator
Adds all parent modules of imported modules if they are not yet part of the modules list.
calculate_importee_modules(imports, all_modules)
For all imported modules: Calculate parent modules and add them to the list of existing modules if they are not already part of this list. This mainly applies to external dependencies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
imports |
Sequence[Import]
|
|
required |
all_modules |
list[str]
|
|
required |
Returns:
Type | Description |
---|---|
list[str]
|
all modules extended by parent modules of imported modules |
parser
Parser
Parses all files that match given criteria starting at a source path.
parse(path)
Reads all python files in the given path and returns list of ast modules with names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Path
|
either to a file or to a directory |
required |
Returns: list of python modules, one per python file