diff --git a/requirements.txt b/requirements.txt index cb90d38..70e3343 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -click==6.7 +click==7.1.2 scancode-toolkit<=21.3.31 typecode_libmagic XlsxWriter diff --git a/setup.py b/setup.py index 2bcb3a7..98951ad 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ if __name__ == "__main__": setup( name='fosslight_source', - version='1.4.5', + version='1.4.6', package_dir={"": "src"}, packages=find_packages(where='src'), description='FOSSLight Source', diff --git a/src/fosslight_source/_parsing_scancode_file_item.py b/src/fosslight_source/_parsing_scancode_file_item.py index 03cab25..c1a035f 100755 --- a/src/fosslight_source/_parsing_scancode_file_item.py +++ b/src/fosslight_source/_parsing_scancode_file_item.py @@ -62,7 +62,7 @@ def set_is_license_text(self, value): def get_row_to_print(self): print_rows = [self.file, "", "", ','.join(self.licenses), "", "", - ','.join(self.copyright), "", + ','.join(self.copyright), "Exclude" if self.exclude else "", self.comment] return print_rows diff --git a/src/fosslight_source/convert_scancode.py b/src/fosslight_source/convert_scancode.py index d3c3f37..7610e1d 100755 --- a/src/fosslight_source/convert_scancode.py +++ b/src/fosslight_source/convert_scancode.py @@ -16,6 +16,7 @@ import yaml from ._parsing_scancode_file_item import parsing_file_item from fosslight_util.write_excel import write_excel_and_csv +from .help import print_help_msg_convert logger = logging.getLogger(constant.LOGGER_NAME) _PKG_NAME = "fosslight_source" @@ -88,11 +89,6 @@ def get_detected_licenses_from_scancode(scancode_json_file): return file_list -def print_help_msg(): - print("* Required :\n -p path_of_scancode_json_result") - sys.exit() - - def main(): global logger @@ -105,7 +101,7 @@ def main(): opts, args = getopt.getopt(argv, 'hp:o:') for opt, arg in opts: if opt == "-h": - print_help_msg() + print_help_msg_convert() elif opt == "-p": path_to_find_bin = arg elif opt == "-o": diff --git a/src/fosslight_source/help.py b/src/fosslight_source/help.py new file mode 100644 index 0000000..3899fd0 --- /dev/null +++ b/src/fosslight_source/help.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2021 LG Electronics Inc. +# SPDX-License-Identifier: Apache-2.0 +from fosslight_util.help import PrintHelpMsg + +_HELP_MESSAGE_SOURCE = """ + 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 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. + + Options: + Mandatory + -p \t\t Path to analyze source + + Optional + -h\t\t\t\t Print help message + -j\t\t\t\t Generate additional result of executing ScanCode in json format + -o \t\t Output file name""" + +_HELP_MESSAGE_CONVERT = """ + Usage: fosslight_convert [option1] [option2] ... + + FOSSLigtht_convert converts the result of executing ScanCode in json format into OSS Report format. + + Options: + Mandatory + -p \t\t Path of ScanCode json files + + Optional + -h\t\t\t\t Print help message + -o \t\t Output file name""" + + +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) + helpMsg.print_help_msg(True) diff --git a/src/fosslight_source/run_scancode.py b/src/fosslight_source/run_scancode.py index 62e1a04..a624d64 100755 --- a/src/fosslight_source/run_scancode.py +++ b/src/fosslight_source/run_scancode.py @@ -19,6 +19,7 @@ from fosslight_util.timer_thread import TimerThread from ._parsing_scancode_file_item import parsing_file_item from fosslight_util.write_excel import write_excel_and_csv +from .help import print_help_msg_source logger = logging.getLogger(constant.LOGGER_NAME) warnings.filterwarnings("ignore", category=FutureWarning) @@ -26,12 +27,6 @@ _ERROR_PREFIX = "* Error : " -def print_help_msg(): - print("* Required : -p path_to_scan") - print("* Optional : -j ") - sys.exit() - - def main(): argv = sys.argv[1:] _path_to_scan = "" @@ -42,7 +37,7 @@ def main(): opts, args = getopt.getopt(argv, 'hjp:o:') for opt, arg in opts: if opt == "-h": - print_help_msg() + print_help_msg_source() elif opt == "-p": _path_to_scan = arg elif opt == "-j": @@ -51,7 +46,7 @@ def main(): _output_file = arg except Exception: - print_help_msg() + print_help_msg_source() timer = TimerThread() timer.setDaemon(True) @@ -88,7 +83,7 @@ def run_scan(path_to_scan, output_file_name="", if _windows: path_to_scan = os.getcwd() else: - print_help_msg() + print_help_msg_source() num_cores = multiprocessing.cpu_count() - 1 if num_cores < 0 else num_cores diff --git a/tox.ini b/tox.ini index d920799..f99f779 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,8 @@ setenv = PYTHONPATH=. commands = + fosslight_source -h + fosslight_convert -h fosslight_source -p test -j -o test_scan/scan_result cat test_scan/scan_result.csv fosslight_convert -p test_scan/scan_result.json -o test_convert/convert_result