assets_guardian.core.config.loaderο
Functions
|
Browses a dictionary using nested keys (e.g., 'a:b:c'). |
|
Retrieves a configuration value (Env > YAML > Default). |
|
Generates the environment variable name corresponding to the key. |
Returns the project version. |
|
|
Extracts user profiles (Email -> list[Profile]) from the configured JSON file. |
|
Loads a JSON file. |
|
Extracts the unique list of profiles from the configured file. |
|
Loads a YAML configuration file. |
|
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.