Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/fosslight_android/_binary_db_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def connect_to_lge_bin_db():
cur = ""
return conn, cur

def clean_decimal_string(input_str):
try:
num = float(input_str)
if num.is_integer():
return str(int(num))
return input_str
except ValueError:
return input_str

def get_oss_info_from_db(platform_version, bin_info_list, return_list):

Expand All @@ -66,6 +74,8 @@ def get_oss_info_from_db(platform_version, bin_info_list, return_list):
item.set_oss_version(row['ossversion'])
item.set_license(row['license'])
else: # In case more than 2 OSS is used for this bin.
tmp_oss_version = str(row['ossversion'])
row['ossversion'] = clean_decimal_string(tmp_oss_version)
item.set_additional_oss_items(row['ossname'] + '\t' + row['ossversion'] + '\t' + row['license'])
except Exception as error:
logger.warn(f"READ OSS :{error}")
Expand Down
12 changes: 12 additions & 0 deletions src/fosslight_android/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ def set_oss_name(self, value):

def set_oss_version(self, value):
self.oss_version = value

def clean_decimal_string(self, input_str):
try:
num = float(input_str)
if num.is_integer():
return str(int(num))
return input_str
except ValueError:
return input_str

def get_print_array(self, return_excel=True):
print_items_txt = []
Expand All @@ -112,6 +121,9 @@ def get_print_array(self, return_excel=True):
need_check = "O"
else:
need_check = ""
# Check if the decimal places are zero in the OSS version
tmp_oss_version = str(self.oss_version)
self.oss_version = self.clean_decimal_string(tmp_oss_version)
print_items_txt.append(f"{self.bin_name}\t{source_path}\t{self.notice}\t"
f"{oss_name}\t{self.oss_version}\t{self.license}\t{need_check}\t{comment}\t{self.tlsh}\t{self.checksum}")
repo_link = self.download_location if self.is_new_bin else ""
Expand Down
Loading