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 inTRUE_ALIASES
are considered equivalent to aTrue
value.If
config_string
is notNone
, the given string will be parsed andkey=value
pairs will be stored in the object, provided thatkey
is listed inFIELDS
.Parameters: config_string (string) – the configuration string to be parsed Raises: TypeError: if config_string
is notNone
and it is not a Unicode stringRaises: 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 forbool
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
- sort (bool) – if
-