utilities#
import compwa_policy.utilities
Collection of helper functions that are shared by all sub-hooks.
- append_safe(expected_line: str, path: Path) bool [source]#
Add a line to a file if it is not already present.
- get_nested_dict(data: dict, keys: list[str]) dict [source]#
Get a nested dictionary from a list of keys, create it if it doesn’t exist.
>>> data = {} >>> sub_dict = get_nested_dict(data, keys=["a", "b"]) >>> sub_dict["c"] = 1 >>> data {'a': {'b': {'c': 1}}}
Submodules and Subpackages