fosslight-util 1.4.48__py3-none-any.whl → 2.0.0__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 +18 -11
- fosslight_util/constant.py +11 -0
- fosslight_util/convert_excel_to_yaml.py +1 -1
- fosslight_util/correct.py +47 -91
- fosslight_util/help.py +3 -4
- fosslight_util/oss_item.py +148 -155
- fosslight_util/output_format.py +7 -5
- fosslight_util/parsing_yaml.py +45 -30
- fosslight_util/read_excel.py +29 -35
- fosslight_util/set_log.py +20 -3
- fosslight_util/spdx_licenses.py +2 -1
- fosslight_util/write_excel.py +88 -156
- fosslight_util/write_opossum.py +14 -20
- fosslight_util/write_scancodejson.py +31 -31
- fosslight_util/write_spdx.py +30 -35
- fosslight_util/write_txt.py +2 -1
- fosslight_util/write_yaml.py +43 -54
- {fosslight_util-1.4.48.dist-info → fosslight_util-2.0.0.dist-info}/METADATA +7 -8
- fosslight_util-2.0.0.dist-info/RECORD +31 -0
- {fosslight_util-1.4.48.dist-info → fosslight_util-2.0.0.dist-info}/WHEEL +1 -1
- fosslight_util-1.4.48.dist-info/RECORD +0 -31
- {fosslight_util-1.4.48.dist-info → fosslight_util-2.0.0.dist-info}/LICENSE +0 -0
- {fosslight_util-1.4.48.dist-info → fosslight_util-2.0.0.dist-info}/entry_points.txt +0 -0
- {fosslight_util-1.4.48.dist-info → fosslight_util-2.0.0.dist-info}/top_level.txt +0 -0
fosslight_util/write_yaml.py
CHANGED
|
@@ -2,60 +2,49 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
# Copyright (c) 2022 LG Electronics Inc.
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
|
|
6
5
|
import yaml
|
|
7
6
|
import logging
|
|
8
7
|
import os
|
|
9
|
-
import
|
|
8
|
+
import json
|
|
10
9
|
from pathlib import Path
|
|
11
|
-
|
|
12
|
-
from
|
|
13
|
-
from fosslight_util.write_excel import _EMPTY_ITEM_MSG
|
|
10
|
+
from fosslight_util.constant import LOGGER_NAME, SHEET_NAME_FOR_SCANNER
|
|
11
|
+
from typing import Tuple
|
|
14
12
|
|
|
15
|
-
_logger = logging.getLogger(
|
|
13
|
+
_logger = logging.getLogger(LOGGER_NAME)
|
|
16
14
|
|
|
17
15
|
|
|
18
|
-
def write_yaml(output_file,
|
|
16
|
+
def write_yaml(output_file, scan_item, separate_yaml=False) -> Tuple[bool, str, str]:
|
|
19
17
|
success = True
|
|
20
18
|
error_msg = ""
|
|
21
19
|
output = ""
|
|
22
20
|
|
|
23
21
|
try:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if sheet_name not in constant.supported_sheet_and_scanner.keys():
|
|
37
|
-
continue
|
|
38
|
-
scanner_name = constant.supported_sheet_and_scanner[sheet_name]
|
|
39
|
-
sheet_contents_with_scanner = []
|
|
40
|
-
for i in sheet_contents:
|
|
41
|
-
i.insert(0, scanner_name)
|
|
42
|
-
sheet_contents_with_scanner.append(i)
|
|
43
|
-
if not separate_yaml:
|
|
44
|
-
merge_sheet.extend(sheet_contents_with_scanner)
|
|
45
|
-
else:
|
|
46
|
-
output_file = f'{separate_output_file}_{sheet_name}.yaml'
|
|
47
|
-
convert_sheet_to_yaml(sheet_contents_with_scanner, output_file)
|
|
48
|
-
output_files.append(output_file)
|
|
22
|
+
output_files = []
|
|
23
|
+
output_dir = os.path.dirname(output_file)
|
|
24
|
+
|
|
25
|
+
Path(output_dir).mkdir(parents=True, exist_ok=True)
|
|
26
|
+
if separate_yaml:
|
|
27
|
+
filename = os.path.splitext(os.path.basename(output_file))[0]
|
|
28
|
+
separate_output_file = os.path.join(output_dir, filename)
|
|
29
|
+
|
|
30
|
+
merge_sheet = []
|
|
31
|
+
for scanner_name, _ in scan_item.file_items.items():
|
|
32
|
+
sheet_name = SHEET_NAME_FOR_SCANNER[scanner_name.lower()]
|
|
33
|
+
json_contents = scan_item.get_print_json(scanner_name)
|
|
49
34
|
|
|
50
35
|
if not separate_yaml:
|
|
51
|
-
|
|
36
|
+
merge_sheet.extend(json_contents)
|
|
37
|
+
else:
|
|
38
|
+
output_file = f'{separate_output_file}_{sheet_name}.yaml'
|
|
39
|
+
remove_duplicates_and_dump_yaml(json_contents, output_file)
|
|
52
40
|
output_files.append(output_file)
|
|
53
41
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
if not separate_yaml:
|
|
43
|
+
remove_duplicates_and_dump_yaml(merge_sheet, output_file)
|
|
44
|
+
output_files.append(output_file)
|
|
45
|
+
|
|
46
|
+
if output_files:
|
|
47
|
+
output = ", ".join(output_files)
|
|
59
48
|
except Exception as ex:
|
|
60
49
|
error_msg = str(ex)
|
|
61
50
|
success = False
|
|
@@ -66,37 +55,37 @@ def write_yaml(output_file, sheet_list_origin, separate_yaml=False):
|
|
|
66
55
|
return success, error_msg, output
|
|
67
56
|
|
|
68
57
|
|
|
69
|
-
def
|
|
70
|
-
|
|
58
|
+
def remove_duplicates_and_dump_yaml(json_contents, output_file):
|
|
59
|
+
unique_json_strings = {json.dumps(e, sort_keys=True) for e in json_contents}
|
|
60
|
+
unique_json_contents = [json.loads(e) for e in unique_json_strings]
|
|
71
61
|
|
|
72
62
|
yaml_dict = {}
|
|
73
|
-
for
|
|
74
|
-
|
|
75
|
-
item.set_sheet_item(sheet_item[1:], sheet_item[0])
|
|
76
|
-
create_yaml_with_ossitem(item, yaml_dict)
|
|
63
|
+
for uitem in unique_json_contents:
|
|
64
|
+
create_yaml_with_ossitem(uitem, yaml_dict)
|
|
77
65
|
|
|
78
66
|
with open(output_file, 'w') as f:
|
|
79
67
|
yaml.dump(yaml_dict, f, default_flow_style=False, sort_keys=False)
|
|
80
68
|
|
|
81
69
|
|
|
82
70
|
def create_yaml_with_ossitem(item, yaml_dict):
|
|
83
|
-
|
|
84
|
-
item_name = item_json.pop("name")
|
|
71
|
+
item_name = item.pop("name")
|
|
85
72
|
|
|
86
73
|
if item_name not in yaml_dict.keys():
|
|
87
74
|
yaml_dict[item_name] = []
|
|
88
75
|
merged = False
|
|
89
76
|
for oss_info in yaml_dict[item_name]:
|
|
90
|
-
if oss_info.get('version', '') == item.version and \
|
|
91
|
-
oss_info.get('license', []) == item.license and \
|
|
92
|
-
oss_info.get('copyright text', '') == item.copyright and \
|
|
93
|
-
oss_info.get('homepage', '') == item.homepage and \
|
|
94
|
-
oss_info.get('download location', '') == item.
|
|
95
|
-
oss_info.get('exclude', False) == item.exclude:
|
|
96
|
-
oss_info.get('source path', [])
|
|
77
|
+
if oss_info.get('version', '') == item.get('version', '') and \
|
|
78
|
+
oss_info.get('license', []) == item.get('license', []) and \
|
|
79
|
+
oss_info.get('copyright text', '') == item.get('copyright text', '') and \
|
|
80
|
+
oss_info.get('homepage', '') == item.get('homepage', '') and \
|
|
81
|
+
oss_info.get('download location', '') == item.get('download location', '') and \
|
|
82
|
+
oss_info.get('exclude', False) == item.get('exclude', False):
|
|
83
|
+
if isinstance(oss_info.get('source path', []), str):
|
|
84
|
+
oss_info['source path'] = [oss_info.get('source path', '')]
|
|
85
|
+
oss_info.get('source path', []).append(item.get('source path', ''))
|
|
97
86
|
oss_info.pop('comment', None)
|
|
98
87
|
merged = True
|
|
99
88
|
break
|
|
100
89
|
|
|
101
90
|
if not merged:
|
|
102
|
-
yaml_dict[item_name].append(
|
|
91
|
+
yaml_dict[item_name].append(item)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fosslight-util
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: FOSSLight Util
|
|
5
5
|
Home-page: https://github.com/fosslight/fosslight_util
|
|
6
6
|
Author: LG Electronics
|
|
@@ -18,7 +18,6 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
Requires-Dist: XlsxWriter
|
|
20
20
|
Requires-Dist: pandas
|
|
21
|
-
Requires-Dist: xlrd ==1.2.0
|
|
22
21
|
Requires-Dist: openpyxl
|
|
23
22
|
Requires-Dist: progress
|
|
24
23
|
Requires-Dist: PyYAML
|
|
@@ -27,14 +26,14 @@ Requires-Dist: coloredlogs
|
|
|
27
26
|
Requires-Dist: python3-wget
|
|
28
27
|
Requires-Dist: beautifulsoup4
|
|
29
28
|
Requires-Dist: jsonmerge
|
|
30
|
-
Requires-Dist: spdx-tools
|
|
31
|
-
Requires-Dist: setuptools
|
|
29
|
+
Requires-Dist: spdx-tools==0.7.0rc0
|
|
30
|
+
Requires-Dist: setuptools>=65.5.1
|
|
32
31
|
Requires-Dist: npm
|
|
33
32
|
Requires-Dist: requests
|
|
34
|
-
Requires-Dist: numpy
|
|
35
|
-
Requires-Dist: numpy
|
|
36
|
-
Requires-Dist: pygit2
|
|
37
|
-
Requires-Dist: pygit2
|
|
33
|
+
Requires-Dist: numpy; python_version < "3.8"
|
|
34
|
+
Requires-Dist: numpy>=1.22.2; python_version >= "3.8"
|
|
35
|
+
Requires-Dist: pygit2==1.6.1; python_version < "3.7"
|
|
36
|
+
Requires-Dist: pygit2>=1.10.1; python_version >= "3.7"
|
|
38
37
|
|
|
39
38
|
<!--
|
|
40
39
|
Copyright (c) 2021 LG Electronics
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
fosslight_util/_get_downloadable_url.py,sha256=63ZPI4KCpUFgL4oheKm8zvekuCRzpwNkVaLJcA-uA90,9010
|
|
3
|
+
fosslight_util/compare_yaml.py,sha256=znKz8sp6dk9wwBkJl-MQmkKTmL1IKNOrBWZklW7QVtU,2790
|
|
4
|
+
fosslight_util/constant.py,sha256=Ig3ACm9_QirE4389Wt-IfxOqRkVOUjqGnX1B05z2Byo,2151
|
|
5
|
+
fosslight_util/convert_excel_to_yaml.py,sha256=OJ11av4bsoxnVS15aa2aX-X3zGYUZW6M3118TPtHHTc,2323
|
|
6
|
+
fosslight_util/correct.py,sha256=3iUipan8ZX8sbyIIGAPtMkAGvZ4YucjeJwx1K1Bx_z4,3897
|
|
7
|
+
fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
|
|
8
|
+
fosslight_util/download.py,sha256=X-R2RTWwmhx_LSIBZhIxzPTJZ2GwasZnhIsZ5m3hUig,14997
|
|
9
|
+
fosslight_util/help.py,sha256=M3_XahUkP794US9Q0NS6ujmGvrFFnKBHsTU95Fg1KpA,2181
|
|
10
|
+
fosslight_util/oss_item.py,sha256=TlTxBS98_eTOrZ1GifyTgi3lrUHa7edqVbgR4_8rGKw,6324
|
|
11
|
+
fosslight_util/output_format.py,sha256=9O2IdhO3GRmrLvicvED-OXH1jPQpxXcLdwRm_lBo0rI,4983
|
|
12
|
+
fosslight_util/parsing_yaml.py,sha256=2zx_N5lMkXT1dRmfJMpzlrru-y_2F_CkVbGlba6vQpU,5380
|
|
13
|
+
fosslight_util/read_excel.py,sha256=-QvrdxaNqYOpIm1H7ZqIEh5NLvFPymZo6BAOZcQmQug,5263
|
|
14
|
+
fosslight_util/set_log.py,sha256=Xpa94AiOyGEK8ucaYkvkAllvlen1Pq_d6UG6kPYBYBc,3780
|
|
15
|
+
fosslight_util/spdx_licenses.py,sha256=GvMNe_D4v2meapTVwPu2BJXInnTo3_gIzg669eJhUu0,3691
|
|
16
|
+
fosslight_util/timer_thread.py,sha256=5VbZENQPD-N0NUmzEktqGr6Am-e7vxD79K05mmr29g0,433
|
|
17
|
+
fosslight_util/write_excel.py,sha256=G0fIslbWoOtWZCJxbBGLCpUKbhmwrrqhI5PHwRw8_44,9931
|
|
18
|
+
fosslight_util/write_opossum.py,sha256=ltmo6SkugKWdAYupeCqwE4-3lua0GwLpix1XqFC-tT8,11678
|
|
19
|
+
fosslight_util/write_scancodejson.py,sha256=81n7cWNYoyIKE_V4Kx5YtL2CgjMPIjoKdnSU3inkpJY,2163
|
|
20
|
+
fosslight_util/write_spdx.py,sha256=MwR_OO9ua1Uvnk77etJXMHFUqnku2sZuuALdeIp7g4k,9478
|
|
21
|
+
fosslight_util/write_txt.py,sha256=BEFjYBppqk1CITx-fUN4vfvKv0XCs1GXWtc2Iu-etU4,629
|
|
22
|
+
fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,3238
|
|
23
|
+
fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
|
|
24
|
+
fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
|
|
25
|
+
fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
|
|
26
|
+
fosslight_util-2.0.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
27
|
+
fosslight_util-2.0.0.dist-info/METADATA,sha256=GhApxdXkZnaERDjLepsy2WKvV1sJdt9B4FydaZqlHAk,6384
|
|
28
|
+
fosslight_util-2.0.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
29
|
+
fosslight_util-2.0.0.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
|
|
30
|
+
fosslight_util-2.0.0.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
|
|
31
|
+
fosslight_util-2.0.0.dist-info/RECORD,,
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
fosslight_util/_get_downloadable_url.py,sha256=63ZPI4KCpUFgL4oheKm8zvekuCRzpwNkVaLJcA-uA90,9010
|
|
3
|
-
fosslight_util/compare_yaml.py,sha256=0bapoyS0yrzkiK70K57E8-3wZ_D6mZAJ-24Eq9TYBlk,2632
|
|
4
|
-
fosslight_util/constant.py,sha256=j9uhncoC2Fn4j4ATNsjUoS91nVXhyGzU6xLyWFj941A,1834
|
|
5
|
-
fosslight_util/convert_excel_to_yaml.py,sha256=7ZsAMMQJIEXrmcl_28nSHvFpGMi1ZiRZYpEfI5O8vP8,2298
|
|
6
|
-
fosslight_util/correct.py,sha256=O8c4vIl5Hdc46Ijr63LfcTjIZE5fgqN2iKRadHqluUU,6253
|
|
7
|
-
fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
|
|
8
|
-
fosslight_util/download.py,sha256=X-R2RTWwmhx_LSIBZhIxzPTJZ2GwasZnhIsZ5m3hUig,14997
|
|
9
|
-
fosslight_util/help.py,sha256=xhAf43fuRLOU3TE7jqaxVTizVn4aANDvHaHYQAdaqYc,2154
|
|
10
|
-
fosslight_util/oss_item.py,sha256=Wc2ka8cZc3D9JiJXl4-Y69A_qcGuyMiyYq053Srq638,7267
|
|
11
|
-
fosslight_util/output_format.py,sha256=ltHniHwu9y0i-OV-Go1tWiqJBAnWgiVMlLV_cd_Ymlg,4907
|
|
12
|
-
fosslight_util/parsing_yaml.py,sha256=m1kg6sYBJTmLmobsD-fjFxOz2NuIVjUvoEvXxmvBOpU,4561
|
|
13
|
-
fosslight_util/read_excel.py,sha256=3zW2F6Azj4ufsrStBQGArBDCLG-BTJGG54HIqMxlx_A,5392
|
|
14
|
-
fosslight_util/set_log.py,sha256=GsUtbtqmYKgBltHzeaxV3H9gaUWMYQYDJEhr_LdEGoo,3258
|
|
15
|
-
fosslight_util/spdx_licenses.py,sha256=r90hUY4_T-XrHIJHLx1Ox3gWZ3qzdZj9rJFo7AwmkPE,3641
|
|
16
|
-
fosslight_util/timer_thread.py,sha256=5VbZENQPD-N0NUmzEktqGr6Am-e7vxD79K05mmr29g0,433
|
|
17
|
-
fosslight_util/write_excel.py,sha256=na3XB_rIr9ekCugGUMCE-AqrndCbvqhmzhoCO0pZRJk,12298
|
|
18
|
-
fosslight_util/write_opossum.py,sha256=PGJV5DysNJvIFbzsyGXxh_kRcvZuHAOmLs-WlXP8qMI,11831
|
|
19
|
-
fosslight_util/write_scancodejson.py,sha256=CSKjuwbA04nK5ogXklNsCBgGDZXPr805T8KPLgvx71U,2282
|
|
20
|
-
fosslight_util/write_spdx.py,sha256=B_aHv9vScgZI5gHo5Hd56ckNWOHdyAQebRV54bTx9ec,9542
|
|
21
|
-
fosslight_util/write_txt.py,sha256=Ms8E2wbc0U84IYP0dxTAbIfX5PzpQG3xblu8lv1w8J0,574
|
|
22
|
-
fosslight_util/write_yaml.py,sha256=nzuIPdjOAOM4NS5VtU-KFrft41fKEF05-cl0OlEHj7Y,3657
|
|
23
|
-
fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
|
|
24
|
-
fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
|
|
25
|
-
fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
|
|
26
|
-
fosslight_util-1.4.48.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
27
|
-
fosslight_util-1.4.48.dist-info/METADATA,sha256=U88pKw2oNZkRupvkU6Gwn2txiPm7yI1sGI1L0GdWrQA,6418
|
|
28
|
-
fosslight_util-1.4.48.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
29
|
-
fosslight_util-1.4.48.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
|
|
30
|
-
fosslight_util-1.4.48.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
|
|
31
|
-
fosslight_util-1.4.48.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|