dgs.utils.config.get_sub_config¶
- dgs.utils.config.get_sub_config(config: dict[str, any], path: list[str]) dict[str, any] | any [source]¶
Given a full configuration file in nested dict style, return the given subtree by using the items in path as node keys.
- Parameters:
config – Configuration file as nested dict.
path – Path of a subtree within this config dictionary
Examples
With a given configuration, this would look something like this.
>>> cfg: Config = { "bar": { "x": 1, "y": 2, "deeper": { "ore": "iron", "pickaxe": {"iron": 10, "diamond": 100.0}, }}} >>> print(get_sub_config(cfg, ["bar", "deeper", "pickaxe"])) {"iron": 10, "diamond": 100.0} >>> print(get_sub_config(cfg, ["bar", "x"])) 1
- Returns:
Either a sub configuration, which is an excerpt of the original configuration, or a single value.