Skip to content

Commit f52aa50

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

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
@@ -282,15 +282,17 @@ def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_do
282282
new_result_item.download_location = download_location
283283
scancode_result.append(new_result_item)
284284

285-
for item in scancode_result:
285+
for i in range(len(scancode_result) - 1, -1, -1):
286+
item = scancode_result[i]
286287
item_path = item.source_name_or_path
287-
if any(
288-
excluded in item_path and
289-
(item_path == excluded or item_path.startswith(f"{excluded}{os.sep}"))
288+
289+
if not any(
290+
item_path == excluded or item_path.startswith(f"{excluded}{os.sep}")
290291
for excluded in path_to_exclude
291292
):
292-
continue
293-
item.set_oss_item()
293+
item.set_oss_item()
294+
else:
295+
del scancode_result[i]
294296

295297
return scancode_result
296298

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)