From 370f9158e54fbead63a83728ec27e2570967128e Mon Sep 17 00:00:00 2001 From: Wonjae Park Date: Tue, 25 Oct 2022 16:24:15 +0900 Subject: [PATCH] Unify help message for scanner and converter --- src/fosslight_source/_help.py | 42 ++++++++---------------- src/fosslight_source/cli.py | 6 ++-- src/fosslight_source/convert_scancode.py | 6 ++-- tests/test_files/run_scancode.py | 8 ++--- 4 files changed, 23 insertions(+), 39 deletions(-) diff --git a/src/fosslight_source/_help.py b/src/fosslight_source/_help.py index 23db55f..65dc9cf 100644 --- a/src/fosslight_source/_help.py +++ b/src/fosslight_source/_help.py @@ -4,52 +4,36 @@ # SPDX-License-Identifier: Apache-2.0 from fosslight_util.help import PrintHelpMsg, print_package_version -_HELP_MESSAGE_SOURCE = """ - Usage: fosslight_source [option1] [option2] ... +_HELP_MESSAGE_SOURCE_SCANNER = """ + FOSSLight Source Scanner Usage: fosslight_source [option1] [option2] ... - FOSSLight Source uses ScanCode, a source code scanner, to detect the copyright and license phrases - contained in the file. Some files (ex- build script), binary files, directory and files in specific + FOSSLight Source Scanner uses ScanCode and SCANOSS, the source code scanners, to detect + the copyright and license phrases contained in the file. + Some files (ex- build script), binary files, directory and files in specific directories (ex-test) are excluded from the result. - And removes words such as “-only” and “-old-style” from the license name to be printed. - The output result is generated in Excel format. + + FOSSLight Convert Usage: fosslight_convert [option1] [option2] ... + + FOSSLigtht Converter converts the result of ScanCode in json format into FOSSLight Report format. Options: Optional -p \t Path to analyze source (Default: current directory) -h\t\t\t Print help message -v\t\t\t Print FOSSLight Source Scanner version - -j\t\t\t Generate raw result of scanners in json format -m\t\t\t Print additional information for scan result on separate sheets -o \t Output path (Path or file name) -f \t\t Output file format (excel, csv, opossum, yaml) + Options only for FOSSLight Source Scanner -s \t Select which scanner to be run (scancode, scanoss, all) + -j\t\t\t Generate raw result of scanners in json format -t \t\t Stop scancode scanning if scanning takes longer than a timeout in seconds.""" -_HELP_MESSAGE_CONVERT = """ - Usage: fosslight_convert [option1] [option2] ... - - FOSSLigtht_convert converts the result of executing ScanCode in json format into FOSSLight Report format. - - Options: - Optional - -p \t\t Path of ScanCode json files (Default: current directory) - -h\t\t\t\t Print help message - -v\t\t\t\t Print FOSSLight Source Scanner version - -m\t\t\t\t Print the Matched text for each license on a separate sheet - -o \t\t Output path - \t\t\t\t (If you want to generate the specific file name, add the output path with file name.) - -f \t\t\t Output file format (excel, csv, opossum)""" - def print_version(pkg_name): print_package_version(pkg_name, "FOSSLight Source Scanner Version") -def print_help_msg_source(): - helpMsg = PrintHelpMsg(_HELP_MESSAGE_SOURCE) - helpMsg.print_help_msg(True) - - -def print_help_msg_convert(): - helpMsg = PrintHelpMsg(_HELP_MESSAGE_CONVERT) +def print_help_msg_source_scanner(): + helpMsg = PrintHelpMsg(_HELP_MESSAGE_SOURCE_SCANNER) helpMsg.print_help_msg(True) diff --git a/src/fosslight_source/cli.py b/src/fosslight_source/cli.py index 4067e28..df23505 100755 --- a/src/fosslight_source/cli.py +++ b/src/fosslight_source/cli.py @@ -12,7 +12,7 @@ import fosslight_util.constant as constant from fosslight_util.set_log import init_log from fosslight_util.timer_thread import TimerThread -from ._help import print_help_msg_source, print_version +from ._help import print_version, print_help_msg_source_scanner from ._license_matched import get_license_list_to_print from fosslight_util.output_format import check_output_format, write_output_file from .run_scancode import run_scan @@ -66,7 +66,7 @@ def main(): args = parser.parse_args() if args.help: - print_help_msg_source() + print_help_msg_source_scanner() if args.version: print_version(_PKG_NAME) if not args.path: @@ -111,7 +111,7 @@ def main(): print_matched_text, format, True, time_out) else: - print_help_msg_source() + print_help_msg_source_scanner() sys.exit(1) create_report_file(_start_time, scanned_result, license_list, selected_scanner, print_matched_text, output_path, output_file, output_extension) diff --git a/src/fosslight_source/convert_scancode.py b/src/fosslight_source/convert_scancode.py index 67a26a4..fdba3c9 100755 --- a/src/fosslight_source/convert_scancode.py +++ b/src/fosslight_source/convert_scancode.py @@ -12,7 +12,7 @@ import yaml from ._parsing_scancode_file_item import parsing_file_item, get_error_from_header from fosslight_util.output_format import check_output_format, write_output_file -from ._help import print_help_msg_convert, print_version +from ._help import print_version, print_help_msg_source_scanner from ._license_matched import get_license_list_to_print import argparse @@ -145,7 +145,7 @@ def main(): args = parser.parse_args() if args.help: - print_help_msg_convert() + print_help_msg_source_scanner() if args.version: print_version(_PKG_NAME) if not args.path: @@ -159,7 +159,7 @@ def main(): format = ''.join(args.format) if path_to_find_json == "": - print_help_msg_convert() + print_help_msg_source_scanner() convert_json_to_output_report(path_to_find_json, output_file_name, print_matched_text, format) diff --git a/tests/test_files/run_scancode.py b/tests/test_files/run_scancode.py index a04f99e..ef16700 100755 --- a/tests/test_files/run_scancode.py +++ b/tests/test_files/run_scancode.py @@ -19,7 +19,7 @@ from ._parsing_scancode_file_item import parsing_file_item from ._parsing_scancode_file_item import get_error_from_header from fosslight_util.write_excel import write_excel_and_csv -from ._help import print_help_msg_source +from ._help import print_help_msg_source_scanner from ._license_matched import get_license_list_to_print logger = logging.getLogger(constant.LOGGER_NAME) @@ -38,7 +38,7 @@ def main(): opts, args = getopt.getopt(argv, 'hmjp:o:') for opt, arg in opts: if opt == "-h": - print_help_msg_source() + print_help_msg_source_scanner() elif opt == "-p": path_to_scan = arg elif opt == "-j": @@ -48,7 +48,7 @@ def main(): elif opt == "-m": print_matched_text = True except Exception: - print_help_msg_source() + print_help_msg_source_scanner() timer = TimerThread() timer.setDaemon(True) @@ -85,7 +85,7 @@ def run_scan(path_to_scan, output_file_name="", if _windows: path_to_scan = os.getcwd() else: - print_help_msg_source() + print_help_msg_source_scanner() num_cores = multiprocessing.cpu_count() - 1 if num_cores < 0 else num_cores