TestCrush Configuration¶
The config.py
module contains configuration parsing and sanitization functions for testcrush.
The expected configuration format is TOML. Detailed information about the TOML configuration files
can be found here.
TOML Parsing Utilities¶
- config.parse_a0_configuration(config_file: Path) tuple[str, list, dict] [source]¶
Parses the TOML configuration file of A0 and returns the A0 constructor args.
- Parameters:
config_file (pathlib.Path) – The configuration file.
- Returns:
A triplet with the ISA file (str), a list of the assembly sources (strs), and a dictionary with all the a0 settings.
- Return type:
tuple
- config.replace_toml_placeholders(item: Any, defines: dict[str, str]) dict[str, Any] [source]¶
Recursively replaces any string or string within list and dicts with user defined values.
- Parameters:
item (Any) – A string, list or dict to act upon and replace any matching %…% pattern with defines.
defines (dict[str, str]) – A dictionary whose keys will be searched on item to be replaced with the associated values.
- Returns:
The parsed TOML dict where all substitutions have been performed on the user-defined keys.
- Return type:
dict[str, Any]
- config.replace_toml_regex(item: Any, substitute: bool = False) dict[str, Any] [source]¶
Recursively substitues all values corresponding to keys which include ‘regex’ with
re.Patterns
.All generated patterns have a
re.DOTALL
flag set.- Parameters:
item (Any) – A string, list or dict to act upon and replace any regex string with re.Pattern.
substitute (bool, optional) – Flag to allow substitution of value. Defaults to False.
- Returns:
The parsed TOML dict where all substitutions have been performed on the regex strings.
- Return type:
dict[str, Any]
- config.sanitize_a0_configuration(config_file: Path) None [source]¶
Checks whether all key-value pairs have been defined in the TOML file.
- Parameters:
config_file (pathlib.Path) – The TOML configuration file.
- Raises:
TomlDecodeError – if loading the file fails.
KeyError – if a key is missing from the TOML file.