progfiguration.sitewrapper¶
Progfiguration site wrapper
We keep a Python package path to the progfigsite module in progfiguration/__init__.py. Using that, wrapper functions in this module can find and import the module. If we can’t find a module with that path, raise ProgfigsiteModuleNotFoundError.
Provide functions for retrieving site-specific resources, including submodules and data files. All progfiguration core code should use these functions to access site resources.
Attributes¶
A private cache for the sitewrapper module |
Exceptions¶
Raised when the progfigsite module was not set |
|
Raised when the progfigsite module cannot be found |
Functions¶
|
Return a tuple of the progfigsite module name and module |
|
Set the progfigsite module by its filesystem path. |
|
Set the progfigsite module by its module name. |
|
The full path to a site submodule |
|
The Python module for a given site submodule |
|
A resource from a site submodule |
|
The filesystem path to the progfigsite package |
Package Contents¶
- exception progfiguration.sitewrapper.ProgfigsiteModuleNotSetError¶
Bases:
ModuleNotFoundError
Raised when the progfigsite module was not set
- exception progfiguration.sitewrapper.ProgfigsiteModuleNotFoundError¶
Bases:
ModuleNotFoundError
Raised when the progfigsite module cannot be found
- progfiguration.sitewrapper._sitewrapper_cache: Dict[str, Any]¶
A private cache for the sitewrapper module
Should only be accessed by getters and setters in the sitewrapper module.
- progfiguration.sitewrapper.get_progfigsite() Tuple[str, types.ModuleType] ¶
Return a tuple of the progfigsite module name and module
Raises:
- ProgfigsiteModuleNotSetError
If the progfigsite module was not set
- progfiguration.sitewrapper.set_progfigsite_by_filepath(filepath: pathlib.Path, module_name: str)¶
Set the progfigsite module by its filesystem path.
Args:
filepath
:The path to the module, eg “/path/to/module.py”.
module_name
:The name of the module, eg “example_site”.
Should match the package name so that ‘import module_name.submodule’ works.
- progfiguration.sitewrapper.set_progfigsite_by_module_name(module_name: str)¶
Set the progfigsite module by its module name.
The module must already be present in the Python path.
- progfiguration.sitewrapper.site_modpath(submodule_path: str) str ¶
The full path to a site submodule
- Args:
- submodule_path: The path to the submodule, relative to the site package.
This can be an empty string for the site package itself, or a dotted path to a submodule. E.g. “”, “nodes”, “nodes.example_node”
- progfiguration.sitewrapper.site_submodule(submodule_path: str) types.ModuleType ¶
The Python module for a given site submodule
- Args:
- submodule_path: The path to the submodule, relative to the site package.
This can be an empty string for the site package itself, or a dotted path to a submodule. E.g. “”, “nodes”, “nodes.example_node”
- Raises:
- ModuleNotFoundError: If the submodule does not exist
(not ImportError!)
- progfiguration.sitewrapper.site_submodule_resource(submodule_path: str, resource_name: str)¶
A resource from a site submodule
Similar to site_submodule(), but returns a resource from the submodule.
- Args:
- submodule_path: The path to the submodule, relative to the site package.
This can be an empty string if the resource is in the site package itself, or a dotted path to a submodule. E.g. “”, “nodes”, “nodes.example_node”
- resource_name: The name of the resource file.
E.g. “inventory.yml”, “secrets.yml”
- Raises:
- ModuleNotFoundError: If the submodule does not exist
(not ImportError!)
- progfiguration.sitewrapper.get_progfigsite_path() pathlib.Path ¶
The filesystem path to the progfigsite package
- Returns:
The path to the progfigsite package, as a string.