ahvn.utils.basic.deps_utils module¶
Dependency management and lazy loading utilities.
This module provides a clean, industrial-standard dependency management system and utilities for lazy loading modules.
- class ahvn.utils.basic.deps_utils.DependencyManager[源代码]¶
基类:
objectClean dependency management system.
- 返回类型:
- add(dep_info)[源代码]¶
Add a dependency.
- 返回类型:
- 参数:
dep_info (DependencyInfo)
- load(module_name, package=None, error_msg=None)[源代码]¶
Import an optional dependency, raising a clear error if missing.
- 参数:
- 返回类型:
- 返回:
The imported module.
- 抛出:
OptionalDependencyError -- If the module cannot be imported.
- exception ahvn.utils.basic.deps_utils.OptionalDependencyError[源代码]¶
基类:
DependencyError,ImportErrorOptional dependency not available.
- ahvn.utils.basic.deps_utils.lazy_getattr(name, export_map, package)[源代码]¶
Helper function to implement __getattr__ for lazy loading modules.
- 参数:
- 返回:
The requested attribute from the imported module.
- 抛出:
AttributeError -- If the name is not in the export_map.
- ahvn.utils.basic.deps_utils.collect_exports(package_names, parent_package)[源代码]¶
Collects exported names from a list of subpackages to build a master lazy map.
- ahvn.utils.basic.deps_utils.lazy_import_submodules(name, submodules, package)[源代码]¶
Helper function to lazy load submodules.