owmeta_core.configure module¶
This module defines a generic configuration dictionary with a few extra features.
A list of all documented configuration values can be found under “configuration values” in the index.
- exception owmeta_core.configure.BadConf[source]¶
Bases:
Exception
Special exception subclass for alerting the user to a bad configuration
- class owmeta_core.configure.ConfigValue[source]¶
Bases:
object
A value to be configured. Base class intended to be subclassed, as its only method is not implemented
- class owmeta_core.configure.Configurable(conf=None, **kwargs)[source]¶
Bases:
object
An object which can accept configuration. A base class intended to be subclassed.
- get(pname, default=None)[source]¶
Gets a config value from this
Configurable
’sconf
See also
- class owmeta_core.configure.Configuration(**initial_values)[source]¶
Bases:
object
A simple configuration object. Enables setting and getting key-value pairs
Unlike a
dict
, Configuration objects will execute a function when retrieving values to enable deferred computation of seldom-used configuration values. In addition, entries in aConfiguration
can be aliased to one another.- copy(other)[source]¶
Copy configuration from another object into this one
- Parameters
- other
dict
orConfiguration
Configuration to copy from
- other
- Returns
Configuration
self
- get(pname, default=NO_DEFAULT)[source]¶
Get some parameter value out by asking for a key. Note that unlike
dict
, if you don’t specify a default, then aKeyError
is raised
- link(*names)[source]¶
Call link() with the names of configuration values that should always be the same to link them together
- classmethod open(file_name)[source]¶
Open a configuration file and read it to build the internal state.
Sets
configure.file_location
to the given file_name- configure.file_location¶
The location where a
Configuration
was loaded from. This may be set by any function that loads the configuration – not justConfiguration.open
. Generally, this value is suitable for finding files in locations relative to the config file, but not for much else.
- Parameters
- file_name
str
configuration file encoded as JSON
- file_name
- Returns
Configuration
returns an instance of this class with the configuration taken from the JSON file
See also
- classmethod process_config(config_dict, variables=None)[source]¶
Resolves variables in config values and creates an instance of this class
- Parameters
- config_dict
dict
The source for the resulting config
- config_dict
- Returns
Configuration
config populated with variables