Newer
Older
netbox-docker / startup_scripts / startup_script_utils / load_yaml.py
@Christian Mäder Christian Mäder on 9 Feb 2021 256 bytes Use black as formatter for python files
from pathlib import Path

from ruamel.yaml import YAML


def load_yaml(yaml_file: str):
    yf = Path(yaml_file)
    if not yf.is_file():
        return None
    with yf.open("r") as stream:
        yaml = YAML(typ="safe")
        return yaml.load(stream)