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
-
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¶
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