Skip to content

Commit

Permalink
Change the json key and value format
Browse files Browse the repository at this point in the history
  • Loading branch information
soimkim committed Jul 8, 2024
1 parent 5c6f6dd commit 588420c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
23 changes: 7 additions & 16 deletions src/fosslight_scanner/_parse_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ def parse_setting_json(data):
mode = data.get('mode', [])
path = data.get('path', [])
dep_argument = data.get('dep_argument', '')
outputDir = data.get('outputDir', '')
outputFile = data.get('outputFile', '')
output = data.get('output', '')
format = data.get('format', '')
link = data.get('link', [])
link = data.get('link', "")
db_url = data.get('db_url', '')
timer = data.get('timer', False)
raw = data.get('raw', False)
core = data.get('core', -1)
no_correction = data.get('no_correction', False)
correct_fpath = data.get('correct_fpath', '')
ui = data.get('ui', False)
exclude_path = data.get('exclude_path', [])
exclude_path = data.get('exclude', [])

str_lists = [mode, path, link, exclude_path]
strings = [dep_argument, outputDir, outputFile, format, db_url, correct_fpath]
str_lists = [mode, path, exclude_path]
strings = [dep_argument, output, format, db_url, correct_fpath, link]
booleans = [timer, raw, no_correction, ui]
is_incorrect = False

Expand All @@ -48,16 +47,8 @@ def parse_setting_json(data):
is_incorrect = True
core = -1

if (is_incorrect):
if is_incorrect:
print('Ignoring some values with incorrect format in the setting file.')

if not mode:
mode = ['all']
final_mode = mode[0].split()
if (not ("compare" in final_mode) and (len(path) > 0)):
path = [path[0]]
link = link[0] if (link and not path) else ''
output = os.path.join(outputDir, outputFile)

return final_mode, path, dep_argument, output, format, link, db_url, timer, \
return mode, path, dep_argument, output, format, link, db_url, timer, \
raw, core, no_correction, correct_fpath, ui, exclude_path
3 changes: 2 additions & 1 deletion src/fosslight_scanner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
from .fosslight_scanner import run_main, PKG_NAME
from ._parse_setting import parse_setting_json
from fosslight_util.help import print_package_version
import os.path


def set_args(mode, path, dep_argument, output, format, link, db_url, timer,
raw, core, no_correction, correct_fpath, ui, setting, exclude_path):
if (setting):
if setting and os.path.isfile(setting):
try:
with open(setting, 'r', encoding='utf-8') as file:
data = json.load(file)
Expand Down
12 changes: 5 additions & 7 deletions tests/setting.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
{
"mode": ["binary source"],
"mode": ["binary", "source"],
"path": ["tests"],
"link": [],
"link": "",
"dep_argument": "",
"outputDir": "test_result_parse_setting",
"outputFile": "",
"exclude_path": ["test", "sample_license.txt"],
"output": "test_result_dir",
"exclude": ["test", "sample_license.txt"],
"format": "excel",
"db_url": "",
"timer": false,
"raw": true,
"core": -1,
"no_correction": false,
"correct_fpath": "",
"ui": false,
"type": "analyze"
"ui": false
}
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ commands =
fosslight binary source -o test_result_multi_mode/test.xlsx -p tests -r
fosslight -o test_result_exclude_path/test.xlsx -p tests -e test sample_license.txt
fosslight dependency -o test_result_wget -w "https://github.com/LGE-OSS/example.git"
fosslight -f yaml -s tests/setting.json
fosslight source -s tests/setting.json
ls test_result_wget

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

0 comments on commit 588420c

Please sign in to comment.