Implementation reference
Envprobe is implemented as a single Python package, named envprobe
.
Warning
While we strive to make the code as modular and easily extensible as possible, at the core, Envprobe is a single program that is offered whole. The core functions that people use Envprobe for are not fully available if the Python package is used as a library, as some of the business logic is part of the command implementations; and as such, the below documentation is geared and intended more for people who would like to contribute to the tool, rather than people who would import it as a library.
Miscellaneous functions
The envprobe.library
module contains some miscellaneous functions that are used to tie the creation of the global objects accessing the environment and the user’s state in a meaningful way.
- get_shell_and_env_always(env_dict=None, vartype_pipeline=None)
Return an
environment.Environment
andshell.Shell
, no matter what.- Parameters
env_dict (dict, optional) – The raw mapping of environment variables to their values, as in
os.environ
.vartype_pipeline (envprobe.environment.HeuristicStack, optional) – The type resolution heuristics pipeline to use. If not specified, the
environment.default_heuristic
will be used.
- Returns
shell (.shell.Shell) – The shell which use can be deduced from the current environment (by calling
shell.get_current_shell()
). If none such can be deduced, ashell.FakeShell
is returned, which is a validshell.Shell
subclass that tells the client code it is not capable of anything.env (.environment.Environment) – The environment associated with the current context and the instantiated Shell.
- get_snapshot(snapshot_name, read_only=True)
Creates the snapshot instance for the snapshot of the given name.
- Parameters
- Returns
The snapshot manager object. Access to the underlying file is handled automatically through this instance.
- Return type
- get_variable_information_manager(variable_name, read_only=True)
Creates the extended information attribute manager for environment variables based on the requested variable’s name.
- Parameters
- Returns
The configuration handler engine. Access to the underlying file is handled automatically through this instance.
- Return type
- get_variable_tracking(shell=None)
Creates a read-only tracking manager for the standard global and local configuration files.
- Parameters
shell (shell.Shell, optional) – The shell which is used in the current environment, used to retrieve the local configuration directory.
- Returns
The tracking handler engine. The configuration files are opened read-only.
- Return type