API Reference

Config

exception manyconfig.config.InvalidConfigException(message, errors)[source]

Exception raises when a configuration is invalid.

class manyconfig.config.MetaConfig(silent=False, schema=None)[source]

Base class for metaconfigurations.

A schema passed at instantiation override any schema set at level class.

Parameters:
  • silent (bool) – Don’t raise exceptions on invalid configurations
  • schema – A marshmallow schema to validate loaded configuration
load(schema=None)[source]

Load the configuration

Return dict:Dict representing the configuration
schema = None

A marshmallow schema to validate loaded configuration

Environment

class manyconfig.environment.EnvironmentMetaConfig(namespace, **kwargs)[source]

Pull configuration from environment

An environment variable is considered to be in a namespace if it begins by it. That is, FOO_BAR is part of the FOO_ namespace.

All environment variables of the given namespace will be collected, and the namespace removed from its beginning. It is then inserted in the configuration with its value.

Parameters:namespace – The namespace to pull from

File

class manyconfig.file.DecoratorDict[source]
class manyconfig.file.FileMetaConfig(format, filepath, binary=False, **kwargs)[source]

Pull configuration from a file.

Parameters:
  • filepath – the path of the configuration file.
  • binary (bool) – Open the file in binary mode.
exception manyconfig.file.InvalidFormatError[source]
manyconfig.file.parse_ini(file_object)[source]

Parse the INI in the file.

Manyconfig

class manyconfig.manyconfig.AnyConfig(*metaconfigs, **kwargs)[source]

Pull configuration from the first existing source

It will iter through the different MetaConfig given and yield the first non-empty valid configuration.

Parameters:metaconfigs – A list of configurations to pull values from
class manyconfig.manyconfig.ManyConfig(*metaconfigs, **kwargs)[source]

Pull configuration from many others.

This class is the real plus-value of ManyConfig. It takes some configuration sources, load them and merge them in a single configuration.

Configurations are loaded in the given order, and new values for the same configuration key overrides older ones.

This allow implementation of Bash-like configurations, where multiple files are read and each one take precedence over the last one.

Parameters:metaconfigs – A list of configurations to pull values from
manyconfig.manyconfig.merge(*configs)[source]

Merge several dicts to produce one.

If a key is present in two or more dicts, the value of the lattest occurence is took.