fosslight-util 2.0.0__py3-none-any.whl → 2.1.28__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.
@@ -8,24 +8,36 @@ import uuid
8
8
  import logging
9
9
  import re
10
10
  from pathlib import Path
11
- from spdx.creationinfo import Tool
12
- from spdx.document import Document
13
- from spdx.package import Package
14
- from spdx.relationship import Relationship
15
- from spdx.license import License, LicenseConjunction
16
- from spdx.utils import SPDXNone
17
- from spdx.utils import NoAssert
18
- from spdx.version import Version
19
- from spdx.writers import json
20
- from spdx.writers import yaml
21
- from spdx.writers import xml
22
- from spdx.writers import tagvalue
11
+ from datetime import datetime
23
12
  from fosslight_util.spdx_licenses import get_spdx_licenses_json, get_license_from_nick
24
- from fosslight_util.constant import LOGGER_NAME, FOSSLIGHT_DEPENDENCY
13
+ from fosslight_util.constant import (LOGGER_NAME, FOSSLIGHT_DEPENDENCY, FOSSLIGHT_SCANNER,
14
+ FOSSLIGHT_BINARY, FOSSLIGHT_SOURCE)
15
+ from fosslight_util.oss_item import CHECKSUM_NULL, get_checksum_sha1
25
16
  import traceback
26
17
 
27
18
  logger = logging.getLogger(LOGGER_NAME)
28
19
 
20
+ try:
21
+ from spdx_tools.common.spdx_licensing import spdx_licensing
22
+ from spdx_tools.spdx.model import (
23
+ Actor,
24
+ ActorType,
25
+ Checksum,
26
+ ChecksumAlgorithm,
27
+ CreationInfo,
28
+ Document,
29
+ File,
30
+ Package,
31
+ Relationship,
32
+ RelationshipType,
33
+ SpdxNoAssertion,
34
+ SpdxNone
35
+ )
36
+ from spdx_tools.spdx.validation.document_validator import validate_full_spdx_document
37
+ from spdx_tools.spdx.writer.write_anything import write_file
38
+ except Exception:
39
+ logger.info('No import spdx-tools')
40
+
29
41
 
30
42
  def get_license_list_version():
31
43
  version = 'N/A'
@@ -37,20 +49,29 @@ def get_license_list_version():
37
49
  return version
38
50
 
39
51
 
40
- def write_spdx(output_file_without_ext, output_extension, scan_item,
41
- scanner_name, scanner_version, spdx_version=(2, 3)):
52
+ def write_spdx(output_file_without_ext, output_extension, scan_item, spdx_version='2.3'):
42
53
  success = True
43
54
  error_msg = ''
44
- if scan_item:
45
- doc = Document(version=Version(*spdx_version),
46
- data_license=License.from_identifier('CC0-1.0'),
47
- namespace=f'http://spdx.org/spdxdocs/{scanner_name.lower()}-{uuid.uuid4()}',
48
- name=f'SPDX Document by {scanner_name.upper()}',
49
- spdx_id='SPDXRef-DOCUMENT')
50
55
 
51
- doc.creation_info.set_created_now()
52
- doc.creation_info.add_creator(Tool(f'{scanner_name.upper()} {scanner_version}'))
53
- doc.creation_info.license_list_version = Version(*tuple(get_license_list_version().split('.')))
56
+ if scan_item:
57
+ try:
58
+ cover_name = scan_item.cover.get_print_json()["Tool information"].split('(').pop(0).strip()
59
+ match = re.search(r"(.+) v([0-9.]+)", cover_name)
60
+ if match:
61
+ scanner_name = match.group(1)
62
+ else:
63
+ scanner_name = FOSSLIGHT_SCANNER
64
+ except Exception:
65
+ cover_name = FOSSLIGHT_SCANNER
66
+ scanner_name = FOSSLIGHT_SCANNER
67
+ creation_info = CreationInfo(spdx_version=f'SPDX-{spdx_version}',
68
+ spdx_id='SPDXRef-DOCUMENT',
69
+ name=f'SPDX Document by {scanner_name.upper()}',
70
+ data_license='CC0-1.0',
71
+ document_namespace=f'http://spdx.org/spdxdocs/{scanner_name.lower()}-{uuid.uuid4()}',
72
+ creators=[Actor(name=cover_name, actor_type=ActorType.TOOL)],
73
+ created=datetime.now())
74
+ doc = Document(creation_info=creation_info)
54
75
 
55
76
  relation_tree = {}
56
77
  spdx_id_packages = []
@@ -58,67 +79,104 @@ def write_spdx(output_file_without_ext, output_extension, scan_item,
58
79
  output_dir = os.path.dirname(output_file_without_ext)
59
80
  Path(output_dir).mkdir(parents=True, exist_ok=True)
60
81
  try:
82
+ file_id = 0
61
83
  package_id = 0
62
84
  root_package = False
63
- for scanner_name, _ in scan_item.file_items.items():
64
- json_contents = scan_item.get_print_json(scanner_name)
65
- for oss_item in json_contents:
66
- package_id += 1
67
- package = Package(spdx_id=f'SPDXRef-{package_id}')
68
-
69
- if oss_item.get('name', '') != '':
70
- package.name = oss_item.get('name', '') # required
71
- else:
72
- package.name = SPDXNone()
73
-
74
- if oss_item.get('version', '') != '':
75
- package.version = oss_item.get('version', '') # no required
76
-
77
- if oss_item.get('download location', '') != '':
78
- package.download_location = oss_item.get('download location', '') # required
79
- else:
80
- package.download_location = SPDXNone()
81
-
82
- if scanner_name == FOSSLIGHT_DEPENDENCY:
83
- package.files_analyzed = False # If omitted, the default value of true is assumed.
84
- else:
85
- package.files_analyzed = True
86
-
87
- if oss_item.get('homepage', '') != '':
88
- package.homepage = oss_item.get('homepage', '') # no required
89
-
90
- if oss_item.get('copyright text', '') != '':
91
- package.cr_text = oss_item.get('copyright text', '') # required
92
- else:
93
- package.cr_text = SPDXNone()
94
- if oss_item.get('license', []) != '':
95
- lic_list = [check_input_license_format(lic.strip()) for lic in oss_item.get('license', [])]
96
- first_lic = License.from_identifier(lic_list.pop(0))
97
- while lic_list:
98
- next_lic = License.from_identifier(lic_list.pop(0))
99
- license_conjunction = LicenseConjunction(first_lic, next_lic)
100
- first_lic = license_conjunction
101
- package.license_declared = first_lic
102
- else:
103
- package.license_declared = NoAssert() # required
104
-
105
- doc.add_package(package)
106
-
107
- if scanner_name == FOSSLIGHT_DEPENDENCY:
108
- purl = oss_item.get('package url', '')
109
- spdx_id_packages.append([purl, package.spdx_id])
110
- comment = oss_item.get('comment', '')
111
- relation_tree[purl] = {}
112
- relation_tree[purl]['id'] = package.spdx_id
113
- relation_tree[purl]['dep'] = []
114
-
115
- if 'root package' in comment.split(','):
116
- root_package = True
117
- relationship = Relationship(f"{doc.spdx_id} DESCRIBES {package.spdx_id}")
118
- doc.add_relationship(relationship)
119
- deps = oss_item.get('depends on', '')
120
- relation_tree[purl]['dep'].extend([di.strip().split('(')[0] for di in deps])
121
- if scanner_name == FOSSLIGHT_DEPENDENCY and len(relation_tree) > 0:
85
+ for scanner_name, file_items in scan_item.file_items.items():
86
+ for file_item in file_items:
87
+ file = '' # file의 license, copyright은 oss item에서 append
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
97
+ file_id += 1
98
+ file = File(name=file_item.source_name_or_path,
99
+ spdx_id=f'SPDXRef-File{file_id}',
100
+ checksums=[Checksum(ChecksumAlgorithm.SHA1, file_item.checksum)])
101
+ file_license = []
102
+ file_copyright = []
103
+ file_comment = []
104
+ for oss_item in file_item.oss_items:
105
+ oss_licenses = []
106
+ declared_oss_licenses = []
107
+ lic_comment = []
108
+ for oi in oss_item.license:
109
+ oi = check_input_license_format(oi)
110
+ try:
111
+ oi_spdx = spdx_licensing.parse(oi, validate=True)
112
+ oss_licenses.append(oi_spdx)
113
+ declared_oss_licenses.append(oi)
114
+ except Exception:
115
+ logger.debug(f'No spdx license name: {oi}')
116
+ lic_comment.append(oi)
117
+ file_comment.append(oi)
118
+ if oss_licenses:
119
+ file_license.extend(oss_licenses)
120
+ if oss_item.copyright != '':
121
+ file_copyright.append(oss_item.copyright)
122
+
123
+ if oss_item.download_location == '':
124
+ if scanner_name == FOSSLIGHT_DEPENDENCY:
125
+ download_location = SpdxNone()
126
+ else:
127
+ continue
128
+ else:
129
+ download_location = oss_item.download_location
130
+ if scanner_name != FOSSLIGHT_DEPENDENCY and oss_item.name == '':
131
+ continue
132
+ package_id += 1
133
+ package = Package(name=oss_item.name,
134
+ spdx_id=f'SPDXRef-Package{package_id}',
135
+ download_location=download_location)
136
+
137
+ if oss_item.version != '':
138
+ package.version = oss_item.version
139
+
140
+ if scanner_name == FOSSLIGHT_DEPENDENCY:
141
+ package.files_analyzed = False # If omitted, the default value of true is assumed.
142
+ else:
143
+ package.files_analyzed = True
144
+ if oss_item.copyright != '':
145
+ package.cr_text = oss_item.copyright
146
+ if oss_item.homepage != '':
147
+ package.homepage = oss_item.homepage
148
+
149
+ if declared_oss_licenses:
150
+ package.license_declared = spdx_licensing.parse(' AND '.join(declared_oss_licenses))
151
+ if lic_comment:
152
+ package.license_comment = ' '.join(lic_comment)
153
+
154
+ doc.packages.append(package)
155
+
156
+ if scanner_name == FOSSLIGHT_DEPENDENCY:
157
+ purl = file_item.purl
158
+ spdx_id_packages.append([purl, package.spdx_id])
159
+ relation_tree[purl] = {}
160
+ relation_tree[purl]['id'] = package.spdx_id
161
+ relation_tree[purl]['dep'] = []
162
+ if 'root package' in oss_item.comment:
163
+ root_package = True
164
+ relationship = Relationship(doc.creation_info.spdx_id,
165
+ RelationshipType.DESCRIBES,
166
+ package.spdx_id)
167
+ doc.relationships.append(relationship)
168
+ relation_tree[purl]['dep'].extend(file_item.depends_on)
169
+
170
+ if scanner_name in [FOSSLIGHT_BINARY, FOSSLIGHT_SOURCE]:
171
+ if file_license:
172
+ file.license_info_in_file = file_license
173
+ if file_copyright:
174
+ file.copyright_text = '\n'.join(file_copyright)
175
+ if file_comment:
176
+ file.license_comment = ' '.join(file_comment)
177
+ doc.files.append(file)
178
+
179
+ if len(doc.packages) > 0:
122
180
  for pkg in relation_tree:
123
181
  if len(relation_tree[pkg]['dep']) > 0:
124
182
  pkg_spdx_id = relation_tree[pkg]['id']
@@ -128,18 +186,18 @@ def write_spdx(output_file_without_ext, output_extension, scan_item,
128
186
  if ans is None:
129
187
  continue
130
188
  rel_pkg_spdx_id = ans[1]
131
- relationship = Relationship(f'{pkg_spdx_id} DEPENDS_ON {rel_pkg_spdx_id}')
132
- doc.add_relationship(relationship)
133
- if not root_package:
134
- root_package = Package(spdx_id='SPDXRef-ROOT-PACKAGE')
135
- root_package.name = 'root package'
136
- root_package.download_location = NoAssert()
137
- root_package.files_analyzed = False
138
- root_package.cr_text = SPDXNone()
139
- root_package.license_declared = NoAssert()
140
- doc.add_package(root_package)
141
- relationship = Relationship(f"{doc.spdx_id} DESCRIBES {root_package.spdx_id}")
142
- doc.add_relationship(relationship)
189
+ relationship = Relationship(pkg_spdx_id, RelationshipType.DEPENDS_ON, rel_pkg_spdx_id)
190
+ doc.relationships.append(relationship)
191
+ if not root_package:
192
+ root_package = Package(name='root package',
193
+ spdx_id='SPDXRef-ROOT-PACKAGE',
194
+ download_location=SpdxNoAssertion())
195
+ root_package.files_analyzed = False
196
+ root_package.license_declared = SpdxNoAssertion()
197
+ doc.packages.append(root_package)
198
+ relationship = Relationship(doc.creation_info.spdx_id, RelationshipType.DESCRIBES, root_package.spdx_id)
199
+ doc.relationships.append(relationship)
200
+
143
201
  except Exception as e:
144
202
  success = False
145
203
  error_msg = f'Failed to create spdx document object:{e}, {traceback.format_exc()}'
@@ -147,24 +205,18 @@ def write_spdx(output_file_without_ext, output_extension, scan_item,
147
205
  success = False
148
206
  error_msg = 'No item to write in output file.'
149
207
 
208
+ validation_messages = validate_full_spdx_document(doc)
209
+ for message in validation_messages:
210
+ logger.warning(message.validation_message)
211
+ logger.warning(message.context)
212
+
213
+ # assert validation_messages == []
214
+
150
215
  result_file = ''
151
216
  if success:
152
217
  result_file = output_file_without_ext + output_extension
153
218
  try:
154
- out_mode = "w"
155
- if result_file.endswith(".tag"):
156
- writer_module = tagvalue
157
- elif result_file.endswith(".json"):
158
- writer_module = json
159
- elif result_file.endswith(".xml"):
160
- writer_module = xml
161
- elif result_file.endswith(".yaml"):
162
- writer_module = yaml
163
- else:
164
- raise Exception("FileType Not Supported")
165
-
166
- with open(result_file, out_mode) as out:
167
- writer_module.write_document(doc, out, True)
219
+ write_file(doc, result_file)
168
220
  except Exception as e:
169
221
  success = False
170
222
  error_msg = f'Failed to write spdx document: {e}'
@@ -1,21 +1,18 @@
1
- Metadata-Version: 2.1
2
- Name: fosslight-util
3
- Version: 2.0.0
1
+ Metadata-Version: 2.4
2
+ Name: fosslight_util
3
+ Version: 2.1.28
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
+ Download-URL: https://github.com/fosslight/fosslight_util
6
7
  Author: LG Electronics
7
8
  License: Apache-2.0
8
- Download-URL: https://github.com/fosslight/fosslight_util
9
- Platform: UNKNOWN
10
9
  Classifier: License :: OSI Approved :: Apache Software License
11
10
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.6
13
- Classifier: Programming Language :: Python :: 3.7
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: Programming Language :: Python :: 3.9
16
11
  Classifier: Programming Language :: Python :: 3.10
17
12
  Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
18
14
  Description-Content-Type: text/markdown
15
+ License-File: LICENSE
19
16
  Requires-Dist: XlsxWriter
20
17
  Requires-Dist: pandas
21
18
  Requires-Dist: openpyxl
@@ -26,14 +23,22 @@ Requires-Dist: coloredlogs
26
23
  Requires-Dist: python3-wget
27
24
  Requires-Dist: beautifulsoup4
28
25
  Requires-Dist: jsonmerge
29
- Requires-Dist: spdx-tools==0.7.0rc0
26
+ Requires-Dist: spdx-tools==0.8.*; sys_platform == "linux"
30
27
  Requires-Dist: setuptools>=65.5.1
31
- Requires-Dist: npm
28
+ Requires-Dist: numpy
32
29
  Requires-Dist: requests
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"
30
+ Requires-Dist: GitPython
31
+ Requires-Dist: cyclonedx-python-lib==8.5.*; sys_platform == "linux"
32
+ Dynamic: author
33
+ Dynamic: classifier
34
+ Dynamic: description
35
+ Dynamic: description-content-type
36
+ Dynamic: download-url
37
+ Dynamic: home-page
38
+ Dynamic: license
39
+ Dynamic: license-file
40
+ Dynamic: requires-dist
41
+ Dynamic: summary
37
42
 
38
43
  <!--
39
44
  Copyright (c) 2021 LG Electronics
@@ -66,7 +71,7 @@ It is a package that supports common utils used by FOSSLight Scanner.
66
71
 
67
72
  ## 📋 Prerequisite
68
73
 
69
- FOSSLight Util needs a Python 3.6+.
74
+ FOSSLight Util needs a Python 3.10+.
70
75
 
71
76
  ## 🎉 How to install
72
77
 
@@ -80,7 +85,7 @@ $ pip3 install fosslight_util
80
85
 
81
86
  Three modules can be called. Please refer to each file for detailed calling method.
82
87
 
83
-
88
+
84
89
  ### 1. Setup logger (tests/test_log.py)
85
90
  ```
86
91
  from fosslight_util.set_log import init_log
@@ -101,7 +106,7 @@ def test():
101
106
  logger.warning("TESTING - Print log")
102
107
  ```
103
108
 
104
-
109
+
105
110
  ### 2. Write result files (tests/test_output_format.py)
106
111
  ```
107
112
  from fosslight_util.output_format import write_output_file
@@ -117,7 +122,7 @@ def test():
117
122
  '0.4.3', 'Apache-2.0', 'https://github.com/jpeddicord/askalono', '', 'Copyright (c) 2018 Amazon.com, Inc. or its affiliates.', '', '']]}
118
123
  success, msg = write_output_file('test_result/excel/FOSSLight-Report', '.xlsx', sheet_contents)
119
124
  ```
120
-
125
+
121
126
  ### 3. Get spdx licenses (tests/test_spdx_licenses.py)
122
127
  ```
123
128
  from fosslight_util.spdx_licenses import get_spdx_licenses_json
@@ -183,5 +188,3 @@ Please report any ideas or bugs to improve by creating an issue in [fosslight_ut
183
188
  FOSSLight Util is released under [Apache-2.0][l].
184
189
 
185
190
  [l]: https://github.com/fosslight/fosslight_util/blob/main/LICENSE
186
-
187
-
@@ -0,0 +1,32 @@
1
+ fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ fosslight_util/_get_downloadable_url.py,sha256=GNfGLJPQVHrU_eYse1flE42AgYUviGNKWZnq9sfUY9c,24473
3
+ fosslight_util/compare_yaml.py,sha256=eLqqCLgERxRHN5vsnpQVMXIEU862Lx66mD_y4uMgQE4,2916
4
+ fosslight_util/constant.py,sha256=3BzJtyxC0o5IFAhYaUW-DeTKkA6f5tDJFJTb0k5ji9Y,2418
5
+ fosslight_util/correct.py,sha256=1WEAL-9_KhjFPLucPhv0PNN3K7avm0z8mU6sTuSyeHM,3864
6
+ fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
7
+ fosslight_util/download.py,sha256=t6-5NAcvCOfmi9TM7O1yp-9X11MiuKd8JdzNEZtEmqQ,20967
8
+ fosslight_util/exclude.py,sha256=fDmBsZJ_F7O9Oh2T-07R03XNbElo1tFaf_z01KfSAqU,2399
9
+ fosslight_util/help.py,sha256=iyWmAaUQSHJtWv5mjFv0f3YoDVlDgEqdsDDEyImEUNc,2646
10
+ fosslight_util/oss_item.py,sha256=8890JHb5ZoKQWAwN7Fl8badnlYatJtF4MVJz1rdS4yQ,6938
11
+ fosslight_util/output_format.py,sha256=BP23LspxawDZ_a99oWLVKWUQ-G7P5uoUpjEXhkRFKwc,8801
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=AbcLFLvY9GSOYSN0a110wO5gNcyc8KKnNjl7GxHEW9A,4008
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_cyclonedx.py,sha256=hq817j-0OM89B8jtZKgHgvVa0YEaYHlz_8R5vNpe21I,9662
18
+ fosslight_util/write_excel.py,sha256=QUIMCnmEKJoSpri5RctBcKLvhDShLdZUP_dhHv-sVy8,10165
19
+ fosslight_util/write_opossum.py,sha256=ltmo6SkugKWdAYupeCqwE4-3lua0GwLpix1XqFC-tT8,11678
20
+ fosslight_util/write_scancodejson.py,sha256=dMCjTtUnNR5BCL6gBCleDT8bTSAN5Gg2RAfimmkGXUE,2692
21
+ fosslight_util/write_spdx.py,sha256=Ov9jBlfVrkWIymcfAxbupUxDZKfCOZZGOPZ4v-x230M,12108
22
+ fosslight_util/write_txt.py,sha256=BEFjYBppqk1CITx-fUN4vfvKv0XCs1GXWtc2Iu-etU4,629
23
+ fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,3238
24
+ fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
25
+ fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
26
+ fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
27
+ fosslight_util-2.1.28.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ fosslight_util-2.1.28.dist-info/METADATA,sha256=9aponw8jVAsmq4_4hIgpvIYCyzSfkDcPR7h9a3tg9mo,6367
29
+ fosslight_util-2.1.28.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
30
+ fosslight_util-2.1.28.dist-info/entry_points.txt,sha256=0yZggRWNwDaClDG8UmUA10UFG8cVX3Jiy5gG9nW7hJs,68
31
+ fosslight_util-2.1.28.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
32
+ fosslight_util-2.1.28.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.44.0)
2
+ Generator: setuptools (79.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  fosslight_download = fosslight_util.download:main
3
-
@@ -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
@@ -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=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,,