1212import fosslight_util .constant as constant
1313from fosslight_util .set_log import init_log
1414from fosslight_util .timer_thread import TimerThread
15+ from fosslight_util .exclude import excluding_files
1516from ._help import print_version , print_help_msg_source_scanner
1617from ._license_matched import get_license_list_to_print
1718from fosslight_util .output_format import check_output_formats_v2 , write_output_file
@@ -147,7 +148,7 @@ def create_report_file(
147148 output_path : str = "" , output_files : list = [],
148149 output_extensions : list = [], correct_mode : bool = True ,
149150 correct_filepath : str = "" , path_to_scan : str = "" , path_to_exclude : list = [],
150- formats : list = []
151+ formats : list = [], excluded_file_list : list = []
151152) -> 'ScannerItem' :
152153 """
153154 Create report files for given scanned result.
@@ -219,6 +220,12 @@ def create_report_file(
219220
220221 if merged_result :
221222 sheet_list = {}
223+ # Remove results that are in excluding file list
224+ for i in range (len (merged_result ) - 1 , - 1 , - 1 ): # Iterate from last to first
225+ item_path = merged_result [i ].source_name_or_path # Assuming SourceItem has 'file_path' attribute
226+ if item_path in excluded_file_list :
227+ del merged_result [i ] # Delete matching item
228+
222229 scan_item .append_file_items (merged_result , PKG_NAME )
223230
224231 if selected_scanner == 'scanoss' :
@@ -262,6 +269,7 @@ def create_report_file(
262269
263270
264271def merge_results (scancode_result : list = [], scanoss_result : list = [], spdx_downloads : dict = {}) -> list :
272+
265273 """
266274 Merge scanner results and spdx parsing result.
267275 :param scancode_result: list of scancode results in SourceItem.
@@ -329,6 +337,7 @@ def run_scanners(
329337
330338 logger , result_log = init_log (os .path .join (output_path , f"fosslight_log_src_{ start_time } .txt" ),
331339 True , logging .INFO , logging .DEBUG , PKG_NAME , path_to_scan , path_to_exclude )
340+ excluded_file_list = excluding_files (path_to_exclude , path_to_scan )
332341
333342 if '.xlsx' not in output_extensions and print_matched_text :
334343 logger .warning ("-m option is only available for excel." )
@@ -348,7 +357,7 @@ def run_scanners(
348357 merged_result = merge_results (scancode_result , scanoss_result , spdx_downloads )
349358 scan_item = create_report_file (start_time , merged_result , license_list , scanoss_result , selected_scanner ,
350359 print_matched_text , output_path , output_files , output_extensions , correct_mode ,
351- correct_filepath , path_to_scan , path_to_exclude , formats )
360+ correct_filepath , path_to_scan , path_to_exclude , formats , excluded_file_list )
352361 else :
353362 print_help_msg_source_scanner ()
354363 result_log [RESULT_KEY ] = "Unsupported scanner"
0 commit comments