THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class ModuleInspector: (source)
Undocumented
| Class Method | load |
Load and return a class object from a specified module. |
| Static Method | _collect |
Add Python module names from one discovered directory. |
| Static Method | discover |
Discover frozen dataclasses in specified modules. |
| Static Method | discover |
Discover Python modules in a directory tree. |
| Static Method | file |
Determine if a file imports any target modules using AST analysis. |
| Class Variable | __cache |
Undocumented |
type, module_path: str | None = None, class_name: str | None = None, *, metadata: dict[ str, str] | None = None) -> type:
(source)
¶
Load and return a class object from a specified module.
Import the given module and retrieve the class by name, using internal caches for efficiency. If not provided directly, module and class names can be extracted from the metadata dictionary.
| Parameters | |
cls:type | Reference to the class for caching and method access. |
modulestr or None | Dotted path to the module (e.g., 'orionis.*.config.app.entities.app'). |
classstr or None | Name of the class to retrieve from the module. |
metadata:dict[str, str] or None, optional | Optional dictionary containing 'module' and 'class' keys. |
| Returns | |
type | The resolved class object. |
| Raises | |
ImportError | If the module cannot be imported. |
AttributeError | If the class does not exist in the module. |
TypeError | If the resolved attribute is not a class. |
Add Python module names from one discovered directory.
| Parameters | |
package:str | Dotted package name relative to the application root. |
files:list[str] | File names reported by the directory walk. |
modules:set[str] | Destination set shared by the discovery traversal. |
| Returns | |
None | Add modules in place, omitting a root-level package initializer. |
set[ str]) -> set[ tuple[ str, str, str, type[ Any]]]:
(source)
¶
Discover frozen dataclasses in specified modules.
Traverse the given set of module names, import each module, and inspect its attributes to find frozen dataclasses defined within the module.
| Parameters | |
modules:set[str] | Set of module names to inspect. |
| Returns | |
set[tuple[str, str, str, type[Any]]] | Set of tuples containing file name (without extension), module path, class name, and class type for each discovered frozen dataclass. |
| Raises | |
RuntimeError | If a module cannot be imported. |
Discover Python modules in a directory tree.
Traverse the target directory to find Python files and convert their paths to module notation. Exclude virtual environments and import caches. Collect each directory's modules with package initializers normalized to their package module names.
| Parameters | |
basePath | Root directory of the application. |
targetPath | Directory to search for Python modules. |
| Returns | |
set of str | Set of discovered module names in dot notation. |
| Raises | |
ValueError | If the target directory is outside the base directory. |
Path, target_modules: set[ str], *, allow_empty: bool = False) -> bool:
(source)
¶
Determine if a file imports any target modules using AST analysis.
| Parameters | |
filePath | Path to the file to analyze. |
targetset[str] | Set of module names to check for imports. |
allowbool, optional | Whether an empty source is accepted without a required import. |
| Returns | |
bool | Whether the file imports a target or is explicitly allowed to be empty. |