88from fosslight_util .constant import LOGGER_NAME
99from fosslight_util .parsing_yaml import parsing_yml
1010from fosslight_util .output_format import write_output_file
11+ from fosslight_util .oss_item import ScannerItem
12+ from fosslight_prechecker ._constant import PKG_NAME
13+ from datetime import datetime
1114
1215logger = logging .getLogger (LOGGER_NAME )
1316
@@ -41,8 +44,9 @@ def convert_yml_to_excel(
4144 base_path : str
4245) -> None :
4346 sheet_list = {}
44- header = {}
45-
47+ start_time = datetime .now ().strftime ('%y%m%d_%H%M' )
48+ scan_item = ScannerItem (PKG_NAME , start_time )
49+ scan_item .set_cover_pathinfo (base_path , "" )
4650 for yaml_file in oss_yaml_files :
4751 try :
4852 if os .path .isfile (yaml_file ):
@@ -52,27 +56,30 @@ def convert_yml_to_excel(
5256
5357 if file_option_on :
5458 base_path = os .path .dirname (yaml_file )
55- oss_items , _ , _ = parsing_yml (yaml_file , base_path )
56- # if oss_items is abnormal(empty or invalid)
57- if not oss_items :
59+ file_items , _ , _ = parsing_yml (yaml_file , base_path )
60+ # if file_items is abnormal(empty or invalid)
61+ if not file_items :
5862 continue
5963
60- for item in oss_items :
61- items_to_print .extend (item .get_print_array ())
6264 if not base_path .endswith (f"{ os .sep } " ):
6365 base_path += f"{ os .sep } "
64- yaml_file = yaml_file .replace (base_path , '' )
65- yaml_file = yaml_file .replace (os .sep , '_' )
66- yaml_file_sheet = get_sheet_name (yaml_file , sheet_list )
66+ tmp_yaml_file = yaml_file .replace (base_path , '' )
67+ tmp_yaml_file = tmp_yaml_file .replace (os .sep , '_' )
68+ yaml_file_sheet = get_sheet_name (tmp_yaml_file , sheet_list )
6769
6870 if yaml_file_sheet :
69- sheet_list [yaml_file_sheet ] = items_to_print
70- header [yaml_file_sheet ] = HEADER_CONTENT
71+ scan_item .set_cover_comment (f"Converted file:{ yaml_file } " )
72+ row_items = [HEADER_CONTENT ]
73+ for file_item in file_items :
74+ row_items .extend (file_item .get_print_array ())
75+ sheet_list [yaml_file_sheet ] = row_items
76+
7177 except Exception as ex :
7278 logger .error (f"Read yaml file: { ex } " )
7379
7480 try :
75- success , msg , result_file = write_output_file (output_file , '.xlsx' , sheet_list , header )
81+ scan_item .external_sheets = sheet_list
82+ success , msg , result_file = write_output_file (output_file , '.xlsx' , scan_item )
7683 if success :
7784 if result_file :
7885 logger .warning (f"Output: { result_file } " )
0 commit comments