3.1.5.1.1. waf_tools.battery_config_validate_utils.extract_defines
- waf_tools.battery_config_validate_utils.extract_defines(cfg: dict, file_name: str, error_cls: type[RuntimeError]) dict[str, object]
Extract define values for a specific generated file.
Searches the
fileslist in the configuration dictionary for an entry whosefile_namematches the requested target file. Returns the containeddefinesas a flat dictionary mapping define names to their raw values.The expected JSON structure is:
{ "files": [ { "file_name": "<file_name>", "defines": [ { "name": "<define_name>", "value": <value>, "value_type": "<value_type>" }, ... ], }, ... ] }
- Parameters:
cfg – Parsed JSON content of a foxBMS configuration file (e.g.
battery_cell_cfg.json), expected to contain afileslist.file_name – The target file name to look up (e.g.
battery_cell_cfg.h).error_cls – The exception class to raise if the file entry is not found.
- Returns:
A dictionary mapping define names to their raw values.
- Raises:
RuntimeError – If no entry with the given
file_nameexists in the configuration’sfileslist. The concrete exception type is determined byerror_cls.KeyError – If a
filesentry has nofile_nameordefineskey, or a define entry has nonameorvaluekey.