MergedConfiguration

Currently the only way to put together Sources, so every configuration is a MergedConfiguration.

class mincfg.MergedConfiguration(sources: List[ConfigSource] | None = None)[source]

Merges configuration sources

Parameters:

sources – a list of :ref:ConfigSource objects to merge, with later ones overriding earlier ones

as_configparser(namespace: List[str] | None = None) ConfigParser[source]

return the config, or a namespace within it, as a ConfigParser

Parameters:

namespace – the namespace to return as a ConfigParser. If unspecified, return the entire config.

as_dict(namespace: List[str] | None = None) Dict[str, Any][source]

return the configuration, or a namespace within it, as a single dictionary

Parameters:

namespace – the namespace to return as a dict. If unspecified, return the entire config.

as_ns(namespace: List[str] | None = None) SimpleNamespace[source]

return the config, or a namespace within it, as a SimpleNamespace

Parameters:

namespace – the namespace to return as a SimpleNamespace. If unspecified, return the entire config.

get(key: str, namespace: ~typing.List[str] | None = None, default=None, parser=<class 'str'>, raise_error=True, doc=None)[source]

get a single config key

Parameters:
  • namespace – the ‘path’ in the config to the namespace to look the key up in

  • default – is the value to use if the key is not found

  • parser – is how to cast the result

  • raise_error – is whether to raise an error if the key is not found (note: supplying a default negates raise_error, as a (presumably) valid value is always available)

  • doc – is extra information to supply with the error message

load()[source]

Cause the config to be loaded; note that this need not be called directly, as it is lazily loaded. Subsequent calls _will_ re-load from the config sources.