io_tools.postproc_toml_dict
- io_tools.postproc_toml_dict._apply_default_values(cfg_inp: Dict[str, Dict[str, Any] | List[Dict[str, Any]]], cfg_def: Dict[str, Dict[str, Any] | List[Dict[str, Any]]], match_key: Dict[str, str]) Dict[str, Dict[str, Any] | List[Dict[str, Any]]] [source]
Fills in the default values where the input config does not specify a value.
- io_tools.postproc_toml_dict._replace_none(d: Dict[str, Any]) None [source]
Replace ‘<none>’ by None in a ParamDict. This also works inside lists.
- io_tools.postproc_toml_dict._resolve_references(d: Dict[str, Any], section_name: str, output: Dict[str, Dict[str, Any] | List[Dict[str, Any]]]) None [source]
Resolve all references of type “<section.key>” in a ParamDict.
- io_tools.postproc_toml_dict._verify_all_mandatory_fields_present(d: Dict[str, Any], section_name: str) None [source]
Verifies that all fields with “<no default>” have been replaced after reading in the config.
- io_tools.postproc_toml_dict._verify_dict_is_full_config(d: Dict[str, Any]) None [source]
Checks that dict is of type FullConfig.
- io_tools.postproc_toml_dict._verify_dict_is_param_dict(d: Any) None [source]
Checks that the input is of type ParamDict.
- io_tools.postproc_toml_dict._verify_restrictions_on_default_and_config(cfg_inp: Dict[str, Any], cfg_def: Dict[str, Any], match_key: Dict[str, str]) None [source]
Checks that the restrictions described in the docstring of merge_config_with_default are met.
- io_tools.postproc_toml_dict.merge_config_with_default(cfg_inp, cfg_def, match_key={})[source]
Merge a TOML config dict with a default TOML dict. The default dict dictates the structure of the input:
Only sections and keys in the default are allowed in the input
All sections listed in match_key must be lists of dicts in the default and can be lists of dicts or dicts in the config
The dicts allows for the following extensions:
Mandatory inputs for all calculations indicated by “<no default>”
None indicated by “<none>”. Also works inside lists
References within the dictionary indicated by “<section.key>”
- Parameters:
- cfg_inpdict
The input config dict
- cfg_defdict
The default config dict
- match_keydict, optional
A dictionary that contains section/key pairs to map entries in listed sections between the input and default config.
- Returns:
- dict
The merged config dict