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 a configuration value by its dotted path key; returns the requested value as its native type stored in the registry.
Get a configuration value by its dotted path key; attempts to return the requested value as a boolean or raises TypeError.
Get a configuration value by its dotted path key; attempts to return the requested value as a Decimal or raises TypeError.
Get a configuration value by its dotted path key; attempts to return the requested value as a float or raises TypeError.
Get a configuration value by its dotted path key; attempts to return the requested value as an int or raises TypeError.
Get a configuration value by its dotted path key; attempts to return the requested value as a list or raises TypeError.
Get a configuration value by its dotted path key; attempts to return the requested value as a string or raises TypeError.
Explicitly set config_key (a dotted key string) to value.
Set the default value for config_key (a dotted key string) to value.
Updates configuration values from all providers.
Attributes
Returns a dictionary of all the configuration data that is considered for merging, before it is merged into the final configuration.
Returns a list of currently used configuration keys as dotted paths, for use with the get() or set() methods.
Returns a dict of merged configuration data
Returns a list of environment variables known from config files and defaults
Returns a "flattened" dictionary of merged config values, condensing hierarchies into dotted paths and returning simple key-value pairs.
Returns json representation of merged configuration.
Returns yaml representation of merged configuration.
The providers attribute holds the ProviderManager instance for the Registry.
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
- property config_keys: List[str]¶
Returns a list of currently used configuration keys as dotted paths, for use with the get() or set() methods.
- property env_vars: List[str]¶
Returns a list of environment variables known from config files and defaults
- property flattened: Dict¶
Returns a “flattened” dictionary of merged config values, condensing hierarchies into dotted paths and returning simple key-value pairs.
- Return type
- get(config_key)¶
Get a configuration value by its dotted path key; returns the requested value as its native type stored in the registry.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- 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
- values: Dict¶
Dictionary containing defaults and overrides:
{"defaults": {}, "super": {}}