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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
click==6.7
click==7.1.2
scancode-toolkit<=21.3.31
typecode_libmagic
XlsxWriter
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/fosslight_source/_parsing_scancode_file_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions src/fosslight_source/convert_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand All @@ -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":
Expand Down
43 changes: 43 additions & 0 deletions src/fosslight_source/help.py
Original file line number Diff line number Diff line change
@@ -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] <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 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 <source_path>\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 <file_name>\t\t Output file name"""

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

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

Options:
Mandatory
-p <path_dir>\t\t Path of ScanCode json files

Optional
-h\t\t\t\t Print help message
-o <file_name>\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)
13 changes: 4 additions & 9 deletions src/fosslight_source/run_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@
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)
_PKG_NAME = "fosslight_source"
_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 = ""
Expand All @@ -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":
Expand All @@ -51,7 +46,7 @@ def main():
_output_file = arg

except Exception:
print_help_msg()
print_help_msg_source()

timer = TimerThread()
timer.setDaemon(True)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down