Skip to content

Commit 44c6882

Browse files
committed
Change the json key and value format
1 parent 5c6f6dd commit 44c6882

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

src/fosslight_scanner/_parse_setting.py

+7-17
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,27 @@
22
# -*- coding: utf-8 -*-
33
# Copyright (c) 2021 LG Electronics Inc.
44
# SPDX-License-Identifier: Apache-2.0
5-
import os
65

76

87
def parse_setting_json(data):
98
# check type, if invalid = init value
109
mode = data.get('mode', [])
1110
path = data.get('path', [])
1211
dep_argument = data.get('dep_argument', '')
13-
outputDir = data.get('outputDir', '')
14-
outputFile = data.get('outputFile', '')
12+
output = data.get('output', '')
1513
format = data.get('format', '')
16-
link = data.get('link', [])
14+
link = data.get('link', "")
1715
db_url = data.get('db_url', '')
1816
timer = data.get('timer', False)
1917
raw = data.get('raw', False)
2018
core = data.get('core', -1)
2119
no_correction = data.get('no_correction', False)
2220
correct_fpath = data.get('correct_fpath', '')
2321
ui = data.get('ui', False)
24-
exclude_path = data.get('exclude_path', [])
22+
exclude_path = data.get('exclude', [])
2523

26-
str_lists = [mode, path, link, exclude_path]
27-
strings = [dep_argument, outputDir, outputFile, format, db_url, correct_fpath]
24+
str_lists = [mode, path, exclude_path]
25+
strings = [dep_argument, output, format, db_url, correct_fpath, link]
2826
booleans = [timer, raw, no_correction, ui]
2927
is_incorrect = False
3028

@@ -48,16 +46,8 @@ def parse_setting_json(data):
4846
is_incorrect = True
4947
core = -1
5048

51-
if (is_incorrect):
49+
if is_incorrect:
5250
print('Ignoring some values with incorrect format in the setting file.')
5351

54-
if not mode:
55-
mode = ['all']
56-
final_mode = mode[0].split()
57-
if (not ("compare" in final_mode) and (len(path) > 0)):
58-
path = [path[0]]
59-
link = link[0] if (link and not path) else ''
60-
output = os.path.join(outputDir, outputFile)
61-
62-
return final_mode, path, dep_argument, output, format, link, db_url, timer, \
52+
return mode, path, dep_argument, output, format, link, db_url, timer, \
6353
raw, core, no_correction, correct_fpath, ui, exclude_path

src/fosslight_scanner/cli.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
from .fosslight_scanner import run_main, PKG_NAME
1010
from ._parse_setting import parse_setting_json
1111
from fosslight_util.help import print_package_version
12+
import os.path
1213

1314

1415
def set_args(mode, path, dep_argument, output, format, link, db_url, timer,
1516
raw, core, no_correction, correct_fpath, ui, setting, exclude_path):
16-
if (setting):
17+
if setting and os.path.isfile(setting):
1718
try:
1819
with open(setting, 'r', encoding='utf-8') as file:
1920
data = json.load(file)

tests/setting.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
{
2-
"mode": ["binary source"],
2+
"mode": ["binary", "source"],
33
"path": ["tests"],
4-
"link": [],
4+
"link": "",
55
"dep_argument": "",
6-
"outputDir": "test_result_parse_setting",
7-
"outputFile": "",
8-
"exclude_path": ["test", "sample_license.txt"],
6+
"output": "test_result_dir",
7+
"exclude": ["test", "sample_license.txt"],
98
"format": "excel",
109
"db_url": "",
1110
"timer": false,
1211
"raw": true,
1312
"core": -1,
1413
"no_correction": false,
1514
"correct_fpath": "",
16-
"ui": false,
17-
"type": "analyze"
15+
"ui": false
1816
}

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ commands =
3131
fosslight binary source -o test_result_multi_mode/test.xlsx -p tests -r
3232
fosslight -o test_result_exclude_path/test.xlsx -p tests -e test sample_license.txt
3333
fosslight dependency -o test_result_wget -w "https://github.com/LGE-OSS/example.git"
34-
fosslight -f yaml -s tests/setting.json
34+
fosslight source -s tests/setting.json
3535
ls test_result_wget
3636

3737
[testenv:release]
@@ -44,5 +44,5 @@ commands =
4444
fosslight binary dependency -o test_result_multi_mode/test.xlsx -p tests -r
4545
fosslight -o test_result_exclude_path/test.xlsx -p tests -e test sample_license.txt
4646
fosslight source -o test_result_wget -w "https://github.com/LGE-OSS/example.git"
47-
fosslight -f yaml -s tests/setting.json
47+
fosslight binary -s tests/setting.json
4848
pytest -v --flake8

0 commit comments

Comments
 (0)