pyexperiment.Config¶
- class pyexperiment.Config(filename=None, spec=u'configspec.ini', options=None, default_spec=None)[source]¶
Represents a singleton configuration object.
- __init__(filename=None, spec=u'configspec.ini', options=None, default_spec=None)[source]¶
Initializer
Methods
__init__([filename, spec, options, default_spec]) Initializer base_keys() Returns the keys of the first level of the mapping clear(() -> None. Remove all items from D.) get(key[, default]) Get the key or return the default value if provided get_instance() Get the singleton instance if its initialized. get_or_set(key, value) Either gets the value associated with key or set it initialize(*args, **kwargs) Initializes the singleton. items(() -> list of D’s (key, value) pairs, ...) iteritems(() -> an iterator over the (key, ...) iterkeys(() -> an iterator over the keys of D) itervalues(...) keys(() -> list of D’s keys) load(filename[, spec, options]) Loads a configuration from filename (or string). merge(other) Merge in another mapping, giving precedence to self override_with_args(options) Override configuration with option dictionary pop((k[,d]) -> v, ...) If key is not found, d is returned if given, otherwise KeyError is raised. popitem(() -> (k, v), ...) as a 2-tuple; but raise KeyError if D is empty. reset_instance() Overloads reset_instance to reset the DEFAULT_CONFIG save(filename) Write configuration to file section_keys() Returns the keys of the sections (and subsections) of the mapping setdefault((k[,d]) -> D.get(k,d), ...) show() Pretty-prints the content of the mapping update(([E, ...) If E present and has a .keys() method, does: for k in E: D[k] = E[k] validate_config(config) Validate configuration values(() -> list of D’s values) Attributes
CONFIG_SPEC_PATH Path of the file with the specification for configurations. DEFAULT_CONFIG Default configuration, later used by initialize SECTION_SEPARATOR