assets_guardian.core.config.loader

Functions

browse_dict(data,Β key)

Browses a dictionary using nested keys (e.g., 'a:b:c').

get_config_value(key,Β data[,Β default,Β ...])

Retrieves a configuration value (Env > YAML > Default).

get_env_key_name(key)

Generates the environment variable name corresponding to the key.

get_project_version()

Returns the project version.

load_employees_profiles(employees_file_path)

Extracts user profiles (Email -> list[Profile]) from the configured JSON file.

load_json(file_path)

Loads a JSON file.

load_profiles(employees_file_path)

Extracts the unique list of profiles from the configured file.

load_yaml_config(config_file_path)

Loads a YAML configuration file.

to_str_list(value)

Normalizes a value into a list of strings.

assets_guardian.core.config.loader.browse_dict(data: dict[str, Any], key: str) Any[source]

Browses a dictionary using nested keys (e.g., β€˜a:b:c’).

Parameters:
  • data – Dictionary to search.

  • key – Configuration key with β€˜:’ delimiter.

Returns:

The value found or None if the key does not exist.

Return type:

Any

assets_guardian.core.config.loader.get_config_value(key: str, data: dict[str, Any], default: Any = None, env_name: str | None = None, env_override: bool = True) Any[source]

Retrieves a configuration value (Env > YAML > Default).

Parameters:
  • key – Configuration key (e.g., β€˜logging:level’).

  • data – YAML data dictionary.

  • default – Default value if not found.

  • env_name – Specific environment variable name (optional).

  • env_override – If True, prioritizes environment variables.

Returns:

The configuration value found.

Return type:

Any

Raises:

KeyError – If the key is missing and no default is provided.

assets_guardian.core.config.loader.get_env_key_name(key: str) str[source]

Generates the environment variable name corresponding to the key.

Parameters:

key – Configuration key (e.g., β€˜logging:level’).

Returns:

Environment-formatted variable name (e.g., β€˜LOGGING_LEVEL’).

Return type:

str

assets_guardian.core.config.loader.get_project_version() str[source]

Returns the project version.

assets_guardian.core.config.loader.load_employees_profiles(employees_file_path: str | None) dict[str, list[str]][source]

Extracts user profiles (Email -> list[Profile]) from the configured JSON file.

assets_guardian.core.config.loader.load_json(file_path: str) Any[source]

Loads a JSON file.

Parameters:

file_path – Path to the JSON file.

Returns:

The loaded JSON data.

Return type:

Any

Raises:
  • FileNotFoundError – If the file is not found.

  • ValueError – If the file is empty or not a valid JSON.

assets_guardian.core.config.loader.load_profiles(employees_file_path: str | None) list[str][source]

Extracts the unique list of profiles from the configured file.

assets_guardian.core.config.loader.load_yaml_config(config_file_path: str) dict[str, Any][source]

Loads a YAML configuration file.

Parameters:

config_file_path – Path to the YAML configuration file.

Returns:

A dictionary containing the configuration data.

Return type:

dict[str, Any]

Raises:
  • FileNotFoundError – If the configuration file is not found.

  • ValueError – If the file is empty.

  • TypeError – If the file does not contain a valid YAML dictionary.

assets_guardian.core.config.loader.to_str_list(value: Any) list[str][source]

Normalizes a value into a list of strings.