cfitall.registry.ConfigurationRegistry

class ConfigurationRegistry(name, defaults=None, providers=None)

Bases: object

The configuration registry holds configuration data from different sources and reconciles it for retrieval. If the defaults dict is provided, it will be used to seed the default configuration values for the registry, equivalent to calling set_default() for each configuration key in defaults.

Parameters

Methods

get

Get a configuration value by its dotted path key; returns the requested value as its native type stored in the registry.

get_bool

Get a configuration value by its dotted path key; attempts to return the requested value as a boolean or raises TypeError.

get_decimal

Get a configuration value by its dotted path key; attempts to return the requested value as a Decimal or raises TypeError.

get_float

Get a configuration value by its dotted path key; attempts to return the requested value as a float or raises TypeError.

get_int

Get a configuration value by its dotted path key; attempts to return the requested value as an int or raises TypeError.

get_list

Get a configuration value by its dotted path key; attempts to return the requested value as a list or raises TypeError.

get_string

Get a configuration value by its dotted path key; attempts to return the requested value as a string or raises TypeError.

set

Explicitly set config_key (a dotted key string) to value.

set_default

Set the default value for config_key (a dotted key string) to value.

update

Updates configuration values from all providers.

Attributes

all

Returns a dictionary of all the configuration data that is considered for merging, before it is merged into the final configuration.

config_keys

Returns a list of currently used configuration keys as dotted paths, for use with the get() or set() methods.

dict

Returns a dict of merged configuration data

env_vars

Returns a list of environment variables known from config files and defaults

flattened

Returns a "flattened" dictionary of merged config values, condensing hierarchies into dotted paths and returning simple key-value pairs.

json

Returns json representation of merged configuration.

yaml

Returns yaml representation of merged configuration.

providers

The providers attribute holds the ProviderManager instance for the Registry.

values

Dictionary containing defaults and overrides: {"defaults": {}, "super": {}}

property all: Dict

Returns a dictionary of all the configuration data that is considered for merging, before it is merged into the final configuration.

Return type

Dict

property config_keys: List[str]

Returns a list of currently used configuration keys as dotted paths, for use with the get() or set() methods.

Return type

List[str]

property dict: Dict

Returns a dict of merged configuration data

Return type

Dict

property env_vars: List[str]

Returns a list of environment variables known from config files and defaults

Return type

List[str]

property flattened: Dict

Returns a “flattened” dictionary of merged config values, condensing hierarchies into dotted paths and returning simple key-value pairs.

Return type

Dict

get(config_key)

Get a configuration value by its dotted path key; returns the requested value as its native type stored in the registry.

Return type

Union[bool, Decimal, float, int, list, str, None]

get_bool(config_key)

Get a configuration value by its dotted path key; attempts to return the requested value as a boolean or raises TypeError.

Return type

Optional[bool]

get_decimal(config_key)

Get a configuration value by its dotted path key; attempts to return the requested value as a Decimal or raises TypeError.

Return type

Optional[Decimal]

get_float(config_key)

Get a configuration value by its dotted path key; attempts to return the requested value as a float or raises TypeError.

Return type

Optional[float]

get_int(config_key)

Get a configuration value by its dotted path key; attempts to return the requested value as an int or raises TypeError.

Return type

Optional[int]

get_list(config_key, csv=True)

Get a configuration value by its dotted path key; attempts to return the requested value as a list or raises TypeError. If csv is True (default), split value on commas.

Return type

Optional[list]

get_string(config_key)

Get a configuration value by its dotted path key; attempts to return the requested value as a string or raises TypeError.

Return type

Optional[str]

property json: str

Returns json representation of merged configuration.

Return type

str

providers: cfitall.manager.ProviderManager

The providers attribute holds the ProviderManager instance for the Registry.

set(config_key, value)

Explicitly set config_key (a dotted key string) to value. Values set via this method take precedence over all other configuration sources.

Return type

None

set_default(config_key, value)

Set the default value for config_key (a dotted key string) to value. Values set via this method will be overridden by any configuration provider containing a matching config_key.

Return type

None

update()

Updates configuration values from all providers.

Return type

None

values: Dict

Dictionary containing defaults and overrides: {"defaults": {}, "super": {}}

property yaml: str

Returns yaml representation of merged configuration.

Return type

str