|
8 | 8 | import platform |
9 | 9 | import warnings |
10 | 10 | import logging |
| 11 | +import glob |
11 | 12 | from datetime import datetime |
12 | 13 | import fosslight_util.constant as constant |
13 | 14 | from fosslight_util.set_log import init_log |
@@ -285,14 +286,19 @@ def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_do |
285 | 286 | for i in range(len(scancode_result) - 1, -1, -1): |
286 | 287 | item = scancode_result[i] |
287 | 288 | item_path = item.source_name_or_path |
288 | | - |
289 | | - if not any( |
290 | | - item_path == excluded or item_path.startswith(f"{excluded}{os.sep}") |
291 | | - for excluded in path_to_exclude |
| 289 | + |
| 290 | + # normalize for windows |
| 291 | + normalized_patterns = [os.path.normpath(pattern).replace("\\", "/") for pattern in path_to_exclude] |
| 292 | + |
| 293 | + # remove from the scanned list if path is matched with exclude patterns |
| 294 | + if any( |
| 295 | + glob.fnmatch.fnmatch(item_path, f"{pattern}") or # 단독 파일 이름 체크 |
| 296 | + glob.fnmatch.fnmatch(item_path, f"**/{pattern}") # 경로 포함 체크 |
| 297 | + for pattern in normalized_patterns |
292 | 298 | ): |
293 | | - item.set_oss_item() |
294 | | - else: |
295 | 299 | del scancode_result[i] |
| 300 | + else: |
| 301 | + item.set_oss_item() |
296 | 302 |
|
297 | 303 | return scancode_result |
298 | 304 |
|
@@ -345,7 +351,7 @@ def run_scanners( |
345 | 351 | success, result_log[RESULT_KEY], scancode_result, license_list = run_scan(path_to_scan, output_file_name, |
346 | 352 | write_json_file, num_cores, True, |
347 | 353 | print_matched_text, formats, called_by_cli, |
348 | | - time_out, correct_mode, correct_filepath) |
| 354 | + time_out, correct_mode, correct_filepath, path_to_exclude) |
349 | 355 | if selected_scanner == 'scanoss' or selected_scanner == 'all' or selected_scanner == '': |
350 | 356 | scanoss_result = run_scanoss_py(path_to_scan, output_file_name, formats, True, write_json_file, num_cores, |
351 | 357 | path_to_exclude) |
|
0 commit comments