flowbber.config

Module implementating the Configurator class.

Classes

class flowbber.config.Configurator

A Component configuration options manager.

Inheritance

Inheritance diagram of Configurator

add_option(key, default=None, optional=False, schema=None, secret=False)

Declare an option.

Parameters
  • key (str) – Key of the configuration option. Must be representable as a public Python variable.
  • default – Default value for this option if optional and no value was provided.
  • optional (bool) – Is this option mandatory or optional. Default is mandatory.
  • schema (dict) – Schema to validate the user value against.
  • secret (bool) – Boolean indicating that the options is a secret and thus shouldn’t be printed, logged, stored in plain text, etc.
add_validator(validator)

Add a custom validation function.

Parameters
validator (function) – A custom validator function.
validate(userconf)

Validate the given user configuration dictionary with the declared config handled by this configurator.

Raises
  • MissingOptions – if mandatory options are missing.
  • UnknownOptions – if non declared options are present.
Parameters

userconf (dict) – The user configuration.

Returns

A custom named tuple that maps the config keys with another named tuple that holds the name of the key, the value and the flag marking it as secret or not.

Return type

namedtuple