Skip to content

Commit 693b8c9

Browse files
authored
Merge pull request #136 from fosslight/json
Fix json output error when not analyzing source
2 parents f298e28 + ab827be commit 693b8c9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/fosslight_scanner/common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ def create_scancodejson(all_scan_item_origin, ui_mode_report, src_path=""):
118118
all_scan_item = copy.deepcopy(all_scan_item_origin)
119119
if FOSSLIGHT_DEPENDENCY in all_scan_item.file_items:
120120
del all_scan_item.file_items[FOSSLIGHT_DEPENDENCY]
121+
first_sheet = FOSSLIGHT_SOURCE
122+
if all_scan_item.file_items:
123+
first_sheet = next(iter(all_scan_item.file_items))
121124
if src_path:
122125
fileitems_without_oss = []
123126
for root, _, files in os.walk(src_path):
@@ -127,7 +130,6 @@ def create_scancodejson(all_scan_item_origin, ui_mode_report, src_path=""):
127130
included = False
128131
item_path = os.path.join(root, file)
129132
item_path = item_path.replace(parent + os.path.sep, '', 1)
130-
131133
for file_items in all_scan_item.file_items.values():
132134
for file_item in file_items:
133135
if file_item.source_name_or_path:
@@ -138,7 +140,7 @@ def create_scancodejson(all_scan_item_origin, ui_mode_report, src_path=""):
138140
fi_without_oss.source_name_or_path = item_path
139141
fileitems_without_oss.append(fi_without_oss)
140142
if len(fileitems_without_oss) > 0:
141-
all_scan_item.file_items[FOSSLIGHT_SOURCE].extend(fileitems_without_oss)
143+
all_scan_item.file_items[first_sheet].extend(fileitems_without_oss)
142144
if root_dir:
143145
for file_items in all_scan_item.file_items.values():
144146
for fi in file_items:

0 commit comments

Comments
 (0)