msticpy.lazy_importer module
Lazy importer for msticpy sub-packages.
- msticpy.lazy_importer.lazy_import(importer_name: str, import_list: Iterable[str]) Tuple[ModuleType, Callable, Callable]
Return the importing module and a callable for lazy importing.
- Parameters:
importer_name (str) – The module performing the import to help facilitate resolving relative imports.
import_list (Iterable[str]) – Iterable of the modules to be potentially imported (absolute or relative). The basic form is “[mod_path.]import_item”. This will import “import_item” from the module specified by “mod_path”. The as form of importing is also supported, e.g. “pkg.mod.func as spam_func”.
- Returns:
This function returns a tuple of two items. The first is the importer module for easy reference within itself. The second item is a callable to be set to __getattr__ of the calling module.
- Return type:
Tuple[module, Callable]
Notes
Code modified (slightly) from example by Brett Cannon. https://snarky.ca/lazy-importing-in-python-3-7/