pynenc.util.import_app¶
Module Contents¶
Functions¶
Builds a file path from a module name. |
|
Creates a module specification from a file location. |
|
Loads a module from a given specification. |
|
Attempts to import a module as a file. |
|
Finds and returns the Pynenc app instance from a given module. |
|
Finds the Pynenc app instance in the specified module. |
API¶
- pynenc.util.import_app.build_file_path_from_module_name(module_name: str) str[source]¶
Builds a file path from a module name.
- Parameters:
module_name (str) – The name of the module.
- Returns:
The file path corresponding to the module.
- Raises:
ValueError – If the module name does not specify a path.
- pynenc.util.import_app.create_module_spec(app_instance_name: str, file_location: str) importlib.machinery.ModuleSpec[source]¶
Creates a module specification from a file location.
- Parameters:
- Returns:
A ModuleSpec object.
- Raises:
ValueError – If the module spec could not be created.
- pynenc.util.import_app.load_module_from_spec(spec: importlib.machinery.ModuleSpec) types.ModuleType[source]¶
Loads a module from a given specification.
- Parameters:
spec (importlib.machinery.ModuleSpec) – The module specification.
- Returns:
The loaded module.
- Raises:
ValueError – If the loader is not found for the given spec.
- pynenc.util.import_app.import_module_as_file(module_name: str, ex: Exception) types.ModuleType[source]¶
Attempts to import a module as a file.
- Parameters:
- Returns:
The imported module.
- Raises:
ValueError – If the module file cannot be found.
- pynenc.util.import_app.find_pynenc_instance_in_module(module: types.ModuleType) pynenc.app.Pynenc[source]¶
Finds and returns the Pynenc app instance from a given module.
- Parameters:
module (types.ModuleType) – The module to search in.
- Returns:
The found Pynenc app instance.
- Raises:
ValueError – If no Pynenc app instance is found.
- pynenc.util.import_app.find_app_instance(module_name: str | None) pynenc.app.Pynenc[source]¶
Finds the Pynenc app instance in the specified module.
- Parameters:
module_name (str | None) – The name of the module.
- Returns:
The Pynenc app instance.
- Raises:
ValueError – If no module name is provided.