Skip to content

Commit

Permalink
Merge pull request #136 from fosslight/json
Browse files Browse the repository at this point in the history
Fix json output error when not analyzing source
  • Loading branch information
soimkim authored Jan 9, 2025
2 parents f298e28 + ab827be commit 693b8c9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/fosslight_scanner/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def create_scancodejson(all_scan_item_origin, ui_mode_report, src_path=""):
all_scan_item = copy.deepcopy(all_scan_item_origin)
if FOSSLIGHT_DEPENDENCY in all_scan_item.file_items:
del all_scan_item.file_items[FOSSLIGHT_DEPENDENCY]
first_sheet = FOSSLIGHT_SOURCE
if all_scan_item.file_items:
first_sheet = next(iter(all_scan_item.file_items))
if src_path:
fileitems_without_oss = []
for root, _, files in os.walk(src_path):
Expand All @@ -127,7 +130,6 @@ def create_scancodejson(all_scan_item_origin, ui_mode_report, src_path=""):
included = False
item_path = os.path.join(root, file)
item_path = item_path.replace(parent + os.path.sep, '', 1)

for file_items in all_scan_item.file_items.values():
for file_item in file_items:
if file_item.source_name_or_path:
Expand All @@ -138,7 +140,7 @@ def create_scancodejson(all_scan_item_origin, ui_mode_report, src_path=""):
fi_without_oss.source_name_or_path = item_path
fileitems_without_oss.append(fi_without_oss)
if len(fileitems_without_oss) > 0:
all_scan_item.file_items[FOSSLIGHT_SOURCE].extend(fileitems_without_oss)
all_scan_item.file_items[first_sheet].extend(fileitems_without_oss)
if root_dir:
for file_items in all_scan_item.file_items.values():
for fi in file_items:
Expand Down

0 comments on commit 693b8c9

Please sign in to comment.