summaryrefslogtreecommitdiffstats
path: root/tools/hdv/redfish/yaml_utils.py
blob: 438c1509ba8e9f0d3e52f94ea478a81a1d529784 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'''
@author: cmcc
'''
import os
import yaml
# pylint: disable=E0611
from log_utils import LOGGER


def read_yaml(file):
    '''read a yaml file
    '''
    if not os.path.exists(file):
        LOGGER.info("%s not found", file)
        return None
    return yaml.load(open(file, "r"))


def write_yaml(file, dict_data):
    '''write a yaml file
    '''
    yaml.safe_dump(dict_data, open(file, "w"), explicit_start=True)


print(read_yaml("./conf/depends.yaml"))
print(read_yaml("./conf/cases.yaml"))

write_yaml("./conf/report.yaml", read_yaml("./conf/cases.yaml"))