fosslight-util 2.0.2__py3-none-any.whl → 2.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fosslight_util/compare_yaml.py +3 -1
- fosslight_util/oss_item.py +17 -0
- fosslight_util/output_format.py +4 -4
- fosslight_util/write_spdx.py +9 -0
- {fosslight_util-2.0.2.dist-info → fosslight_util-2.1.1.dist-info}/METADATA +2 -2
- {fosslight_util-2.0.2.dist-info → fosslight_util-2.1.1.dist-info}/RECORD +10 -11
- fosslight_util/convert_excel_to_yaml.py +0 -69
- {fosslight_util-2.0.2.dist-info → fosslight_util-2.1.1.dist-info}/LICENSE +0 -0
- {fosslight_util-2.0.2.dist-info → fosslight_util-2.1.1.dist-info}/WHEEL +0 -0
- {fosslight_util-2.0.2.dist-info → fosslight_util-2.1.1.dist-info}/entry_points.txt +0 -0
- {fosslight_util-2.0.2.dist-info → fosslight_util-2.1.1.dist-info}/top_level.txt +0 -0
fosslight_util/compare_yaml.py
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
6
6
|
import logging
|
|
7
|
+
from typing import List, Dict
|
|
7
8
|
from fosslight_util.constant import LOGGER_NAME
|
|
9
|
+
from fosslight_util.oss_item import FileItem
|
|
8
10
|
|
|
9
11
|
logger = logging.getLogger(LOGGER_NAME)
|
|
10
12
|
VERSION = 'version'
|
|
@@ -12,7 +14,7 @@ LICENSE = 'license'
|
|
|
12
14
|
NAME = 'name'
|
|
13
15
|
|
|
14
16
|
|
|
15
|
-
def compare_yaml(before_fileitems, after_fileitems):
|
|
17
|
+
def compare_yaml(before_fileitems: List[FileItem], after_fileitems: List[FileItem]) -> Dict[str, List]:
|
|
16
18
|
bf_raw = []
|
|
17
19
|
af_raw = []
|
|
18
20
|
for bf in before_fileitems:
|
fosslight_util/oss_item.py
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import logging
|
|
7
7
|
import os
|
|
8
|
+
import hashlib
|
|
8
9
|
from fosslight_util.constant import LOGGER_NAME, FOSSLIGHT_SCANNER
|
|
9
10
|
from fosslight_util.cover import CoverItem
|
|
10
11
|
from typing import List, Dict
|
|
@@ -171,6 +172,22 @@ class FileItem:
|
|
|
171
172
|
return items
|
|
172
173
|
|
|
173
174
|
|
|
175
|
+
def get_checksum_sha1(source_name_or_path) -> str:
|
|
176
|
+
checksum = CHECKSUM_NULL
|
|
177
|
+
try:
|
|
178
|
+
checksum = str(hashlib.sha1(source_name_or_path.encode()).hexdigest())
|
|
179
|
+
except Exception:
|
|
180
|
+
try:
|
|
181
|
+
f = open(source_name_or_path, "rb")
|
|
182
|
+
byte = f.read()
|
|
183
|
+
checksum = str(hashlib.sha1(byte).hexdigest())
|
|
184
|
+
f.close()
|
|
185
|
+
except Exception as ex:
|
|
186
|
+
_logger.info(f"(Error) Get_checksum: {ex}")
|
|
187
|
+
|
|
188
|
+
return checksum
|
|
189
|
+
|
|
190
|
+
|
|
174
191
|
def invalid(cmd):
|
|
175
192
|
_logger.info('[{}] is invalid'.format(cmd))
|
|
176
193
|
|
fosslight_util/output_format.py
CHANGED
|
@@ -183,11 +183,11 @@ def write_output_file(output_file_without_ext: str, file_extension: str, scan_it
|
|
|
183
183
|
elif format == 'yaml':
|
|
184
184
|
success, msg, _ = write_yaml(result_file, scan_item, False)
|
|
185
185
|
elif format.startswith('spdx'):
|
|
186
|
-
if platform.system()
|
|
187
|
-
success, msg, _ = write_spdx(output_file_without_ext, file_extension, scan_item, spdx_version)
|
|
188
|
-
else:
|
|
186
|
+
if platform.system() == 'Windows' or platform.system() == 'Darwin':
|
|
189
187
|
success = False
|
|
190
|
-
msg = '
|
|
188
|
+
msg = f'{platform.system()} not support spdx format.'
|
|
189
|
+
else:
|
|
190
|
+
success, msg, _ = write_spdx(output_file_without_ext, file_extension, scan_item, spdx_version)
|
|
191
191
|
else:
|
|
192
192
|
if file_extension == '.xlsx':
|
|
193
193
|
success, msg = write_result_to_excel(result_file, scan_item, extended_header, hide_header)
|
fosslight_util/write_spdx.py
CHANGED
|
@@ -12,6 +12,7 @@ from datetime import datetime
|
|
|
12
12
|
from fosslight_util.spdx_licenses import get_spdx_licenses_json, get_license_from_nick
|
|
13
13
|
from fosslight_util.constant import (LOGGER_NAME, FOSSLIGHT_DEPENDENCY, FOSSLIGHT_SCANNER,
|
|
14
14
|
FOSSLIGHT_BINARY, FOSSLIGHT_SOURCE)
|
|
15
|
+
from fosslight_util.oss_item import CHECKSUM_NULL, get_checksum_sha1
|
|
15
16
|
import traceback
|
|
16
17
|
|
|
17
18
|
logger = logging.getLogger(LOGGER_NAME)
|
|
@@ -85,6 +86,14 @@ def write_spdx(output_file_without_ext, output_extension, scan_item, spdx_versio
|
|
|
85
86
|
for file_item in file_items:
|
|
86
87
|
file = '' # file의 license, copyright은 oss item에서 append
|
|
87
88
|
if scanner_name in [FOSSLIGHT_BINARY, FOSSLIGHT_SOURCE]:
|
|
89
|
+
if file_item.exclude:
|
|
90
|
+
continue
|
|
91
|
+
if file_item.checksum == CHECKSUM_NULL:
|
|
92
|
+
if os.path.exists(file_item.source_name_or_path):
|
|
93
|
+
file_item.checksum = get_checksum_sha1(file_item.source_name_or_path)
|
|
94
|
+
if file_item.checksum == CHECKSUM_NULL:
|
|
95
|
+
logger.info(f'Failed to get checksum, Skip: {file_item.source_name_or_path}')
|
|
96
|
+
continue
|
|
88
97
|
file_id += 1
|
|
89
98
|
file = File(name=file_item.source_name_or_path,
|
|
90
99
|
spdx_id=f'SPDXRef-File{file_id}',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fosslight-util
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: FOSSLight Util
|
|
5
5
|
Home-page: https://github.com/fosslight/fosslight_util
|
|
6
6
|
Author: LG Electronics
|
|
@@ -34,7 +34,7 @@ Requires-Dist: numpy; python_version < "3.8"
|
|
|
34
34
|
Requires-Dist: numpy>=1.22.2; python_version >= "3.8"
|
|
35
35
|
Requires-Dist: pygit2==1.6.1; python_version < "3.7"
|
|
36
36
|
Requires-Dist: pygit2>=1.10.1; python_version >= "3.7"
|
|
37
|
-
Requires-Dist: spdx-tools
|
|
37
|
+
Requires-Dist: spdx-tools==0.8.*; sys_platform == "linux"
|
|
38
38
|
|
|
39
39
|
<!--
|
|
40
40
|
Copyright (c) 2021 LG Electronics
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
fosslight_util/_get_downloadable_url.py,sha256=63ZPI4KCpUFgL4oheKm8zvekuCRzpwNkVaLJcA-uA90,9010
|
|
3
|
-
fosslight_util/compare_yaml.py,sha256=
|
|
3
|
+
fosslight_util/compare_yaml.py,sha256=eLqqCLgERxRHN5vsnpQVMXIEU862Lx66mD_y4uMgQE4,2916
|
|
4
4
|
fosslight_util/constant.py,sha256=Ig3ACm9_QirE4389Wt-IfxOqRkVOUjqGnX1B05z2Byo,2151
|
|
5
|
-
fosslight_util/convert_excel_to_yaml.py,sha256=OJ11av4bsoxnVS15aa2aX-X3zGYUZW6M3118TPtHHTc,2323
|
|
6
5
|
fosslight_util/correct.py,sha256=3iUipan8ZX8sbyIIGAPtMkAGvZ4YucjeJwx1K1Bx_z4,3897
|
|
7
6
|
fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
|
|
8
7
|
fosslight_util/download.py,sha256=y2WYHUjAUH5kTTDtPrAop9sD1QDWTiGgFdUbNocIuH0,15070
|
|
9
8
|
fosslight_util/help.py,sha256=M3_XahUkP794US9Q0NS6ujmGvrFFnKBHsTU95Fg1KpA,2181
|
|
10
|
-
fosslight_util/oss_item.py,sha256=
|
|
11
|
-
fosslight_util/output_format.py,sha256=
|
|
9
|
+
fosslight_util/oss_item.py,sha256=8W2HlwqGH3l1iPPdvycrRYKsBSBpqAkqYyYtBVPgMtY,6868
|
|
10
|
+
fosslight_util/output_format.py,sha256=o21Vz1VNe9sec2Tb38DykrvzgmcqGG-a1fkm3xe6z8Q,8219
|
|
12
11
|
fosslight_util/parsing_yaml.py,sha256=2zx_N5lMkXT1dRmfJMpzlrru-y_2F_CkVbGlba6vQpU,5380
|
|
13
12
|
fosslight_util/read_excel.py,sha256=-QvrdxaNqYOpIm1H7ZqIEh5NLvFPymZo6BAOZcQmQug,5263
|
|
14
13
|
fosslight_util/set_log.py,sha256=Xpa94AiOyGEK8ucaYkvkAllvlen1Pq_d6UG6kPYBYBc,3780
|
|
@@ -17,15 +16,15 @@ fosslight_util/timer_thread.py,sha256=5VbZENQPD-N0NUmzEktqGr6Am-e7vxD79K05mmr29g
|
|
|
17
16
|
fosslight_util/write_excel.py,sha256=G0fIslbWoOtWZCJxbBGLCpUKbhmwrrqhI5PHwRw8_44,9931
|
|
18
17
|
fosslight_util/write_opossum.py,sha256=ltmo6SkugKWdAYupeCqwE4-3lua0GwLpix1XqFC-tT8,11678
|
|
19
18
|
fosslight_util/write_scancodejson.py,sha256=81n7cWNYoyIKE_V4Kx5YtL2CgjMPIjoKdnSU3inkpJY,2163
|
|
20
|
-
fosslight_util/write_spdx.py,sha256=
|
|
19
|
+
fosslight_util/write_spdx.py,sha256=Ov9jBlfVrkWIymcfAxbupUxDZKfCOZZGOPZ4v-x230M,12108
|
|
21
20
|
fosslight_util/write_txt.py,sha256=BEFjYBppqk1CITx-fUN4vfvKv0XCs1GXWtc2Iu-etU4,629
|
|
22
21
|
fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,3238
|
|
23
22
|
fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
|
|
24
23
|
fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
|
|
25
24
|
fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
|
|
26
|
-
fosslight_util-2.
|
|
27
|
-
fosslight_util-2.
|
|
28
|
-
fosslight_util-2.
|
|
29
|
-
fosslight_util-2.
|
|
30
|
-
fosslight_util-2.
|
|
31
|
-
fosslight_util-2.
|
|
25
|
+
fosslight_util-2.1.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
26
|
+
fosslight_util-2.1.1.dist-info/METADATA,sha256=GeJezINLDPAC-wKuBqNmtucPR1Z1o6UGFKGeHlhOQdI,6431
|
|
27
|
+
fosslight_util-2.1.1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
28
|
+
fosslight_util-2.1.1.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
|
|
29
|
+
fosslight_util-2.1.1.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
|
|
30
|
+
fosslight_util-2.1.1.dist-info/RECORD,,
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# Copyright (c) 2022 LG Electronics Inc.
|
|
4
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
import os
|
|
6
|
-
import sys
|
|
7
|
-
import logging
|
|
8
|
-
import yaml
|
|
9
|
-
import re
|
|
10
|
-
from fosslight_util.constant import LOGGER_NAME
|
|
11
|
-
from fosslight_util.write_yaml import create_yaml_with_ossitem
|
|
12
|
-
from fosslight_util.read_excel import read_oss_report
|
|
13
|
-
|
|
14
|
-
logger = logging.getLogger(LOGGER_NAME)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def find_report_file(path_to_find):
|
|
18
|
-
file_to_find = ["FOSSLight-Report.xlsx", "OSS-Report.xlsx"]
|
|
19
|
-
|
|
20
|
-
try:
|
|
21
|
-
for file in file_to_find:
|
|
22
|
-
file_with_path = os.path.join(path_to_find, file)
|
|
23
|
-
if os.path.isfile(file_with_path):
|
|
24
|
-
return file
|
|
25
|
-
for root, dirs, files in os.walk(path_to_find):
|
|
26
|
-
for file in files:
|
|
27
|
-
file_name = file.lower()
|
|
28
|
-
p = re.compile(r"[\s\S]*OSS[\s\S]*-Report[\s\S]*.xlsx", re.I)
|
|
29
|
-
if p.search(file_name):
|
|
30
|
-
return os.path.join(root, file)
|
|
31
|
-
except Exception as error:
|
|
32
|
-
logger.debug("Find report:"+str(error))
|
|
33
|
-
return ""
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def convert_excel_to_yaml(oss_report_to_read: str, output_file: str, sheet_names: str = "") -> None:
|
|
37
|
-
_file_extension = ".yaml"
|
|
38
|
-
yaml_dict = {}
|
|
39
|
-
|
|
40
|
-
if os.path.isfile(oss_report_to_read):
|
|
41
|
-
try:
|
|
42
|
-
items = read_oss_report(oss_report_to_read, sheet_names)
|
|
43
|
-
for item in items:
|
|
44
|
-
create_yaml_with_ossitem(item, yaml_dict)
|
|
45
|
-
if yaml_dict:
|
|
46
|
-
output_file = output_file if output_file.endswith(_file_extension) else output_file + _file_extension
|
|
47
|
-
success = write_yaml_file(output_file, yaml_dict)
|
|
48
|
-
if success:
|
|
49
|
-
logger.warning(f"Output: {output_file}")
|
|
50
|
-
else:
|
|
51
|
-
logger.error(f"Can't write yaml file : {output_file}")
|
|
52
|
-
sys.exit(1)
|
|
53
|
-
except Exception as error:
|
|
54
|
-
logger.error(f"Convert yaml: {error}")
|
|
55
|
-
else:
|
|
56
|
-
logger.error(f"Can't find a file: {oss_report_to_read}")
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def write_yaml_file(output_file, json_output):
|
|
60
|
-
success = True
|
|
61
|
-
error_msg = ""
|
|
62
|
-
|
|
63
|
-
try:
|
|
64
|
-
with open(output_file, 'w') as f:
|
|
65
|
-
yaml.dump(json_output, f, sort_keys=False)
|
|
66
|
-
except Exception as ex:
|
|
67
|
-
error_msg = str(ex)
|
|
68
|
-
success = False
|
|
69
|
-
return success, error_msg
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|