libera_utils.config#

Configuration reader. To modify the configuration, see file: config.json

Module Attributes

config

Singleton (one per process) accessor for libera_utils.config._ConfigurationCache()

Classes

ConfigurationFormatter()

Customize the string formatter to replace fields in a config string with values from the configuration dictionary.

class libera_utils.config.ConfigurationFormatter#

Customize the string formatter to replace fields in a config string with values from the configuration dictionary. This will allow configuration parameters in the emus_config.json file to be based off of other configuration parameters by wrapping the configuration key in curly braces.

Methods

get_field(field_name, args, kwargs)

get_value(key, *args, **kwargs)

Overrides the default get_value method in the python formatter.

parse(format_string)

check_unused_args

convert_field

format

format_field

vformat

get_value(key: str, *args, **kwargs)#

Overrides the default get_value method in the python formatter. This will return the value from the emus configuration with the specified key.

class libera_utils.config._ConfigurationCache#

Class that stores the JSON configuration and provides methods for accessing configuration information

Methods

force_reload()

Force reloading of the JSON config

get(key)

Retrieves a configuration value from either the cached JSON or from the environment

_format_return_value(value: str)#

Recursively formats the returned value, looking for config keys to substitute.

Parameters:

value (str) – String to format

Return type:

str

_parse_numeric_types(value: str)#

Checks the final result of a config retrieval. If it is a string that can be interpreted as a float or int, parse it and return that.

Parameters:

value (any) – Final formatted value.

Return type:

str or float or int

force_reload()#

Force reloading of the JSON config

get(key)#

Retrieves a configuration value from either the cached JSON or from the environment

Parameters:

key (str) – Key for which to retrieve the configured value.

Returns:

Resulting value

Return type:

any

libera_utils.config.config = <libera_utils.config._ConfigurationCache object>#

Singleton (one per process) accessor for libera_utils.config._ConfigurationCache()