From df14a294eb3e73f65baa949a44b52a3ded6d90e7 Mon Sep 17 00:00:00 2001 From: "Jaekwon.bang" Date: Fri, 14 May 2021 08:32:50 +0900 Subject: [PATCH 1/5] Update Help Message --- src/fosslight_source/help.py | 26 ++++++++++++++++++++++++++ src/fosslight_source/run_scancode.py | 7 +------ tox.ini | 1 + 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 src/fosslight_source/help.py diff --git a/src/fosslight_source/help.py b/src/fosslight_source/help.py new file mode 100644 index 0000000..edab4f2 --- /dev/null +++ b/src/fosslight_source/help.py @@ -0,0 +1,26 @@ +#!/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""" + + +def print_help_msg(): + helpMsg = PrintHelpMsg(_HELP_MESSAGE_SOURCE) + helpMsg.print_help_msg(True) \ No newline at end of file diff --git a/src/fosslight_source/run_scancode.py b/src/fosslight_source/run_scancode.py index 62e1a04..7ee51de 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 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 = "" diff --git a/tox.ini b/tox.ini index d920799..9331d76 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ setenv = PYTHONPATH=. commands = + fosslight_source -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 From 9fca2cf4427146109bb4568a961ac8bef1d8267f Mon Sep 17 00:00:00 2001 From: "Jaekwon.bang" Date: Fri, 14 May 2021 10:25:46 +0900 Subject: [PATCH 2/5] Add FOSSLight Convert help message --- src/fosslight_source/convert_scancode.py | 8 ++------ src/fosslight_source/help.py | 16 +++++++++++++++- src/fosslight_source/run_scancode.py | 8 ++++---- tox.ini | 1 + 4 files changed, 22 insertions(+), 11 deletions(-) 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 index edab4f2..203a3ec 100644 --- a/src/fosslight_source/help.py +++ b/src/fosslight_source/help.py @@ -20,7 +20,21 @@ -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] ... -def print_help_msg(): + FOSSLigtht_convert converts the result of executing ScanCode in json format into OSS Report format. + + Options: + -h\t\t\t\t Print help message + -p \t\t Path of ScanCode json files + -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) \ No newline at end of file diff --git a/src/fosslight_source/run_scancode.py b/src/fosslight_source/run_scancode.py index 7ee51de..a624d64 100755 --- a/src/fosslight_source/run_scancode.py +++ b/src/fosslight_source/run_scancode.py @@ -19,7 +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 +from .help import print_help_msg_source logger = logging.getLogger(constant.LOGGER_NAME) warnings.filterwarnings("ignore", category=FutureWarning) @@ -37,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": @@ -46,7 +46,7 @@ def main(): _output_file = arg except Exception: - print_help_msg() + print_help_msg_source() timer = TimerThread() timer.setDaemon(True) @@ -83,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 9331d76..f99f779 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ setenv = 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 From e6ff9208f601532e1085c5c45031aa4ee5457e26 Mon Sep 17 00:00:00 2001 From: "Jaekwon.bang" Date: Fri, 14 May 2021 11:17:49 +0900 Subject: [PATCH 3/5] Version up to 1.4.6 --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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', From 1fa5c3130789121ae4dd785eaa38cc54929bfc5f Mon Sep 17 00:00:00 2001 From: "Jaekwon.bang" Date: Fri, 14 May 2021 15:13:18 +0900 Subject: [PATCH 4/5] Fix exclude column error --- src/fosslight_source/_parsing_scancode_file_item.py | 2 +- src/fosslight_source/help.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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/help.py b/src/fosslight_source/help.py index 203a3ec..37924dd 100644 --- a/src/fosslight_source/help.py +++ b/src/fosslight_source/help.py @@ -26,8 +26,11 @@ FOSSLigtht_convert converts the result of executing ScanCode in json format into OSS Report format. Options: - -h\t\t\t\t Print help message + Mandatory -p \t\t Path of ScanCode json files + + Optional + -h\t\t\t\t Print help message -o \t\t Output file name""" From 8a738c8798fe10dd7e8e1d893a2dd59cc2987391 Mon Sep 17 00:00:00 2001 From: bjk7119 <81218204+bjk7119@users.noreply.github.com> Date: Fri, 14 May 2021 15:22:41 +0900 Subject: [PATCH 5/5] Update help.py --- src/fosslight_source/help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fosslight_source/help.py b/src/fosslight_source/help.py index 37924dd..3899fd0 100644 --- a/src/fosslight_source/help.py +++ b/src/fosslight_source/help.py @@ -40,4 +40,4 @@ def print_help_msg_source(): def print_help_msg_convert(): helpMsg = PrintHelpMsg(_HELP_MESSAGE_CONVERT) - helpMsg.print_help_msg(True) \ No newline at end of file + helpMsg.print_help_msg(True)