reflections
tergite_autocalibration.lib.utils.reflections
Functions:
| Name | Description |
|---|---|
find_inheriting_classes_ast_recursive |
Recursively finds all classes in a directory and its subdirectories that inherit |
import_class_from_file |
Imports a class from a given file path. |
find_inheriting_classes_ast_recursive
find_inheriting_classes_ast_recursive(directory: Union[str, Path], base_class_name: str = None) -> dict
Recursively finds all classes in a directory and its subdirectories that inherit from the specified base class using AST parsing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str
|
The root directory to search for classes. |
required |
base_class_name
|
str
|
The name of the base class to check inheritance. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary where keys are file paths, and values are lists of class names inheriting from base_class_name. |
import_class_from_file
Imports a class from a given file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
class_name
|
str
|
The name of the class to import. |
required |
file_path
|
str
|
The path to the file containing the class. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Type |
Type
|
The class type if found, otherwise raises an AttributeError or FileNotFoundError. |