Documentation Index
Fetch the complete documentation index at: https://mintlify.com/alex-ber/AlexBerUtils/llms.txt
Use this file to discover all available pages before exploring further.
This module requires optional dependencies. Install them with:
init_app_conf module is the primary high-level API for application configuration. It merges command-line system arguments with hierarchical YAML configuration files using profile-based overrides.
conf
Namespace class holding configuration key constants used throughout the module.Constants
| Constant | Value | Description |
|---|---|---|
GENERAL_KEY | 'general' | Top-level key for general config section. |
PROFILES_KEY | 'profiles' | Key for the active profile list. |
WHITE_LIST_KEY | 'whiteListSysOverride' | Key controlling which keys may be overridden from system args. |
LIST_ENSURE_KEY | 'listEnsure' | Key listing flat keys that must be treated as comma-delimited lists. |
CONFIG_KEY | 'config' | Sub-key under general holding config metadata. |
FILE_LEY | 'file' | Key under general.config storing the resolved config file path. |
AppConfParser
Low-level parser class. In most cases you should use the module-level functions (parse_config, mask_value, etc.) rather than instantiating this class directly.
__init__
If
True, string values parsed from system args are automatically converted to their Python type (int, float, bool, etc.). Cannot be None.mask_value
Converts a string value to its appropriate Python type when implicit_convert=True, otherwise returns the value unchanged.
The string value to convert.
implicit_convert=True, or the original string when False.
to_convex_map
Converts a flat dot-notation dictionary into a nested OrderedDict.
Dictionary with flat dot-separated keys.
If provided, only keys that start with one of these prefixes are included in the output.
OrderedDict — nested dictionary.
merge_list_value_in_dicts
Merges a list value from a flat dictionary and a nested dictionary. The flat dictionary value takes precedence when non-empty.
Flat dictionary, typically from parsed system args. Cannot be
None.Nested dictionary, typically from a parsed YAML file. Cannot be
None.Top-level key in
d (e.g. 'general').Second-level key in
d[main_key] (e.g. 'profiles').flat_d if non-empty, otherwise from d[main_key][sub_key].
parse_config
Full parse cycle: reads system args, loads YAML files with profile layering, and returns the merged config dict.
Optional
argparse.ArgumentParser instance to extend with additional arguments before parsing.If provided, suppresses
sys.argv and uses this list as the argument source.OrderedDict — fully merged configuration.
mask_value
Module-level convenience wrapper aroundAppConfParser.mask_value.
The string value to convert.
If
None (default), uses the value set in initConfig() (default True). If True, attempts type conversion. If False, returns value as-is.to_convex_map
Module-level convenience wrapper aroundAppConfParser.to_convex_map.
Dictionary with flat dot-separated keys.
If provided, only entries whose keys start with one of these prefixes are included.
If
None (default), uses the value from initConfig(). If True, converts values to their Python types. If False, keeps values as strings.OrderedDict — nested dictionary.
merge_list_value_in_dicts
Module-level convenience wrapper aroundAppConfParser.merge_list_value_in_dicts.
Flat dictionary, usually from parsing system args.
Nested dictionary, usually from parsing a YAML file.
Top-level key in
d.Second-level key in
d[main_key].Applied only to
flat_d values. If None, uses the value from initConfig().flat_d when non-empty, otherwise from d[main_key][sub_key].
parse_config
The main function of the module. Parses command-line arguments, loads YAML configuration files with profile-based layering, and returns a single merged dictionary.How it works
- System args of the form
--key=valueare parsed. --general.config.file(default:config.yml) identifies the base YAML file.- The base YAML is loaded to discover profiles and the white-list override policy.
- Profile files (
config-dev.yml,config-local.yml, …) are layered on top. - System args override the merged YAML result.
Optional
argparse.ArgumentParser to extend before parsing.If provided, suppresses
sys.argv and uses this list as the argument source.If
None (default), uses the value from initConfig() (default True). Controls type conversion of system-arg values only; YAML values are always converted on a best-effort basis.OrderedDict — fully merged configuration dictionary.
initConfig
Optional initialization function. Call this once at startup (in the main thread) to customise the default parser class and its kwargs. The module calls it automatically with defaults on import.Class (or fully-qualified string name) to use as the default parser. Defaults to
AppConfParser.Default keyword arguments passed to
default_parser_cls.__init__(). Merged on top of {'implicit_convert': True}.None. This function is idempotent.