1919from .run_scancode import run_scan
2020from .run_scanoss import run_scanoss_py
2121
22+ SCANOSS_SHEET_NAME = 'SRC_FL_Source'
23+ SCANOSS_HEADER = {SCANOSS_SHEET_NAME : ['ID' , 'Source Name or Path' , 'OSS Name' ,
24+ 'OSS Version' , 'License' , 'Download Location' ,
25+ 'Homepage' , 'Copyright Text' , 'Exclude' ,
26+ 'Comment' , 'scanoss_matched_lines' ,
27+ 'scanoss_fileURL' , 'scanoss_vendor' ]}
28+
2229logger = logging .getLogger (constant .LOGGER_NAME )
2330warnings .filterwarnings ("ignore" , category = FutureWarning )
2431_PKG_NAME = "fosslight_source"
@@ -82,10 +89,11 @@ def main():
8289 else :
8390 print_help_msg_source ()
8491 sys .exit (1 )
85- create_report_file (start_time , scanned_result , license_list , print_matched_text , output_path , output_file , output_extension )
92+ create_report_file (start_time , scanned_result , license_list , selected_scanner , print_matched_text ,
93+ output_path , output_file , output_extension )
8694
8795
88- def create_report_file (start_time , scanned_result , license_list , need_license = False ,
96+ def create_report_file (start_time , scanned_result , license_list , selected_scanner , need_license = False ,
8997 output_path = "" , output_file = "" , output_extension = "" ):
9098 """
9199 Create report files for given scanned result.
@@ -95,6 +103,7 @@ def create_report_file(start_time, scanned_result, license_list, need_license=Fa
95103 :param license_list: matched text (only for scancode).
96104 :param need_license: if requested, output matched text (only for scancode).
97105 """
106+ extended_header = {}
98107 _result_log = {}
99108 sheet_list = {}
100109 _json_ext = ".json"
@@ -111,13 +120,19 @@ def create_report_file(start_time, scanned_result, license_list, need_license=Fa
111120 output_file = "FOSSLight-Report_" + start_time
112121
113122 scanned_result = sorted (scanned_result , key = lambda row : ('' .join (row .licenses )))
114- sheet_list ["SRC_FL_Source" ] = [scan_item .get_row_to_print () for scan_item in scanned_result ]
123+
124+ if selected_scanner == 'scancode' or output_extension == _json_ext :
125+ sheet_list [SCANOSS_SHEET_NAME ] = [scan_item .get_row_to_print () for scan_item in scanned_result ]
126+
127+ else :
128+ sheet_list [SCANOSS_SHEET_NAME ] = [scan_item .get_row_to_print_for_scanoss () for scan_item in scanned_result ]
129+ extended_header = SCANOSS_HEADER
115130
116131 if need_license :
117132 sheet_list ["matched_text" ] = get_license_list_to_print (license_list )
118133
119134 output_file_without_ext = os .path .join (output_path , output_file )
120- success_to_write , writing_msg = write_output_file (output_file_without_ext , output_extension , sheet_list )
135+ success_to_write , writing_msg = write_output_file (output_file_without_ext , output_extension , sheet_list , extended_header )
121136 logger .info ("Writing Output file(" + output_file + output_extension + "):"
122137 + str (success_to_write ) + " " + writing_msg )
123138 if success_to_write :
0 commit comments