fosslight-util 2.1.0__tar.gz → 2.1.2__tar.gz
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-2.1.0 → fosslight_util-2.1.2}/PKG-INFO +1 -1
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/requirements.txt +1 -1
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/setup.py +1 -1
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/compare_yaml.py +3 -1
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/download.py +95 -61
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/output_format.py +14 -14
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util.egg-info/PKG-INFO +1 -1
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util.egg-info/SOURCES.txt +0 -1
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util.egg-info/requires.txt +2 -2
- fosslight_util-2.1.0/src/fosslight_util/convert_excel_to_yaml.py +0 -69
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/LICENSE +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/MANIFEST.in +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/README.md +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/setup.cfg +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/__init__.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/_get_downloadable_url.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/constant.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/correct.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/cover.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/help.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/oss_item.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/parsing_yaml.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/read_excel.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/resources/frequentLicenselist.json +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/resources/frequent_license_nick_list.json +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/resources/licenses.json +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/set_log.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/spdx_licenses.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/timer_thread.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/write_excel.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/write_opossum.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/write_scancodejson.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/write_spdx.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/write_txt.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/write_yaml.py +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util.egg-info/dependency_links.txt +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util.egg-info/entry_points.txt +0 -0
- {fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util.egg-info/top_level.txt +0 -0
|
@@ -8,7 +8,7 @@ coloredlogs
|
|
|
8
8
|
python3-wget
|
|
9
9
|
beautifulsoup4
|
|
10
10
|
jsonmerge
|
|
11
|
-
spdx-tools
|
|
11
|
+
spdx-tools==0.8.*;sys_platform=="linux"
|
|
12
12
|
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
|
|
13
13
|
numpy; python_version < '3.8'
|
|
14
14
|
numpy>=1.22.2; python_version >= '3.8'
|
|
@@ -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:
|
|
@@ -10,7 +10,7 @@ import zipfile
|
|
|
10
10
|
import logging
|
|
11
11
|
import argparse
|
|
12
12
|
import shutil
|
|
13
|
-
from git import Repo, GitCommandError
|
|
13
|
+
from git import Repo, GitCommandError, Git
|
|
14
14
|
import bz2
|
|
15
15
|
import contextlib
|
|
16
16
|
from datetime import datetime
|
|
@@ -77,7 +77,7 @@ def parse_src_link(src_link):
|
|
|
77
77
|
if src_link.startswith("git://github.com/"):
|
|
78
78
|
src_link_changed = change_src_link_to_https(src_link_split[0])
|
|
79
79
|
elif src_link.startswith("git@github.com:"):
|
|
80
|
-
src_link_changed =
|
|
80
|
+
src_link_changed = src_link_split[0]
|
|
81
81
|
else:
|
|
82
82
|
if "rubygems.org" in src_link:
|
|
83
83
|
src_info["rubygems"] = True
|
|
@@ -92,39 +92,9 @@ def parse_src_link(src_link):
|
|
|
92
92
|
return src_info
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
def main():
|
|
96
|
-
parser = argparse.ArgumentParser(description='FOSSLight Downloader', prog='fosslight_download', add_help=False)
|
|
97
|
-
parser.add_argument('-h', '--help', help='Print help message', action='store_true', dest='help')
|
|
98
|
-
parser.add_argument('-s', '--source', help='Source link to download', type=str, dest='source')
|
|
99
|
-
parser.add_argument('-t', '--target_dir', help='Target directory', type=str, dest='target_dir', default="")
|
|
100
|
-
parser.add_argument('-d', '--log_dir', help='Directory to save log file', type=str, dest='log_dir', default="")
|
|
101
|
-
|
|
102
|
-
src_link = ""
|
|
103
|
-
target_dir = os.getcwd()
|
|
104
|
-
log_dir = os.getcwd()
|
|
105
|
-
|
|
106
|
-
try:
|
|
107
|
-
args = parser.parse_args()
|
|
108
|
-
except SystemExit:
|
|
109
|
-
sys.exit(0)
|
|
110
|
-
|
|
111
|
-
if args.help:
|
|
112
|
-
print_help_msg_download()
|
|
113
|
-
if args.source:
|
|
114
|
-
src_link = args.source
|
|
115
|
-
if args.target_dir:
|
|
116
|
-
target_dir = args.target_dir
|
|
117
|
-
if args.log_dir:
|
|
118
|
-
log_dir = args.log_dir
|
|
119
|
-
|
|
120
|
-
if not src_link:
|
|
121
|
-
print_help_msg_download()
|
|
122
|
-
else:
|
|
123
|
-
cli_download_and_extract(src_link, target_dir, log_dir)
|
|
124
|
-
|
|
125
|
-
|
|
126
95
|
def cli_download_and_extract(link: str, target_dir: str, log_dir: str, checkout_to: str = "",
|
|
127
|
-
compressed_only: bool = False
|
|
96
|
+
compressed_only: bool = False, ssh_key: str = "",
|
|
97
|
+
id: str = "", git_token: str = "") -> Tuple[bool, str, str, str]:
|
|
128
98
|
global logger
|
|
129
99
|
|
|
130
100
|
success = True
|
|
@@ -152,7 +122,9 @@ def cli_download_and_extract(link: str, target_dir: str, log_dir: str, checkout_
|
|
|
152
122
|
is_rubygems = src_info.get("rubygems", False)
|
|
153
123
|
|
|
154
124
|
# General download (git clone, wget)
|
|
155
|
-
success_git, msg, oss_name, oss_version = download_git_clone(link, target_dir, checkout_to,
|
|
125
|
+
success_git, msg, oss_name, oss_version = download_git_clone(link, target_dir, checkout_to,
|
|
126
|
+
tag, branch, ssh_key, id, git_token)
|
|
127
|
+
link = change_ssh_link_to_https(link)
|
|
156
128
|
if (not is_rubygems) and (not success_git):
|
|
157
129
|
if os.path.isfile(target_dir):
|
|
158
130
|
shutil.rmtree(target_dir)
|
|
@@ -229,11 +201,38 @@ def get_github_token(git_url):
|
|
|
229
201
|
return github_token
|
|
230
202
|
|
|
231
203
|
|
|
232
|
-
def
|
|
204
|
+
def download_git_repository(refs_to_checkout, git_url, target_dir, tag):
|
|
205
|
+
success = False
|
|
206
|
+
oss_version = ""
|
|
207
|
+
clone_default_branch_flag = False
|
|
208
|
+
|
|
209
|
+
logger.info(f"Download git url :{git_url}")
|
|
210
|
+
if refs_to_checkout:
|
|
211
|
+
try:
|
|
212
|
+
# gitPython uses the branch argument the same whether you check out to a branch or a tag.
|
|
213
|
+
repo = Repo.clone_from(git_url, target_dir, branch=refs_to_checkout)
|
|
214
|
+
success = True
|
|
215
|
+
except GitCommandError as error:
|
|
216
|
+
logger.debug(f"Git checkout error:{error}")
|
|
217
|
+
success = False
|
|
218
|
+
|
|
219
|
+
if not success:
|
|
220
|
+
repo = Repo.clone_from(git_url, target_dir)
|
|
221
|
+
clone_default_branch_flag = True
|
|
222
|
+
success = True
|
|
223
|
+
|
|
224
|
+
if refs_to_checkout != tag or clone_default_branch_flag:
|
|
225
|
+
oss_version = repo.active_branch.name
|
|
226
|
+
else:
|
|
227
|
+
oss_version = repo.git.describe('--tags')
|
|
228
|
+
return success, oss_version
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch="", ssh_key="", id="", git_token=""):
|
|
233
232
|
oss_name = get_github_ossname(git_url)
|
|
234
233
|
refs_to_checkout = decide_checkout(checkout_to, tag, branch)
|
|
235
|
-
clone_default_branch_flag = False
|
|
236
234
|
msg = ""
|
|
235
|
+
success = True
|
|
237
236
|
|
|
238
237
|
try:
|
|
239
238
|
if platform.system() != "Windows":
|
|
@@ -244,36 +243,40 @@ def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch=""):
|
|
|
244
243
|
alarm.start()
|
|
245
244
|
|
|
246
245
|
Path(target_dir).mkdir(parents=True, exist_ok=True)
|
|
247
|
-
if refs_to_checkout != "":
|
|
248
|
-
try:
|
|
249
|
-
# gitPython uses the branch argument the same whether you check out to a branch or a tag.
|
|
250
|
-
repo = Repo.clone_from(git_url, target_dir, branch=refs_to_checkout)
|
|
251
|
-
except GitCommandError as error:
|
|
252
|
-
error_msg = error.args[2].decode("utf-8")
|
|
253
|
-
if "Remote branch " + refs_to_checkout + " not found in upstream origin" in error_msg:
|
|
254
|
-
# clone default branch, when non-existent branch or tag entered
|
|
255
|
-
repo = Repo.clone_from(git_url, target_dir)
|
|
256
|
-
clone_default_branch_flag = True
|
|
257
|
-
else:
|
|
258
|
-
repo = Repo.clone_from(git_url, target_dir)
|
|
259
|
-
clone_default_branch_flag = True
|
|
260
246
|
|
|
261
|
-
if
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
oss_version = repo.git.describe('--tags')
|
|
265
|
-
logger.info(f"git checkout: {oss_version}")
|
|
266
|
-
|
|
267
|
-
if platform.system() != "Windows":
|
|
268
|
-
signal.alarm(0)
|
|
247
|
+
if git_url.startswith("ssh:") and not ssh_key:
|
|
248
|
+
msg = "Private git needs ssh_key"
|
|
249
|
+
success = False
|
|
269
250
|
else:
|
|
270
|
-
|
|
251
|
+
if ssh_key:
|
|
252
|
+
logger.info(f"Download git with ssh_key:{git_url}")
|
|
253
|
+
git_ssh_cmd = f'ssh -i {ssh_key}'
|
|
254
|
+
with Git().custom_environment(GIT_SSH_COMMAND=git_ssh_cmd):
|
|
255
|
+
success, oss_version = download_git_repository(refs_to_checkout, git_url, target_dir, tag)
|
|
256
|
+
else:
|
|
257
|
+
if id and git_token:
|
|
258
|
+
try:
|
|
259
|
+
m = re.match(r"^(ht|f)tp(s?)\:\/\/", git_url)
|
|
260
|
+
protocol = m.group()
|
|
261
|
+
if protocol:
|
|
262
|
+
git_url = git_url.replace(protocol, f"{protocol}{id}:{git_token}@")
|
|
263
|
+
except Exception as error:
|
|
264
|
+
logger.info(f"Failed to insert id, token to git url:{error}")
|
|
265
|
+
success, oss_version = download_git_repository(refs_to_checkout, git_url, target_dir, tag)
|
|
266
|
+
|
|
267
|
+
logger.info(f"git checkout: {oss_version}")
|
|
268
|
+
refs_to_checkout = oss_version
|
|
269
|
+
|
|
270
|
+
if platform.system() != "Windows":
|
|
271
|
+
signal.alarm(0)
|
|
272
|
+
else:
|
|
273
|
+
del alarm
|
|
271
274
|
except Exception as error:
|
|
275
|
+
success = False
|
|
272
276
|
logger.warning(f"git clone - failed: {error}")
|
|
273
277
|
msg = str(error)
|
|
274
|
-
return False, msg, oss_name, refs_to_checkout
|
|
275
278
|
|
|
276
|
-
return
|
|
279
|
+
return success, msg, oss_name, refs_to_checkout
|
|
277
280
|
|
|
278
281
|
|
|
279
282
|
def download_wget(link, target_dir, compressed_only):
|
|
@@ -444,5 +447,36 @@ def gem_download(link, target_dir, checkout_to):
|
|
|
444
447
|
return success
|
|
445
448
|
|
|
446
449
|
|
|
450
|
+
def main():
|
|
451
|
+
parser = argparse.ArgumentParser(description='FOSSLight Downloader', prog='fosslight_download', add_help=False)
|
|
452
|
+
parser.add_argument('-h', '--help', help='Print help message', action='store_true', dest='help')
|
|
453
|
+
parser.add_argument('-s', '--source', help='Source link to download', type=str, dest='source')
|
|
454
|
+
parser.add_argument('-t', '--target_dir', help='Target directory', type=str, dest='target_dir', default="")
|
|
455
|
+
parser.add_argument('-d', '--log_dir', help='Directory to save log file', type=str, dest='log_dir', default="")
|
|
456
|
+
|
|
457
|
+
src_link = ""
|
|
458
|
+
target_dir = os.getcwd()
|
|
459
|
+
log_dir = os.getcwd()
|
|
460
|
+
|
|
461
|
+
try:
|
|
462
|
+
args = parser.parse_args()
|
|
463
|
+
except SystemExit:
|
|
464
|
+
sys.exit(0)
|
|
465
|
+
|
|
466
|
+
if args.help:
|
|
467
|
+
print_help_msg_download()
|
|
468
|
+
if args.source:
|
|
469
|
+
src_link = args.source
|
|
470
|
+
if args.target_dir:
|
|
471
|
+
target_dir = args.target_dir
|
|
472
|
+
if args.log_dir:
|
|
473
|
+
log_dir = args.log_dir
|
|
474
|
+
|
|
475
|
+
if not src_link:
|
|
476
|
+
print_help_msg_download()
|
|
477
|
+
else:
|
|
478
|
+
cli_download_and_extract(src_link, target_dir, log_dir)
|
|
479
|
+
|
|
480
|
+
|
|
447
481
|
if __name__ == '__main__':
|
|
448
482
|
main()
|
|
@@ -31,7 +31,7 @@ def check_output_format(output='', format='', customized_format={}):
|
|
|
31
31
|
format = format.lower()
|
|
32
32
|
if format not in list(support_format.keys()):
|
|
33
33
|
success = False
|
|
34
|
-
msg = 'Enter the supported format
|
|
34
|
+
msg = '(-f option) Enter the supported format: ' + ', '.join(list(support_format.keys()))
|
|
35
35
|
else:
|
|
36
36
|
output_extension = support_format[format]
|
|
37
37
|
|
|
@@ -47,11 +47,11 @@ def check_output_format(output='', format='', customized_format={}):
|
|
|
47
47
|
if format:
|
|
48
48
|
if output_extension != basename_extension:
|
|
49
49
|
success = False
|
|
50
|
-
msg = f"Enter the same extension of output file(-o:'{output}') with format(-f:'{format}')."
|
|
50
|
+
msg = f"(-o & -f option) Enter the same extension of output file(-o:'{output}') with format(-f:'{format}')."
|
|
51
51
|
else:
|
|
52
52
|
if basename_extension not in support_format.values():
|
|
53
53
|
success = False
|
|
54
|
-
msg = 'Enter the supported file extension: ' + ', '.join(list(support_format.values()))
|
|
54
|
+
msg = '(-o option) Enter the supported file extension: ' + ', '.join(list(support_format.values()))
|
|
55
55
|
if success:
|
|
56
56
|
output_file = basename_file
|
|
57
57
|
output_extension = basename_extension
|
|
@@ -79,7 +79,7 @@ def check_output_formats(output='', formats=[], customized_format={}):
|
|
|
79
79
|
for format in formats:
|
|
80
80
|
if format not in list(support_format.keys()):
|
|
81
81
|
success = False
|
|
82
|
-
msg = 'Enter the supported format
|
|
82
|
+
msg = '(-f option) Enter the supported format: ' + ', '.join(list(support_format.keys()))
|
|
83
83
|
else:
|
|
84
84
|
output_extensions.append(support_format[format])
|
|
85
85
|
|
|
@@ -95,11 +95,11 @@ def check_output_formats(output='', formats=[], customized_format={}):
|
|
|
95
95
|
if formats:
|
|
96
96
|
if basename_extension not in output_extensions:
|
|
97
97
|
success = False
|
|
98
|
-
msg = f"The format of output file(-o:'{output}') should be in the format list(-f:'{formats}')."
|
|
98
|
+
msg = f"(-o & -f option) The format of output file(-o:'{output}') should be in the format list(-f:'{formats}')."
|
|
99
99
|
else:
|
|
100
100
|
if basename_extension not in support_format.values():
|
|
101
101
|
success = False
|
|
102
|
-
msg = 'Enter the supported file extension: ' + ', '.join(list(support_format.values()))
|
|
102
|
+
msg = '(-o option) Enter the supported file extension: ' + ', '.join(list(support_format.values()))
|
|
103
103
|
output_extensions.append(basename_extension)
|
|
104
104
|
output_files = [basename_file for _ in range(len(output_extensions))]
|
|
105
105
|
else:
|
|
@@ -128,7 +128,7 @@ def check_output_formats_v2(output='', formats=[], customized_format={}):
|
|
|
128
128
|
for format in formats:
|
|
129
129
|
if format not in list(support_format.keys()):
|
|
130
130
|
success = False
|
|
131
|
-
msg = 'Enter the supported format with -f option: ' + ', '.join(list(support_format.keys()))
|
|
131
|
+
msg = '(-f option) Enter the supported format with -f option: ' + ', '.join(list(support_format.keys()))
|
|
132
132
|
else:
|
|
133
133
|
output_extensions.append(support_format[format])
|
|
134
134
|
|
|
@@ -144,11 +144,11 @@ def check_output_formats_v2(output='', formats=[], customized_format={}):
|
|
|
144
144
|
if formats:
|
|
145
145
|
if basename_extension not in output_extensions:
|
|
146
146
|
success = False
|
|
147
|
-
msg = f"The format of output file(-o:'{output}') should be in the format list(-f:'{formats}')."
|
|
147
|
+
msg = f"(-o & -f option) The format of output file(-o:'{output}') should be in the format list(-f:'{formats}')."
|
|
148
148
|
else:
|
|
149
149
|
if basename_extension not in support_format.values():
|
|
150
150
|
success = False
|
|
151
|
-
msg = 'Enter the supported file extension: ' + ', '.join(list(support_format.values()))
|
|
151
|
+
msg = '(-o option) Enter the supported file extension: ' + ', '.join(list(support_format.values()))
|
|
152
152
|
output_extensions.append(basename_extension)
|
|
153
153
|
output_files = [basename_file for _ in range(len(output_extensions))]
|
|
154
154
|
else:
|
|
@@ -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)
|
|
@@ -199,6 +199,6 @@ def write_output_file(output_file_without_ext: str, file_extension: str, scan_it
|
|
|
199
199
|
success, msg, result_file = write_yaml(result_file, scan_item, False)
|
|
200
200
|
else:
|
|
201
201
|
success = False
|
|
202
|
-
msg = f'Not supported file extension({file_extension})'
|
|
202
|
+
msg = f'(-f option) Not supported file extension({file_extension})'
|
|
203
203
|
|
|
204
204
|
return success, msg, result_file
|
|
@@ -7,7 +7,6 @@ src/fosslight_util/__init__.py
|
|
|
7
7
|
src/fosslight_util/_get_downloadable_url.py
|
|
8
8
|
src/fosslight_util/compare_yaml.py
|
|
9
9
|
src/fosslight_util/constant.py
|
|
10
|
-
src/fosslight_util/convert_excel_to_yaml.py
|
|
11
10
|
src/fosslight_util/correct.py
|
|
12
11
|
src/fosslight_util/cover.py
|
|
13
12
|
src/fosslight_util/download.py
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util/resources/frequentLicenselist.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_util-2.1.0 → fosslight_util-2.1.2}/src/fosslight_util.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|