Skip to content

Commit 40c1f8b

Browse files
committed
restore check_notice
Signed-off-by: Ethan Lee <[email protected]>
1 parent a06a78b commit 40c1f8b

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/fosslight_android/android_binary_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def find_notice_value(notice_zip_dest_file=""):
342342
notice_file_comment = "Notice file not found."
343343

344344
try:
345-
notice_file_list, notice_files = read_notice_file(os.path.abspath(build_out_notice_file_path))
345+
notice_file_list, notice_files = read_notice_file(os.path.abspath(build_out_notice_file_path), NOTICE_HTML_FILE_NAME)
346346
if notice_file_list:
347347
if notice_files:
348348
for notice_file in notice_files:

src/fosslight_android/check_notice_file.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,26 @@ def find_files_by_extension(path):
9696
return files
9797

9898

99-
def read_notice_file(notice_file_path):
100-
final_notice_file = {}
99+
def read_notice_file(notice_file_path, notice_html_file):
100+
final_notice_file = {}
101+
# NOTICE.html need to be skipped the errors related to decode
101102
encodings = ["latin-1", "utf-8", "utf-16"]
102-
notice_files = []
103+
notice_files = []
104+
105+
if notice_html_file != "":
106+
notice_files = notice_html_file.split(",")
107+
else:
108+
if os.path.isfile(notice_file_path):
109+
notice_files.append(notice_file_path)
110+
if notice_file_path.endswith(".html") or notice_file_path.endswith(".xml") or notice_file_path.endswith(".txt"):
111+
notice_file_path = os.path.dirname(notice_file_path)
112+
113+
if os.path.isdir(notice_file_path):
114+
additional_notice_files = find_files_by_extension(notice_file_path)
115+
if len(additional_notice_files) > 0:
116+
notice_files.extend(additional_notice_files)
117+
notice_files = list(set(notice_files))
103118

104-
if os.path.isfile(notice_file_path):
105-
notice_files.append(notice_file_path)
106-
if notice_file_path.endswith(".html") or notice_file_path.endswith(".xml") or notice_file_path.endswith(".txt"):
107-
notice_file_path = os.path.dirname(notice_file_path)
108-
109-
if os.path.isdir(notice_file_path):
110-
additional_notice_files = find_files_by_extension(notice_file_path)
111-
if len(additional_notice_files) > 0:
112-
notice_files.extend(additional_notice_files)
113-
notice_files = list(set(notice_files))
114-
115119
for file_name in notice_files:
116120
file_list = {}
117121
file_content = ""

0 commit comments

Comments
 (0)