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’s conf

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 a Configuration can be aliased to one another.

copy(other)[source]

Copy configuration from another object into this one

Parameters
otherdict or Configuration

Configuration to copy from

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 a KeyError is raised

Parameters
pnamestr

they key of the value you want to return.

defaultobject

The default value to return if there’s no entry for pname

Returns
object

The value corresponding to the key

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 just Configuration.open. Generally, this value is suitable for finding files in locations relative to the config file, but not for much else.

Parameters
file_namestr

configuration file encoded as JSON

Returns
Configuration

returns an instance of this class with the configuration taken from the JSON file

See also

process_config
classmethod process_config(config_dict, variables=None)[source]

Resolves variables in config values and creates an instance of this class

Parameters
config_dictdict

The source for the resulting config

Returns
Configuration

config populated with variables