fosslight-util 2.1.20__tar.gz → 2.1.22__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.20 → fosslight_util-2.1.22}/PKG-INFO +1 -1
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/setup.py +1 -1
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/_get_downloadable_url.py +27 -17
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/download.py +34 -5
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/help.py +6 -1
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util.egg-info/PKG-INFO +1 -1
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/LICENSE +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/MANIFEST.in +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/README.md +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/requirements.txt +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/setup.cfg +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/__init__.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/compare_yaml.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/constant.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/correct.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/cover.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/exclude.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/oss_item.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/output_format.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/parsing_yaml.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/read_excel.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/resources/frequentLicenselist.json +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/resources/frequent_license_nick_list.json +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/resources/licenses.json +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/set_log.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/spdx_licenses.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/timer_thread.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/write_cyclonedx.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/write_excel.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/write_opossum.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/write_scancodejson.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/write_spdx.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/write_txt.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util/write_yaml.py +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util.egg-info/SOURCES.txt +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util.egg-info/dependency_links.txt +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util.egg-info/entry_points.txt +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util.egg-info/requires.txt +0 -0
- {fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util.egg-info/top_level.txt +0 -0
|
@@ -13,7 +13,7 @@ import fosslight_util.constant as constant
|
|
|
13
13
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
def extract_name_version_from_link(link):
|
|
16
|
+
def extract_name_version_from_link(link, checkout_version):
|
|
17
17
|
oss_name = ""
|
|
18
18
|
oss_version = ""
|
|
19
19
|
matched = False
|
|
@@ -53,8 +53,12 @@ def extract_name_version_from_link(link):
|
|
|
53
53
|
except Exception as ex:
|
|
54
54
|
logger.info(f"extract_name_version_from_link {key}:{ex}")
|
|
55
55
|
if oss_name and (not oss_version):
|
|
56
|
-
if
|
|
57
|
-
oss_version
|
|
56
|
+
if checkout_version:
|
|
57
|
+
oss_version = checkout_version
|
|
58
|
+
elif key in ["pypi", "maven", "npm", "npm2", "pub", "go"]:
|
|
59
|
+
oss_version = get_latest_package_version(link, key, origin_name)
|
|
60
|
+
if oss_version:
|
|
61
|
+
link = get_new_link_with_version(link, key, origin_name, oss_version)
|
|
58
62
|
logger.info(f'Try to download with the latest version:{link}')
|
|
59
63
|
matched = True
|
|
60
64
|
break
|
|
@@ -63,50 +67,56 @@ def extract_name_version_from_link(link):
|
|
|
63
67
|
return oss_name, oss_version, link, key
|
|
64
68
|
|
|
65
69
|
|
|
70
|
+
def get_new_link_with_version(link, pkg_type, oss_name, oss_version):
|
|
71
|
+
if pkg_type == "pypi":
|
|
72
|
+
link = f'https://pypi.org/project/{oss_name}/{oss_version}'
|
|
73
|
+
elif pkg_type == "maven":
|
|
74
|
+
oss_name = oss_name.replace(':', '/')
|
|
75
|
+
link = f'https://mvnrepository.com/artifact/{oss_name}/{oss_version}'
|
|
76
|
+
elif pkg_type == "npm" or pkg_type == "npm2":
|
|
77
|
+
link = f'https://www.npmjs.com/package/{oss_name}/v/{oss_version}'
|
|
78
|
+
elif pkg_type == "pub":
|
|
79
|
+
link = f'https://pub.dev/packages/{oss_name}/versions/{oss_version}'
|
|
80
|
+
elif pkg_type == "go":
|
|
81
|
+
link = f'https://pkg.go.dev/{oss_name}@{oss_version}'
|
|
82
|
+
elif pkg_type == "cargo":
|
|
83
|
+
link = f'https://crates.io/crates/{oss_name}/{oss_version}'
|
|
84
|
+
return link
|
|
85
|
+
|
|
86
|
+
|
|
66
87
|
def get_latest_package_version(link, pkg_type, oss_name):
|
|
67
88
|
find_version = ''
|
|
68
|
-
link_with_version = link
|
|
69
89
|
|
|
70
90
|
try:
|
|
71
91
|
if pkg_type in ['npm', 'npm2']:
|
|
72
92
|
npm_response = requests.get(f"https://registry.npmjs.org/{oss_name}")
|
|
73
93
|
if npm_response.status_code == 200:
|
|
74
94
|
find_version = npm_response.json().get("dist-tags", {}).get("latest")
|
|
75
|
-
if find_version:
|
|
76
|
-
link_with_version = f'https://www.npmjs.com/package/{oss_name}/v/{find_version}'
|
|
77
95
|
elif pkg_type == 'pypi':
|
|
78
96
|
find_version = str(latest(oss_name, at='pip', output_format='version', pre_ok=True))
|
|
79
|
-
link_with_version = f'https://pypi.org/project/{oss_name}/{find_version}'
|
|
80
97
|
elif pkg_type == 'maven':
|
|
81
98
|
maven_response = requests.get(f'https://api.deps.dev/v3alpha/systems/maven/packages/{oss_name}')
|
|
82
99
|
if maven_response.status_code == 200:
|
|
83
100
|
find_version = maven_response.json().get('versions')[-1].get('versionKey').get('version')
|
|
84
|
-
oss_name = oss_name.replace(':', '/')
|
|
85
|
-
if find_version:
|
|
86
|
-
link_with_version = f'https://mvnrepository.com/artifact/{oss_name}/{find_version}'
|
|
87
101
|
elif pkg_type == 'pub':
|
|
88
102
|
pub_response = requests.get(f'https://pub.dev/api/packages/{oss_name}')
|
|
89
103
|
if pub_response.status_code == 200:
|
|
90
104
|
find_version = pub_response.json().get('latest').get('version')
|
|
91
|
-
if find_version:
|
|
92
|
-
link_with_version = f'https://pub.dev/packages/{oss_name}/versions/{find_version}'
|
|
93
105
|
elif pkg_type == 'go':
|
|
94
106
|
go_response = requests.get(f'https://proxy.golang.org/{oss_name}/@latest')
|
|
95
107
|
if go_response.status_code == 200:
|
|
96
108
|
find_version = go_response.json().get('Version')
|
|
97
|
-
if find_version:
|
|
98
|
-
link_with_version = f'https://pkg.go.dev/{oss_name}@{find_version}'
|
|
99
109
|
except Exception as e:
|
|
100
110
|
logger.info(f'Fail to get latest package version({link}:{e})')
|
|
101
|
-
return find_version
|
|
111
|
+
return find_version
|
|
102
112
|
|
|
103
113
|
|
|
104
|
-
def get_downloadable_url(link):
|
|
114
|
+
def get_downloadable_url(link, checkout_version):
|
|
105
115
|
|
|
106
116
|
ret = False
|
|
107
117
|
result_link = link
|
|
108
118
|
|
|
109
|
-
oss_name, oss_version, new_link, pkg_type = extract_name_version_from_link(link)
|
|
119
|
+
oss_name, oss_version, new_link, pkg_type = extract_name_version_from_link(link, checkout_version)
|
|
110
120
|
new_link = new_link.replace('http://', '')
|
|
111
121
|
new_link = new_link.replace('https://', '')
|
|
112
122
|
|
|
@@ -27,6 +27,7 @@ import subprocess
|
|
|
27
27
|
import re
|
|
28
28
|
from typing import Tuple
|
|
29
29
|
import urllib.parse
|
|
30
|
+
import json
|
|
30
31
|
|
|
31
32
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
32
33
|
compression_extension = {".tar.bz2", ".tar.gz", ".tar.xz", ".tgz", ".tar", ".zip", ".jar", ".bz2"}
|
|
@@ -96,7 +97,8 @@ def parse_src_link(src_link):
|
|
|
96
97
|
def cli_download_and_extract(link: str, target_dir: str, log_dir: str, checkout_to: str = "",
|
|
97
98
|
compressed_only: bool = False, ssh_key: str = "",
|
|
98
99
|
id: str = "", git_token: str = "",
|
|
99
|
-
called_cli: bool = True
|
|
100
|
+
called_cli: bool = True,
|
|
101
|
+
output: bool = False) -> Tuple[bool, str, str, str]:
|
|
100
102
|
global logger
|
|
101
103
|
|
|
102
104
|
success = True
|
|
@@ -135,7 +137,8 @@ def cli_download_and_extract(link: str, target_dir: str, log_dir: str, checkout_
|
|
|
135
137
|
if os.path.isfile(target_dir):
|
|
136
138
|
shutil.rmtree(target_dir)
|
|
137
139
|
|
|
138
|
-
success, downloaded_file, msg_wget, oss_name, oss_version = download_wget(link, target_dir,
|
|
140
|
+
success, downloaded_file, msg_wget, oss_name, oss_version = download_wget(link, target_dir,
|
|
141
|
+
compressed_only, checkout_to)
|
|
139
142
|
if success:
|
|
140
143
|
success = extract_compressed_file(downloaded_file, target_dir, True, compressed_only)
|
|
141
144
|
# Download from rubygems.org
|
|
@@ -155,6 +158,17 @@ def cli_download_and_extract(link: str, target_dir: str, log_dir: str, checkout_
|
|
|
155
158
|
success = False
|
|
156
159
|
msg = str(error)
|
|
157
160
|
|
|
161
|
+
if output:
|
|
162
|
+
output_result = {
|
|
163
|
+
"success": success,
|
|
164
|
+
"message": msg,
|
|
165
|
+
"oss_name": oss_name,
|
|
166
|
+
"oss_version": oss_version
|
|
167
|
+
}
|
|
168
|
+
output_json = os.path.join(log_dir, "fosslight_download_output.json")
|
|
169
|
+
with open(output_json, 'w') as f:
|
|
170
|
+
json.dump(output_result, f, indent=4)
|
|
171
|
+
|
|
158
172
|
logger.info(f"\n* FOSSLight Downloader - Result: {success} ({msg})")
|
|
159
173
|
return success, msg, oss_name, oss_version
|
|
160
174
|
|
|
@@ -297,7 +311,7 @@ def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch="",
|
|
|
297
311
|
return success, msg, oss_name, refs_to_checkout
|
|
298
312
|
|
|
299
313
|
|
|
300
|
-
def download_wget(link, target_dir, compressed_only):
|
|
314
|
+
def download_wget(link, target_dir, compressed_only, checkout_to):
|
|
301
315
|
success = False
|
|
302
316
|
msg = ""
|
|
303
317
|
oss_name = ""
|
|
@@ -314,7 +328,7 @@ def download_wget(link, target_dir, compressed_only):
|
|
|
314
328
|
|
|
315
329
|
Path(target_dir).mkdir(parents=True, exist_ok=True)
|
|
316
330
|
|
|
317
|
-
ret, new_link, oss_name, oss_version, pkg_type = get_downloadable_url(link)
|
|
331
|
+
ret, new_link, oss_name, oss_version, pkg_type = get_downloadable_url(link, checkout_to)
|
|
318
332
|
if ret and new_link:
|
|
319
333
|
link = new_link
|
|
320
334
|
|
|
@@ -478,10 +492,17 @@ def main():
|
|
|
478
492
|
parser.add_argument('-s', '--source', help='Source link to download', type=str, dest='source')
|
|
479
493
|
parser.add_argument('-t', '--target_dir', help='Target directory', type=str, dest='target_dir', default="")
|
|
480
494
|
parser.add_argument('-d', '--log_dir', help='Directory to save log file', type=str, dest='log_dir', default="")
|
|
495
|
+
parser.add_argument('-c', '--checkout_to', help='Checkout to branch or tag', type=str, dest='checkout_to', default="")
|
|
496
|
+
parser.add_argument('-z', '--compressed_only', help='Unzip only compressed file',
|
|
497
|
+
action='store_true', dest='compressed_only', default=False)
|
|
498
|
+
parser.add_argument('-o', '--output', help='Generate output file', action='store_true', dest='output', default=False)
|
|
481
499
|
|
|
482
500
|
src_link = ""
|
|
483
501
|
target_dir = os.getcwd()
|
|
484
502
|
log_dir = os.getcwd()
|
|
503
|
+
checkout_to = ""
|
|
504
|
+
compressed_only = False
|
|
505
|
+
output = False
|
|
485
506
|
|
|
486
507
|
try:
|
|
487
508
|
args = parser.parse_args()
|
|
@@ -496,11 +517,19 @@ def main():
|
|
|
496
517
|
target_dir = args.target_dir
|
|
497
518
|
if args.log_dir:
|
|
498
519
|
log_dir = args.log_dir
|
|
520
|
+
if args.checkout_to:
|
|
521
|
+
checkout_to = args.checkout_to
|
|
522
|
+
if args.compressed_only:
|
|
523
|
+
compressed_only = args.compressed_only
|
|
524
|
+
if args.output:
|
|
525
|
+
output = args.output
|
|
499
526
|
|
|
500
527
|
if not src_link:
|
|
501
528
|
print_help_msg_download()
|
|
502
529
|
else:
|
|
503
|
-
cli_download_and_extract(src_link, target_dir, log_dir
|
|
530
|
+
cli_download_and_extract(src_link, target_dir, log_dir, checkout_to,
|
|
531
|
+
compressed_only, "", "", "", False,
|
|
532
|
+
output)
|
|
504
533
|
|
|
505
534
|
|
|
506
535
|
if __name__ == '__main__':
|
|
@@ -34,7 +34,12 @@ _HELP_MESSAGE_DOWNLOAD = """
|
|
|
34
34
|
Optional:
|
|
35
35
|
-h\t\t Print help message
|
|
36
36
|
-t\t\t Output path name
|
|
37
|
-
-d\t\t Directory name to save the log file
|
|
37
|
+
-d\t\t Directory name to save the log file
|
|
38
|
+
-s\t\t Source link to download
|
|
39
|
+
-t\t\t Directory to download source code
|
|
40
|
+
-c\t\t Checkout to branch or tag/ or version
|
|
41
|
+
-z\t\t Unzip only compressed file
|
|
42
|
+
-o\t\t Generate summary output file with this option"""
|
|
38
43
|
|
|
39
44
|
|
|
40
45
|
class PrintHelpMsg():
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{fosslight_util-2.1.20 → fosslight_util-2.1.22}/src/fosslight_util.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|