Skip to content

Commit af1aef3

Browse files
Remove excluded items from scancode_result
Signed-off-by: Wonjae Park <[email protected]>
1 parent 6ffe719 commit af1aef3

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/fosslight_source/cli.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,17 @@ def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_do
285285
new_result_item.download_location = download_location
286286
scancode_result.append(new_result_item)
287287

288-
for item in scancode_result:
288+
for i in range(len(scancode_result) - 1, -1, -1):
289+
item = scancode_result[i]
289290
item_path = item.source_name_or_path
290-
if any(
291-
excluded in item_path and
292-
(item_path == excluded or item_path.startswith(f"{excluded}{os.sep}"))
291+
292+
if not any(
293+
item_path == excluded or item_path.startswith(f"{excluded}{os.sep}")
293294
for excluded in path_to_exclude
294295
):
295-
continue
296-
item.set_oss_item()
296+
item.set_oss_item()
297+
else:
298+
del scancode_result[i]
297299

298300
return scancode_result
299301

src/fosslight_source/run_scanoss.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list =
110110

111111
try:
112112
if write_json_file:
113+
destination_file = os.path.join(output_path, SCANOSS_RESULT_FILE)
114+
if os.path.exists(destination_file):
115+
os.remove(destination_file)
113116
shutil.move(SCANOSS_RESULT_FILE, output_path)
114117
else:
115118
os.remove(output_json_file)

0 commit comments

Comments
 (0)