Skip to content

Commit 6ed9bda

Browse files
committed
Fix not to print version N/A for comparison result
Signed-off-by: Jiyeong Seok <[email protected]>
1 parent fd0a44a commit 6ed9bda

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/fosslight_scanner/_run_compare.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,23 @@ def write_result_json_yaml(output_file, compared_result, file_ext):
3636

3737
def parse_result_for_table(oi, status):
3838
compared_row = []
39-
if status == ADD:
40-
oss_after = f"{oi['name']} ({oi['version']})"
41-
license_after = f"{', '.join(oi['license'])}"
42-
compared_row = [status, '', '', oss_after, license_after]
43-
elif status == DELETE:
44-
oss_before = f"{oi['name']} ({oi['version']})"
45-
license_before = f"{', '.join(oi['license'])}"
46-
compared_row = [status, oss_before, license_before, '', '']
39+
if status == ADD or status == DELETE:
40+
oi_ver = '' if oi['version'] == '' else f"({oi['version']})"
41+
oss_info = f"{oi['name']}{oi_ver}"
42+
license_info = f"{', '.join(oi['license'])}"
43+
if status == ADD:
44+
compared_row = [status, '', '', oss_info, license_info]
45+
elif status == DELETE:
46+
compared_row = [status, oss_info, license_info, '', '']
4747
elif status == CHANGE:
4848
oss_before, oss_after, license_before, license_after = [], [], [], []
4949
for prev_i in oi['prev']:
50-
oss_before.append(f"{oi['name']} ({prev_i['version']})")
50+
prev_i_ver = '' if prev_i['version'] == '' else f"({prev_i['version']})"
51+
oss_before.append(f"{oi['name']}{prev_i_ver}")
5152
license_before.append(f"{', '.join(prev_i['license'])}")
5253
for now_i in oi['now']:
53-
oss_after.append(f"{oi['name']} ({now_i['version']})")
54+
now_i_ver = '' if now_i['version'] == '' else f"({now_i['version']})"
55+
oss_after.append(f"{oi['name']}{now_i_ver}")
5456
license_after.append(f"{', '.join(now_i['license'])}")
5557
compared_row = [status, ' / '.join(oss_before), ' / '.join(license_before),
5658
' / '.join(oss_after), ' / '.join(license_after)]
@@ -105,13 +107,16 @@ def write_result_html(output_file, compared_result, before_yaml, after_yaml):
105107
tr.insert(i, td)
106108
table_html.insert(row, tr)
107109
row += 1
108-
if row >= MIN_ROW_NUM + 2:
109-
p = f.new_tag('p')
110-
p.string = "(!) There are so many different oss.\
111-
See the attached excel file for the full comparison result."
112-
p.attrs = {"style": "font-weight:bold; color:red; font-size:15px"}
113-
table_html.insert_before(p)
114-
break
110+
if row >= MIN_ROW_NUM + 2:
111+
p = f.new_tag('p')
112+
p.string = "(!) There are so many different oss.\
113+
See the attached excel file for the full comparison result."
114+
p.attrs = {"style": "font-weight:bold; color:red; font-size:15px"}
115+
table_html.insert_before(p)
116+
break
117+
else:
118+
continue
119+
break
115120

116121
if row == 2:
117122
tr = f.new_tag('tr')

0 commit comments

Comments
 (0)