summaryrefslogtreecommitdiffstats
path: root/tools/hdv/redfish/excel_2_yaml.py
diff options
context:
space:
mode:
authoropensource-tnbt <sridhar.rao@spirent.com>2020-10-30 15:48:23 +0530
committeropensource-tnbt <sridhar.rao@spirent.com>2020-10-30 15:50:29 +0530
commit0fd1dc39ee6f6bb7f2c35f84c3a2a39d9e63805f (patch)
treef58b5d9ca603d193476254d3d5b13e853985ad64 /tools/hdv/redfish/excel_2_yaml.py
parentdff7c66ee8e7ef0b8b14ad5776a1318b987d3eaa (diff)
CIRV-Cleanup: Remove HDV and SDV contents.
As CIRV-HDV and CIRV-SDV are active now, we do not need contents here. The docs folder has links to HDV and SDV. Signed-off-by: Sridhar K. N. Rao <sridhar.rao@spirent.com> Change-Id: I86ee90fb5e969e14d000d9a08d971b13a2c2740e
Diffstat (limited to 'tools/hdv/redfish/excel_2_yaml.py')
-rw-r--r--tools/hdv/redfish/excel_2_yaml.py62
1 files changed, 0 insertions, 62 deletions
diff --git a/tools/hdv/redfish/excel_2_yaml.py b/tools/hdv/redfish/excel_2_yaml.py
deleted file mode 100644
index 948ead3..0000000
--- a/tools/hdv/redfish/excel_2_yaml.py
+++ /dev/null
@@ -1,62 +0,0 @@
-##############################################################################
-# Copyright (c) 2020 China Mobile Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-'''
-excel 2 yaml tools
-convert excel config to yaml format config: depends.yaml and cases.yaml.
-'''
-import os
-import yaml
-from openpyxl.reader.excel import load_workbook
-# pylint: disable=E0611
-from log_utils import LOGGER
-
-
-def load_sheet(excel_file, sheet_index, start_col, end_col):
- '''
- load sheet
- '''
- if not os.path.exists(excel_file):
- LOGGER.error("excel file not existing")
- return None
- input_file = load_workbook(excel_file)
- input_ws = input_file[input_file.sheetnames[sheet_index]]
- cell_key = []
- rows_list = []
- for i in range(start_col, end_col):
- cell_key.append(input_ws.cell(row=1, column=i).value)
- row = 2
- while input_ws.cell(row=row, column=1).value:
- cell_value = []
- for i in range(start_col, end_col):
- value = input_ws.cell(row=row, column=i).value
- if isinstance(value, str):
- value = value.strip().replace('\n', '')
- cell_value.append(value)
- cell_dict = dict(zip(cell_key, cell_value))
- row += 1
- rows_list.append(cell_dict)
-
- LOGGER.info(rows_list)
- return rows_list
-
-
-def create_yaml(id_dict, yaml_file):
- '''
- create yaml
- '''
- with open(yaml_file, 'w') as y_file:
- yaml.dump(id_dict, y_file, explicit_start=True)
-
-
-DEPEND_FILE_NAME = "./conf/depends.yaml"
-LOGGER.info("create %s ", DEPEND_FILE_NAME)
-create_yaml(load_sheet("./conf/cases.xlsx", 1, 1, 5), DEPEND_FILE_NAME)
-
-CASE_FILE_NAME = "./conf/cases.yaml"
-create_yaml(load_sheet("./conf/cases.xlsx", 0, 1, 10), CASE_FILE_NAME)