Skip to content

Commit ff22028

Browse files
committed
remove some options
Signed-off-by: Ethan Lee <[email protected]>
1 parent 42e27c7 commit ff22028

File tree

2 files changed

+28
-59
lines changed

2 files changed

+28
-59
lines changed

src/fosslight_android/android_binary_analysis.py

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@
3131
get_path_by_using_find
3232
)
3333
from .check_package_file import check_packaging_files
34-
from .check_notice_file import (
35-
run_notice_html_checklist,
34+
from .check_notice_file import (
3635
find_bin_in_notice,
37-
read_notice_file,
38-
create_additional_notice,
39-
divide_notice_files_by_binary
36+
read_notice_file
4037
)
4138
from ._binary_db_controller import get_oss_info_from_db
4239
from ._common import (
@@ -72,7 +69,6 @@
7269
platform_version = "" # Android Version. ex- 7.0.0.r1 -> 7.0
7370

7471
# Define Const Variables
75-
NOTICE_HTML_FILE_NAME = ""
7672
ANDROID_LOG_FILE_NAME = "android.log"
7773
num_cores = 1
7874
now = ""
@@ -343,7 +339,7 @@ def find_notice_value(notice_zip_dest_file=""):
343339
notice_file_comment = "Notice file not found."
344340

345341
try:
346-
notice_file_list, notice_files = read_notice_file(os.path.abspath(build_out_notice_file_path), NOTICE_HTML_FILE_NAME)
342+
notice_file_list, notice_files = read_notice_file(os.path.abspath(build_out_notice_file_path))
347343
if notice_file_list:
348344
if notice_files:
349345
for notice_file in notice_files:
@@ -794,13 +790,11 @@ def create_and_copy_notice_zip(notice_files_list, zip_file_path):
794790

795791

796792
def main():
797-
global android_log_lines, ANDROID_LOG_FILE_NAME, NOTICE_HTML_FILE_NAME, python_script_dir, num_cores, now, logger, final_bin_info
798-
find_empty_path = False
799-
_create_additial_notice = False
793+
global android_log_lines, ANDROID_LOG_FILE_NAME, python_script_dir, num_cores, now, logger, final_bin_info
794+
find_empty_path = False
800795
notice_check_ok = False
801796
base_binary_txt = ""
802-
auto_fill_oss_name = True
803-
_NOTICE_CHECKLIST_TYPE = False
797+
auto_fill_oss_name = True
804798
analyze_source = False
805799
path_to_exclude = []
806800
RESULT_FILE_EXTENSION = ".xlsx"
@@ -820,17 +814,12 @@ def main():
820814
parser = argparse.ArgumentParser(description='FOSSLight Android', prog='fosslight_android', add_help=False)
821815
parser.add_argument('-h', '--help', action='store_true', required=False)
822816
parser.add_argument('-v', '--version', action='store_true', required=False)
823-
parser.add_argument('-s', '--source', type=str, required=False)
824-
parser.add_argument('-b', '--binary', type=str, required=False)
825-
parser.add_argument('-n', '--notice', type=str, required=False)
826-
parser.add_argument('-t', '--toadd', action='store_true', required=False)
827-
parser.add_argument('-m', '--more', action='store_true', required=False)
828-
parser.add_argument('-c', '--check', type=str, required=False)
817+
parser.add_argument('-s', '--source', type=str, required=False)
818+
parser.add_argument('-m', '--more', action='store_true', required=False)
829819
parser.add_argument('-a', '--android', type=str, required=False)
830820
parser.add_argument('-f', '--find', action='store_true', required=False)
831821
parser.add_argument('-i', '--ignore', action='store_true', required=False)
832-
parser.add_argument('-p', '--packaging', type=str, required=False)
833-
parser.add_argument('-d', '--divide', type=str, required=False)
822+
parser.add_argument('-p', '--packaging', type=str, required=False)
834823
parser.add_argument('-r', '--remove', type=str, required=False)
835824
parser.add_argument('-e', '--exclude', nargs="*", required=False, default=[])
836825

@@ -842,17 +831,10 @@ def main():
842831
if args.source: # android source path
843832
os.chdir(args.source)
844833
android_src_path = args.source
845-
if args.binary: # Base model's binary.txt to exclude
846-
base_binary_txt = args.binary
847-
if args.notice:
848-
NOTICE_HTML_FILE_NAME = args.notice
849-
if args.toadd: # Create needtoadd-notice.html file.
850-
_create_additial_notice = True
834+
851835
if args.more: # Analyze source mode.
852836
analyze_source = True
853-
if args.check:
854-
_NOTICE_CHECKLIST_TYPE = True
855-
notice_check_ok = (args.check == "ok" or args.check == "OK")
837+
856838
if args.android:
857839
ANDROID_LOG_FILE_NAME = args.android
858840
if args.find: # Execute "find" command when source path is not found.
@@ -867,15 +849,9 @@ def main():
867849
if args.packaging:
868850
check_packaging_files(args.packaging)
869851
return
870-
if args.divide:
871-
divide_notice_files_by_binary(args.divide, python_script_dir, now)
872-
return
852+
873853
if args.remove: # Remove the inputted list from the binary list.
874-
remove_list_file = args.remove
875-
876-
if _NOTICE_CHECKLIST_TYPE:
877-
run_notice_html_checklist(base_binary_txt, notice_check_ok, NOTICE_HTML_FILE_NAME)
878-
return
854+
remove_list_file = args.remove
879855

880856
read_success, android_log_lines = read_file(ANDROID_LOG_FILE_NAME)
881857
if not read_success:
@@ -912,10 +888,7 @@ def main():
912888
if not success:
913889
logger.warning(f"Failed to write result to excel:{msg}")
914890
result_log["Output FOSSLight Report"] = f"{result_file}"
915-
916-
if _create_additial_notice:
917-
create_additional_notice(final_bin_info, python_script_dir)
918-
891+
919892
# Print the result
920893
result_log["Output Directory"] = python_script_dir
921894
try:

src/fosslight_android/check_notice_file.py

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

9898

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
99+
def read_notice_file(notice_file_path):
100+
final_notice_file = {}
102101
encodings = ["latin-1", "utf-8", "utf-16"]
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))
102+
notice_files = []
103+
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))
118114

119115
for file_name in notice_files:
120116
file_list = {}

0 commit comments

Comments
 (0)