sawtooth.config module

exception sawtooth.config.ConfigFileNotFound(config_files, search_path)[source]

Bases: exceptions.Exception

Exception thrown when config files are expected but not found.

exception sawtooth.config.InvalidSubstitutionKey(key, config_key, config_value, source)[source]

Bases: exceptions.Exception

Exception raised when a config uses invalid substitution key.

class sawtooth.config.Config(name='config', cfg=None, source=None, **kwargs)[source]

Bases: dict

Configuration base class.

get_source(key)[source]

Returns the source of the key.

resolve(substitutions)[source]

Performs path substitutions, as provided, and then returns a dict of key/value pairs.

Keyword arguments: substitutions – a dict where the key is the variable to be substituted and the value is the config key to use to lookup the value

class sawtooth.config.EnvConfig(env_to_config_list)[source]

Bases: sawtooth.config.Config

Configuration based on environment variables.

get_source(key)[source]
class sawtooth.config.ArgparseOptionsConfig(option_to_config_list, options)[source]

Bases: sawtooth.config.Config

Configuration based on argparse options.

class sawtooth.config.JsonConfig(lines, filename=None)[source]

Bases: sawtooth.config.Config

Loads configuration from a JSON file given the file content.

class sawtooth.config.JsonFileConfig(filename)[source]

Bases: sawtooth.config.Config

Loads configuration from a JSON file given a filename.

class sawtooth.config.AggregateConfig(configs)[source]

Bases: sawtooth.config.Config

Aggregates multiple Configs by applying them in order.

get_source(key)[source]
sawtooth.config.load_config_files(config_files, search_path, config_files_required=True)[source]

Loads a set of config files from a search path.

Keyword arguments: config_files – a list of config filenames search_path – a list of directories to search config_files_required – if True, ConfigFilesNotFound is thrown if the configuration files cannot be located