Skip to content

Commit 31bcd0a

Browse files
committed
Comply with flake8 in tox
1 parent d27d515 commit 31bcd0a

File tree

3 files changed

+33
-36
lines changed

3 files changed

+33
-36
lines changed

src/fosslight_android/_common.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,47 +125,47 @@ def get_print_items(self):
125125
source_path = self.source_code_path
126126
item_license = self.license
127127

128-
need_check, comment = get_comment(self.comment, item_license, oss_name, self.notice, source_path)
129-
print_items_txt.append(
130-
self.bin_name + '\t' + source_path + '\t' + self.notice +
131-
'\t' + oss_name + '\t' + self.oss_version + '\t' +
132-
self.license + '\t' + need_check + '\t' + comment +
133-
'\t' + self.tlsh + '\t' + self.checksum)
128+
empty_columns, license_to_notice = check_empty_column(item_license, oss_name, source_path)
129+
comment = get_comment(self.comment, license_to_notice, self.notice, empty_columns)
130+
if comment != "":
131+
need_check = "O"
132+
print_items_txt.append(f"{self.bin_name}\t{source_path}\t{self.notice}\t"
133+
f"{oss_name}\t{self.oss_version}\t{self.license}\t{need_check}\t{comment}\t{self.tlsh}\t{self.checksum}")
134134
repo_link = self.download_location if self.is_new_bin else ""
135135
print_items_excel.append([self.bin_name, source_path, self.notice, oss_name,
136136
self.oss_version, self.license, repo_link, repo_link, '', '', '', comment, need_check])
137137

138138
if self.additional_oss_items is not None:
139139
for item in self.additional_oss_items:
140-
print_items_txt.append(
141-
self.bin_name + '\t' + source_path + '\t' + self.notice +
142-
'\t' + item + '\t' + need_check + '\t' + comment +
143-
'\t' + self.tlsh + '\t' + self.checksum)
140+
print_items_txt.append(f"{self.bin_name}\t{source_path}\t{self.notice}\t{item}"
141+
f"\t{need_check}\t{comment}\t{self.tlsh}\t{self.checksum}")
144142
excel_item = [self.bin_name, source_path, self.notice]
145143
excel_item.extend(item.split('\t'))
146144
excel_item.extend(['', '', '', '', '', comment, need_check])
147145
print_items_excel.append(excel_item)
148146
return print_items_txt, print_items_excel
149147

150148

151-
def get_comment(default_comment, license, oss_name, notice_value, directory):
152-
need_check = ""
153-
comment = ""
149+
def check_empty_column(license, oss_name, directory):
154150
empty_columns = []
155151
license_to_notice = True
156152

157-
if license == CONST_NULL:
158-
empty_columns.append('License')
159-
else:
153+
if license != CONST_NULL:
160154
for license_item in license.split(','):
161155
if license_item in skip_license:
162156
license_to_notice = False
163157
break
164-
158+
else:
159+
empty_columns.append('License')
165160
if oss_name == CONST_NULL and license_to_notice:
166161
empty_columns.append('OSS Name')
167162
if directory == CONST_NULL:
168163
empty_columns.append('Source Code Path')
164+
return empty_columns, license_to_notice
165+
166+
167+
def get_comment(default_comment, license_to_notice, notice_value, empty_columns):
168+
comment = ""
169169

170170
if empty_columns is not None and len(empty_columns) > 0:
171171
comment = "Fill in " + ",".join(empty_columns) + "."
@@ -180,12 +180,9 @@ def get_comment(default_comment, license, oss_name, notice_value, directory):
180180
comment += "/"
181181
comment += "Add NOTICE to proper path."
182182

183-
if comment != "":
184-
need_check = "O"
185-
186183
comment = default_comment + comment # Paste Auto ID comment in front.
187184

188-
return need_check, comment
185+
return comment
189186

190187

191188
def set_value_switch(bin, key, value):

src/fosslight_android/android_binary_analysis.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,19 @@ def find_binaries_from_out_dir():
243243
obj_static_lib = os.path.join(build_out_path, "obj/STATIC_LIBRARIES")
244244
font_path = os.path.join(build_out_path, "system/fonts")
245245
cmd_list = [
246-
"find " + system_path + " -type f -exec file \"{}\" \\; | " +
247-
"egrep \"ELF\\ |ARM,|\\.jar|\\.apk\" | grep -v \"\\.o:\" | " +
246+
"find " + system_path + " -type f -exec file \"{}\" \\; | "
247+
"egrep \"ELF\\ |ARM,|\\.jar|\\.apk\" | grep -v \"\\.o:\" | "
248248
"grep -v \"\\.odex:\" | awk -F\":\" \'{print $1}\'",
249-
"find " + root_path + " -type f -exec file \"{}\" \\; | " +
249+
"find " + root_path + " -type f -exec file \"{}\" \\; | "
250250
"egrep \"ELF\\ |ARM,|\\.jar|\\.apk\" | grep -v \"\\.o:\" | awk -F\":\" \'{print $1}\' ",
251-
"find " + build_out_path + " -maxdepth 1 -type f -exec file \"{}\" \\; | grep data$ |" +
251+
"find " + build_out_path + " -maxdepth 1 -type f -exec file \"{}\" \\; | grep data$ |"
252252
" grep -v .img | awk -F\":\" \'{print $1}\' ",
253253
"find " + obj_static_lib + " -type f -exec file \"{}\" \\; | egrep \"ar archive\" | awk -F\":\" \'{print $1}\' ",
254-
"find " + build_out_path + " ! \\( \\( -type d -path " + system_path +
255-
" -o -path " + root_path + " -o -path \'" + build_out_path +
256-
"/obj*\' -o -path " + build_out_path + "/symbols -o -path \'" +
257-
build_out_path + "/factory_*\' -o -path " + build_out_path +
258-
"/dex_bootjars \\) -prune \\) -type f -exec file \"{}\" \\; | egrep \"ELF\\ |ARM,|\\.jar|\\.apk\" | " +
254+
f"find {build_out_path} ! \\( \\( -type d -path {system_path}"
255+
f" -o -path {root_path} -o -path \'{build_out_path}"
256+
f"/obj*\' -o -path {build_out_path}/symbols -o -path \'"
257+
f"{build_out_path}/factory_*\' -o -path {build_out_path}"
258+
"/dex_bootjars \\) -prune \\) -type f -exec file \"{}\" \\; | egrep \"ELF\\ |ARM,|\\.jar|\\.apk\" | "
259259
"grep -v \"\\.o:\" | grep -v \"\\.odex:\" | awk -F\":\" \'{print $1}\' ",
260260
"find " + font_path + " -type f -exec file \"{}\" \\; | egrep \"font\" | awk -F\":\" \'{print $1}\'"
261261
]
@@ -419,7 +419,7 @@ def filter_non_path_bin(FIND_DIRECTORY_MODE):
419419
pass
420420

421421
if FIND_DIRECTORY_MODE:
422-
get_path_by_using_find(need_to_find, build_out_path, "FIND_RESULT_OF_BINARIES"+now+".txt", python_script_dir)
422+
get_path_by_using_find(need_to_find, build_out_path, f"FIND_RESULT_OF_BINARIES_{now}.txt", python_script_dir)
423423

424424

425425
def search_binaries_by_bin_name_and_checksum(bin_name_to_search, bin_checksum_to_search):
@@ -475,7 +475,7 @@ def get_repositories_name_from_web():
475475
pkg_list = soup.findAll("span", "RepoList-itemName")
476476

477477
for pkg in pkg_list:
478-
repositories[pkg.text] = url+pkg.text
478+
repositories[pkg.text] = url + pkg.text
479479
except Exception:
480480
pass
481481

@@ -606,7 +606,7 @@ def get_checksum_tlsh(bin_info_list, return_bin_list):
606606

607607
def remove_duplicated_binaries_by_checking_checksum(remove_list_file):
608608
global final_bin_info
609-
result_file_name = "REMOVED_BIN_BY_DUPLICATION_"+now+".txt"
609+
result_file_name = f"REMOVED_BIN_BY_DUPLICATION_{now}.txt"
610610
str_bin_removed = ""
611611
filtered_binaries = []
612612
checked_file_name = {}
@@ -633,7 +633,7 @@ def remove_duplicated_binaries_by_checking_checksum(remove_list_file):
633633
cnt += 1
634634
print_removed_str, print_removed_array = item.get_print_items()
635635
for row_removed in print_removed_str:
636-
str_bin_removed += row_removed+'\n'
636+
str_bin_removed += f"{row_removed}\n"
637637
continue
638638
elif search_key not in checked_file_name:
639639
find_result, same_name_binaries = search_binaries_by_bin_name_and_checksum(bin_name_with_path,
@@ -677,7 +677,7 @@ def remove_duplicated_binaries_by_checking_checksum(remove_list_file):
677677
if bin_same_name.bin_name != final_added.bin_name:
678678
print_removed_str, print_removed_array = bin_same_name.get_print_items()
679679
for row_removed in print_removed_str:
680-
str_bin_removed += row_removed+'\n'
680+
str_bin_removed += f"{row_removed}\n"
681681
else: # Don't have any duplicated binaries
682682
filtered_binaries.append(item)
683683
if remove_list_file != "":

src/fosslight_android/check_notice_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def create_license_txt_files(file_list, result_file_path):
293293
os.makedirs(dir)
294294
write_txt_file(file_name, file['license_txt'], "")
295295
except Exception as error:
296-
logger.warn("Error: Cannot create a notice file.:"+str(error))
296+
logger.warn(f"Error: Cannot create a notice file.:{error}")
297297

298298

299299
def parsing_notice_html_for_license_text(notice_file_content):

0 commit comments

Comments
 (0)