Context#
- class processor_tools.context.Context(config: str | List[str] | dict | None = None, supercontext: List[Context | Tuple[Context, str]] | None = None, config_init: ConfigInit | None = None)[source]#
Class to determine and store processing state
- Parameters:
config – processing configuration data, either:
dictionary of configuration data
path of configuration file or directory containing set of configuration files
list of dicts/paths (earlier in the list overwrites later in the list)
- Parameters:
supercontext – context supercontext or list of supercontexts (earlier in the list overwrites later in the list), configuration values of which override those defined in the context. Each defined as context object or tuple of:
supercontext(Context) - supercontext objectsection(str) - name of section of supercontext to apply as supercontext
- Parameters:
config_init – config initialiser for setting up default config files/directories to be loaded every time the class is initialised, as well as providing methods for generating config file/directory paths. See
processor_tools.config.init_config.ConfigInitfor more details.
For example:
supercontext = Context({"section": {"val1": 1 , "val2", 2}}) (supercontext, "section")
Methods
Get config value if defined, else return default
Get available config value names
Get available config value names
Sets config data
Update config values
Update config values from file
Write config values to file
Attributes
Returns defined configuration values
Return context supercontexts