PyOpenWorm.configure module

exception PyOpenWorm.configure.BadConf[source]

Bases: Exception

Special exception subclass for alerting the user to a bad configuration

class PyOpenWorm.configure.ConfigValue[source]

Bases: object

A value to be configured. Base class intended to be subclassed, as its only method is not implemented

class PyOpenWorm.configure.Configure(**initial_values)[source]

Bases: object

A simple configuration object. Enables setting and getting key-value pairs

Unlike a dict, Configure objects will execute a function when retrieving values to enable deferred computation of seldom-used configuration values. In addition, entries in a Configure can be aliased to one another.

copy(self, other)[source]

Copy this configuration into a different object.

Parameters:other – A different configuration object to copy the configuration from this object into
Returns:
get(self, 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:
pname : str

they key of the value you want to return.

default : object

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

Returns:
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.

Parameters:file_name – configuration file encoded as JSON
Returns:a Configure object with the configuration taken from the JSON file
class PyOpenWorm.configure.Configureable(conf=None, **kwargs)[source]

Bases: object

An object which can accept configuration. A base class intended to be subclassed.

get(self, pname, default=None)[source]

Gets a config value from this Configureable’s conf

See also

Configure.get
class PyOpenWorm.configure.ImmutableConfigure(**initial_values)[source]

Bases: PyOpenWorm.configure.Configure