Skip to content

Commit e266059

Browse files
Fix exclude error (#201)
* Fix exclude error Signed-off-by: Wonjae Park <[email protected]> * move excluding code in to create_report_file Signed-off-by: Wonjae Park <[email protected]> * fix set fl_util requirement 2.1.9 Signed-off-by: Wonjae Park <[email protected]> * fix tox error Signed-off-by: Wonjae Park <[email protected]> * change FL Util minimum version Signed-off-by: Wonjae Park <[email protected]> --------- Signed-off-by: Wonjae Park <[email protected]>
1 parent 762ddc6 commit e266059

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pyparsing
22
scanoss<=1.14.0
33
XlsxWriter
4-
fosslight_util>=2.1.6
4+
fosslight_util>=2.1.10
55
PyYAML
66
wheel>=0.38.1
77
intbitset

src/fosslight_source/cli.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import fosslight_util.constant as constant
1313
from fosslight_util.set_log import init_log
1414
from fosslight_util.timer_thread import TimerThread
15+
from fosslight_util.exclude import excluding_files
1516
from ._help import print_version, print_help_msg_source_scanner
1617
from ._license_matched import get_license_list_to_print
1718
from 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

264271
def 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

Comments
 (0)