Skip to content

Commit bc6d855

Browse files
authored
Merge pull request #8 from fosslight/develop
- Update Help Message - Fix exclude column error
2 parents b10d3d5 + 8a738c8 commit bc6d855

File tree

7 files changed

+54
-18
lines changed

7 files changed

+54
-18
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
click==6.7
1+
click==7.1.2
22
scancode-toolkit<=21.3.31
33
typecode_libmagic
44
XlsxWriter

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
if __name__ == "__main__":
1515
setup(
1616
name='fosslight_source',
17-
version='1.4.5',
17+
version='1.4.6',
1818
package_dir={"": "src"},
1919
packages=find_packages(where='src'),
2020
description='FOSSLight Source',

src/fosslight_source/_parsing_scancode_file_item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def set_is_license_text(self, value):
6262

6363
def get_row_to_print(self):
6464
print_rows = [self.file, "", "", ','.join(self.licenses), "", "",
65-
','.join(self.copyright), "",
65+
','.join(self.copyright),
6666
"Exclude" if self.exclude else "",
6767
self.comment]
6868
return print_rows

src/fosslight_source/convert_scancode.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import yaml
1717
from ._parsing_scancode_file_item import parsing_file_item
1818
from fosslight_util.write_excel import write_excel_and_csv
19+
from .help import print_help_msg_convert
1920

2021
logger = logging.getLogger(constant.LOGGER_NAME)
2122
_PKG_NAME = "fosslight_source"
@@ -88,11 +89,6 @@ def get_detected_licenses_from_scancode(scancode_json_file):
8889
return file_list
8990

9091

91-
def print_help_msg():
92-
print("* Required :\n -p path_of_scancode_json_result")
93-
sys.exit()
94-
95-
9692
def main():
9793
global logger
9894

@@ -105,7 +101,7 @@ def main():
105101
opts, args = getopt.getopt(argv, 'hp:o:')
106102
for opt, arg in opts:
107103
if opt == "-h":
108-
print_help_msg()
104+
print_help_msg_convert()
109105
elif opt == "-p":
110106
path_to_find_bin = arg
111107
elif opt == "-o":

src/fosslight_source/help.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2021 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
from fosslight_util.help import PrintHelpMsg
6+
7+
_HELP_MESSAGE_SOURCE = """
8+
Usage: fosslight_source [option1] <arg1> [option2] <arg2>...
9+
10+
FOSSLight Source uses ScanCode, a source code scanner, to detect the copyright and license phrases contained in the file.
11+
Some files (ex- build script), binary files, directory and files in specific directories (ex-test) are excluded from the result.
12+
And removes words such as “-only” and “-old-style” from the license name to be printed. The output result is generated in Excel format.
13+
14+
Options:
15+
Mandatory
16+
-p <source_path>\t\t Path to analyze source
17+
18+
Optional
19+
-h\t\t\t\t Print help message
20+
-j\t\t\t\t Generate additional result of executing ScanCode in json format
21+
-o <file_name>\t\t Output file name"""
22+
23+
_HELP_MESSAGE_CONVERT = """
24+
Usage: fosslight_convert [option1] <arg1> [option2] <arg2>...
25+
26+
FOSSLigtht_convert converts the result of executing ScanCode in json format into OSS Report format.
27+
28+
Options:
29+
Mandatory
30+
-p <path_dir>\t\t Path of ScanCode json files
31+
32+
Optional
33+
-h\t\t\t\t Print help message
34+
-o <file_name>\t\t Output file name"""
35+
36+
37+
def print_help_msg_source():
38+
helpMsg = PrintHelpMsg(_HELP_MESSAGE_SOURCE)
39+
helpMsg.print_help_msg(True)
40+
41+
def print_help_msg_convert():
42+
helpMsg = PrintHelpMsg(_HELP_MESSAGE_CONVERT)
43+
helpMsg.print_help_msg(True)

src/fosslight_source/run_scancode.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,14 @@
1919
from fosslight_util.timer_thread import TimerThread
2020
from ._parsing_scancode_file_item import parsing_file_item
2121
from fosslight_util.write_excel import write_excel_and_csv
22+
from .help import print_help_msg_source
2223

2324
logger = logging.getLogger(constant.LOGGER_NAME)
2425
warnings.filterwarnings("ignore", category=FutureWarning)
2526
_PKG_NAME = "fosslight_source"
2627
_ERROR_PREFIX = "* Error : "
2728

2829

29-
def print_help_msg():
30-
print("* Required : -p path_to_scan")
31-
print("* Optional : -j ")
32-
sys.exit()
33-
34-
3530
def main():
3631
argv = sys.argv[1:]
3732
_path_to_scan = ""
@@ -42,7 +37,7 @@ def main():
4237
opts, args = getopt.getopt(argv, 'hjp:o:')
4338
for opt, arg in opts:
4439
if opt == "-h":
45-
print_help_msg()
40+
print_help_msg_source()
4641
elif opt == "-p":
4742
_path_to_scan = arg
4843
elif opt == "-j":
@@ -51,7 +46,7 @@ def main():
5146
_output_file = arg
5247

5348
except Exception:
54-
print_help_msg()
49+
print_help_msg_source()
5550

5651
timer = TimerThread()
5752
timer.setDaemon(True)
@@ -88,7 +83,7 @@ def run_scan(path_to_scan, output_file_name="",
8883
if _windows:
8984
path_to_scan = os.getcwd()
9085
else:
91-
print_help_msg()
86+
print_help_msg_source()
9287

9388
num_cores = multiprocessing.cpu_count() - 1 if num_cores < 0 else num_cores
9489

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ setenv =
1212
PYTHONPATH=.
1313

1414
commands =
15+
fosslight_source -h
16+
fosslight_convert -h
1517
fosslight_source -p test -j -o test_scan/scan_result
1618
cat test_scan/scan_result.csv
1719
fosslight_convert -p test_scan/scan_result.json -o test_convert/convert_result

0 commit comments

Comments
 (0)