|
6 | 6 | import re |
7 | 7 | import logging |
8 | 8 | import shutil |
9 | | -import json |
10 | 9 | import sys |
11 | 10 | import fosslight_util.constant as constant |
12 | 11 | import urllib.request |
13 | 12 | from yaml import safe_dump |
14 | 13 | from fosslight_util.set_log import init_log |
15 | | -from fosslight_util.spdx_licenses import get_spdx_licenses_json |
| 14 | +from fosslight_util.spdx_licenses import get_spdx_licenses_json, get_license_from_nick |
16 | 15 | from fosslight_util.parsing_yaml import find_sbom_yaml_files, parsing_yml |
17 | 16 | from fosslight_util.output_format import check_output_format |
18 | 17 | from datetime import datetime |
|
30 | 29 | LICENSE_INCLUDE_FILES = ["license", "license.md", "license.txt", "notice"] |
31 | 30 | EXCLUDE_DIR = ["test", "tests", "doc", "docs"] |
32 | 31 | EXCLUDE_PREFIX = ("test", ".", "doc", "__") |
33 | | -RESOURCES_DIR = 'resources' |
34 | | -LICENSES_JSON_FILE = 'convert_license.json' |
35 | 32 | OPENSOURCE_LGE_COM_URL_PREFIX = "https://opensource.lge.com/license/" |
36 | 33 | _result_log = {} |
37 | 34 | spdx_licenses = [] |
38 | 35 |
|
39 | 36 | logger = logging.getLogger(constant.LOGGER_NAME) |
40 | 37 |
|
41 | 38 |
|
42 | | -def get_licenses_from_json(): |
43 | | - licenses = {} |
44 | | - licenses_file = os.path.join(RESOURCES_DIR, LICENSES_JSON_FILE) |
45 | | - |
46 | | - try: |
47 | | - base_dir = sys._MEIPASS |
48 | | - except Exception: |
49 | | - base_dir = os.path.dirname(__file__) |
50 | | - |
51 | | - file_withpath = os.path.join(base_dir, licenses_file) |
52 | | - try: |
53 | | - with open(file_withpath, 'r') as f: |
54 | | - licenses = json.load(f) |
55 | | - except Exception as ex: |
56 | | - dump_error_msg(f"Error to get license from json file : {ex}") |
57 | | - |
58 | | - return licenses |
59 | | - |
60 | | - |
61 | 39 | def check_file_extension(file_list): |
62 | 40 | if file_list != "": |
63 | 41 | for file in file_list: |
@@ -99,7 +77,7 @@ def check_input_license_format(input_license): |
99 | 77 | if input_license.startswith('LicenseRef-'): |
100 | 78 | return input_license |
101 | 79 |
|
102 | | - licensesfromJson = get_licenses_from_json() |
| 80 | + licensesfromJson = get_license_from_nick() |
103 | 81 | if licensesfromJson == "": |
104 | 82 | dump_error_msg(" Error - Return Value to get license from Json is none") |
105 | 83 |
|
|
0 commit comments