Skip to content

Commit ea8a76d

Browse files
authored
Merge pull request #29 from fosslight/develop
Fix the pub parsing error
2 parents ec427f9 + e5f0052 commit ea8a76d

File tree

6 files changed

+41
-26
lines changed

6 files changed

+41
-26
lines changed

cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2020 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
from fosslight_dependency.analyze_dependency import main
6+
7+
8+
if __name__ == '__main__':
9+
main()

src/fosslight_dependency/_version.py renamed to hooks/hook-fosslight_dependency.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
# -*- coding: utf-8 -*-
33
# Copyright (c) 2021 LG Electronics Inc.
44
# SPDX-License-Identifier: Apache-2.0
5-
__version__ = "3.2.1"
5+
from PyInstaller.utils.hooks import collect_all
6+
7+
datas, binaries, hiddenimports = collect_all('fosslight_dependency')

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
with open('requirements.txt', 'r', 'utf-8') as f:
1414
required = f.read().splitlines()
1515

16-
exec(open("src/fosslight_dependency/_version.py").read())
1716

1817
if __name__ == "__main__":
1918
setup(
2019
name='fosslight_dependency',
21-
version=__version__,
20+
version='3.3.0',
2221
package_dir={"": "src"},
2322
packages=find_packages(where='src'),
2423
description='FOSSLight Dependency Scanner',

src/fosslight_dependency/_help.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Optional
2323
-h\t\t\t\t Print help message.
2424
-v\t\t\t\t Print the version of the script.
25-
-m <package_manager>\t Enther the package manager(npm, maven, gradle, pip, pub, cocoapods, android).
25+
-m <package_manager>\t Enter the package manager(npm, maven, gradle, pip, pub, cocoapods).
2626
-p <input_path>\t\t Enter the path where the script will be run.
2727
-o <output_path>\t\t Enter the path where the result file will be generated.
2828
@@ -31,10 +31,11 @@
3131
-d <deactivate_cmd>\t\t Virtual environment deactivate command(ex, 'conda deactivate')
3232
3333
Optional only for gradle, maven
34-
-c <dir_name>\t\t Enter the customized build output directory name(default: target)
35-
34+
-c <dir_name>\t\t Enter the customized build output directory name
35+
\t\t-Default name : 'build' for gradle, 'target' for maven
36+
3637
Optional only for android
37-
-n <app_name>\t\t Enter the application directory name where the plugin output file is located(default: app)
38+
-n <app_name>\t\t Enter the application directory name where the plugin output file is located(default: app)
3839
"""
3940

4041

src/fosslight_dependency/analyze_dependency.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
from xml.etree.ElementTree import parse
1717
from bs4 import BeautifulSoup
1818
import yaml
19-
from lastversion import lastversion
20-
from fosslight_util.set_log import init_log
19+
import pkg_resources
2120
from datetime import datetime
21+
from fosslight_util.set_log import init_log, init_log_item
2222
from fosslight_util.write_excel import write_excel_and_csv
23-
from fosslight_dependency._version import __version__
2423
from fosslight_dependency._help import print_help_msg
2524

25+
# Package Name
26+
_PKG_NAME = "fosslight_dependency"
2627

2728
# Check the manifest file
2829
manifest_array = [["pip", "requirements.txt"], ["npm", "package.json"], ["maven", "pom.xml"],
@@ -83,7 +84,8 @@ def parse_option():
8384

8485
# -v option
8586
if args.version:
86-
print(__version__)
87+
cur_version = pkg_resources.get_distribution(_PKG_NAME).version
88+
print("Current version : " + cur_version)
8789
sys.exit(0)
8890

8991
# -m option
@@ -732,9 +734,8 @@ def parse_and_generate_output_gradle(input_fp):
732734

733735

734736
def preprocess_pub_result(input_file):
735-
matched_json = re.findall(r'final ossLicenses = <String, dynamic>({.*});', input_file.read())
736-
737-
if matched_json[0] is not None:
737+
matched_json = re.findall(r'final ossLicenses = <String, dynamic>({[\s\S]*});', input_file.read())
738+
if len(matched_json) > 0:
738739
return matched_json[0]
739740
else:
740741
logger.error("### Error Message ###")
@@ -1016,13 +1017,9 @@ def main():
10161017

10171018
parse_option()
10181019
logger = init_log(os.path.join(OUTPUT_RESULT_DIR, "fosslight_dependency_log_" + start_time + ".txt"), True, 20, 10)
1020+
_result_log = init_log_item(_PKG_NAME)
10191021

1020-
# Check the latest version
1021-
latest_version = lastversion.has_update(repo="fosslight_dependency", at='pip', current_version=__version__)
1022-
if latest_version:
1023-
logger.info('### Version Info ###')
1024-
logger.info('Newer version is available:{}'.format(str(latest_version)))
1025-
logger.info('You can update it with command (\'pip install fosslight_dependency --upgrade\')')
1022+
logger.info("Tool Info : " + _result_log["Tool Info"])
10261023

10271024
# Configure global variables according to package manager.
10281025
try:

tox.ini

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ skipdist = true
77
[testenv]
88
install_command = pip install {opts} {packages}
99
basepython= python3.6
10+
setenv =
11+
PYTHONPATH=.
1012

1113
[pytest]
1214
filterwarnings = ignore::DeprecationWarning
@@ -17,12 +19,17 @@ exclude = .tox/*
1719
ignore = E722
1820

1921
[testenv:test_run]
20-
deps =
21-
-r{toxinidir}/requirements-dev.txt
22+
commands =
23+
fosslight_dependency -h
2224

23-
setenv =
24-
PYTHONPATH=.
25+
[testenv:release]
26+
deps =
27+
-r{toxinidir}/requirements-dev.txt
2528

2629
commands =
27-
fosslight_dependency -h
28-
pytest -v --flake8
30+
fosslight_dependency -h
31+
fosslight_dependency -v
32+
pytest -v --flake8
33+
pyinstaller --onefile cli.py build.spec --additional-hooks-dir=hooks
34+
{toxinidir}/dist/cli -o test_result_cli
35+

0 commit comments

Comments
 (0)