Skip to content

Commit 0d00cf6

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

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/fosslight_scanner/_run_compare.py

Lines changed: 12 additions & 10 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)]

0 commit comments

Comments
 (0)