aboutsummaryrefslogtreecommitdiffstats
path: root/hdv/redfish/yaml_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'hdv/redfish/yaml_utils.py')
-rw-r--r--hdv/redfish/yaml_utils.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/hdv/redfish/yaml_utils.py b/hdv/redfish/yaml_utils.py
new file mode 100644
index 0000000..438c150
--- /dev/null
+++ b/hdv/redfish/yaml_utils.py
@@ -0,0 +1,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"))