Skip to content

Commit

Permalink
Remove excluded items from scancode_result
Browse files Browse the repository at this point in the history
Signed-off-by: Wonjae Park <[email protected]>
  • Loading branch information
JustinWonjaePark committed Nov 13, 2024
1 parent a2f5335 commit f52aa50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/fosslight_source/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,17 @@ def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_do
new_result_item.download_location = download_location
scancode_result.append(new_result_item)

for item in scancode_result:
for i in range(len(scancode_result) - 1, -1, -1):
item = scancode_result[i]
item_path = item.source_name_or_path
if any(
excluded in item_path and
(item_path == excluded or item_path.startswith(f"{excluded}{os.sep}"))

if not any(
item_path == excluded or item_path.startswith(f"{excluded}{os.sep}")
for excluded in path_to_exclude
):
continue
item.set_oss_item()
item.set_oss_item()
else:
del scancode_result[i]

return scancode_result

Expand Down
3 changes: 3 additions & 0 deletions src/fosslight_source/run_scanoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list =

try:
if write_json_file:
destination_file = os.path.join(output_path, SCANOSS_RESULT_FILE)
if os.path.exists(destination_file):
os.remove(destination_file)
shutil.move(SCANOSS_RESULT_FILE, output_path)
else:
os.remove(output_json_file)
Expand Down

0 comments on commit f52aa50

Please sign in to comment.