config_client

Client to load and process YAML configuration files.

Module Contents

Classes

ConfigClient

Client to load and process YAML configuration files.

class config_client.ConfigClient(config_file_name='resources/app.yaml')

Client to load and process YAML configuration files.

property logger_properties: dict

Get the logger properties from the configuration.

env_var_pattern
env_var_with_default_pattern
logger
__get_other_static_config_files()

Load additional static configuration files specified in the application config.

__load_static_config_files()

Load additional static configuration files specified in the application config.

get(key, default_value=None)

Get a value from the configuration by key.

Parameters:
  • key – The key to look up in the configuration.

  • default_value – The default value to return if the key is not found.

Returns:

The value associated with the key, or the default value if the key is not found.

get_config_path(config_file_name)

Get the absolute path of the configuration file.

Parameters:

config_file_name

Returns:

Absolute path of the configuration file.

get_dict(key, default_value=None)

Get a dictionary value from the configuration by key.

Parameters:
  • key – The key to look up in the configuration.

  • default_value – The default value to return if the key is not found or if the value is not a dict.

Returns:

The dictionary value associated with the key, or the default value if the key is not found or not a dict.

get_list(key, default_value=None)

Get a list value from the configuration by key.

Parameters:
  • key – The key to look up in the configuration.

  • default_value – The default value to return if the key is not found or if the value is not a list.

Returns:

The list value associated with the key, or the default value if the key is not found or not a list.

get_string(key, default_value=None)

Get a string value from the configuration by key.

Parameters:
  • key – The key to look up in the configuration.

  • default_value – The default value to return if the key is not found or if the value is not a string.

Returns:

The string value associated with the key, or the default value if the key is not found or not a string.

load(key, cls, default_value=None)

Load a configuration value and return an instance of the specified class.

Parameters:
  • key – The key to look up in the configuration.

  • cls – The class to instantiate with the configuration values.

  • default_value – The default value to return if the key is not found or if instantiation fails.

Returns:

An instance of the specified class initialized.

load_and_process_yaml(file_path)

Load a YAML file and process its content to resolve environment variable placeholders.

Parameters:

file_path – Path to the YAML file.

Returns:

Processed YAML content as a Python object.

process_object(obj)

Recursively process a Python object (list or dict) to resolve environment variable placeholders.

Parameters:

obj – The Python object to process.

Returns:

The processed object with placeholders resolved.

resolve_placeholders(value)

Resolve environment variable placeholders in a string.

Parameters:

value – The string containing placeholders.

Returns:

The string with placeholders resolved, or the original value if not a string.