configuration

This module contains the following classes:

  • Configuration which is a dictionary with a fixed set of keys, possibly with default values and key aliases.

New in version 1.4.1.

class aeneas.configuration.Configuration(config_string=None)[source]

A generic configuration object, that is, a dictionary with a fixed set of keys, each with a type, a default value, and possibly aliases.

Keys are (unique) Unicode strings.

Values are stored as Unicode strings (or None), and casted to the type of the field (int, float, bool, TimeValue, etc.) when accessed.

For bool keys, values listed in TRUE_ALIASES are considered equivalent to a True value.

If config_string is not None, the given string will be parsed and key=value pairs will be stored in the object, provided that key is listed in FIELDS.

Parameters:config_string (string) – the configuration string to be parsed
Raises:TypeError: if config_string is not None and it is not a Unicode string
Raises:KeyError: if trying to access a key not listed above
FIELDS = []

The fields, that is, key names each with associated default value, type, and possibly aliases, of this object.

TRUE_ALIASES = [True, 'TRUE', 'True', 'true', 'YES', 'Yes', 'yes', '1', 1]

Aliases for a True value for bool fields

clone()[source]

Return a deep copy of this configuration object.

New in version 1.7.0.

Return type:Configuration
config_string

Build the storable string corresponding to this configuration object.

Return type:string
classmethod parameters(sort=True, as_strings=False)[source]

Return a list of tuples (field, description, type, default), one for each field of the configuration.

Parameters:
  • sort (bool) – if True, return the list sorted by field
  • as_strings (bool) – if True, return formatted strings instead
Return type:

list