Inheritance

yahp.inheritance.load_yaml_with_inheritance(yaml_path: str) Dict[str, JSON][source]

Loads a YAML file with inheritance.

Inheritance allows one YAML file to include data from another yaml file.

Example:

Given two yaml files – foo.yaml and bar.yaml:

foo.yaml:

foo:
    inherits:
        - bar.yaml

bar.yaml:

foo:
    param: val
    other:
        whatever: 12
tomatoes: 11

Then this function will return one dictionary with:

{
    "foo": {
        "param": "val",
        "other: {
            "whatever": 12
        }
    },
}
Parameters

yaml_path (str) – The filepath to the yaml to load.

Returns

The flattened YAML, with inheritance stripped.

Return type

JSON Dictionary

yahp.inheritance.preprocess_yaml_with_inheritance(yaml_path: str, output_yaml_path: str) None[source]

Helper function to preprocess yaml with inheritance and dump it to another file

See load_yaml_with_inheritance() for how inheritance works.

Parameters
  • yaml_path (str) – Filepath to load

  • output_yaml_path (str) – Filepath to write flattened yaml to.