Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 13 additions & 29 deletions src/fosslight_source/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] <arg1> [option2] <arg2>...
_HELP_MESSAGE_SOURCE_SCANNER = """
FOSSLight Source Scanner Usage: fosslight_source [option1] <arg1> [option2] <arg2>...

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] <arg1> [option2] <arg2>...

FOSSLigtht Converter converts the result of ScanCode in json format into FOSSLight Report format.

Options:
Optional
-p <source_path>\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 <output_path>\t Output path (Path or file name)
-f <format>\t\t Output file format (excel, csv, opossum, yaml)
Options only for FOSSLight Source Scanner
-s <scanner>\t Select which scanner to be run (scancode, scanoss, all)
-j\t\t\t Generate raw result of scanners in json format
-t <float>\t\t Stop scancode scanning if scanning takes longer than a timeout in seconds."""

_HELP_MESSAGE_CONVERT = """
Usage: fosslight_convert [option1] <arg1> [option2] <arg2>...

FOSSLigtht_convert converts the result of executing ScanCode in json format into FOSSLight Report format.

Options:
Optional
-p <path_dir>\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 <output_path>\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 <format>\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)
6 changes: 3 additions & 3 deletions src/fosslight_source/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/fosslight_source/convert_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_files/run_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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":
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down