fosslight-util 2.1.21__py3-none-any.whl → 2.1.22__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/_get_downloadable_url.py +27 -17
- fosslight_util/download.py +4 -3
- fosslight_util/help.py +6 -1
- {fosslight_util-2.1.21.dist-info → fosslight_util-2.1.22.dist-info}/METADATA +1 -1
- {fosslight_util-2.1.21.dist-info → fosslight_util-2.1.22.dist-info}/RECORD +9 -9
- {fosslight_util-2.1.21.dist-info → fosslight_util-2.1.22.dist-info}/LICENSE +0 -0
- {fosslight_util-2.1.21.dist-info → fosslight_util-2.1.22.dist-info}/WHEEL +0 -0
- {fosslight_util-2.1.21.dist-info → fosslight_util-2.1.22.dist-info}/entry_points.txt +0 -0
- {fosslight_util-2.1.21.dist-info → fosslight_util-2.1.22.dist-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
|
|
fosslight_util/download.py
CHANGED
|
@@ -137,7 +137,8 @@ def cli_download_and_extract(link: str, target_dir: str, log_dir: str, checkout_
|
|
|
137
137
|
if os.path.isfile(target_dir):
|
|
138
138
|
shutil.rmtree(target_dir)
|
|
139
139
|
|
|
140
|
-
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)
|
|
141
142
|
if success:
|
|
142
143
|
success = extract_compressed_file(downloaded_file, target_dir, True, compressed_only)
|
|
143
144
|
# Download from rubygems.org
|
|
@@ -310,7 +311,7 @@ def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch="",
|
|
|
310
311
|
return success, msg, oss_name, refs_to_checkout
|
|
311
312
|
|
|
312
313
|
|
|
313
|
-
def download_wget(link, target_dir, compressed_only):
|
|
314
|
+
def download_wget(link, target_dir, compressed_only, checkout_to):
|
|
314
315
|
success = False
|
|
315
316
|
msg = ""
|
|
316
317
|
oss_name = ""
|
|
@@ -327,7 +328,7 @@ def download_wget(link, target_dir, compressed_only):
|
|
|
327
328
|
|
|
328
329
|
Path(target_dir).mkdir(parents=True, exist_ok=True)
|
|
329
330
|
|
|
330
|
-
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)
|
|
331
332
|
if ret and new_link:
|
|
332
333
|
link = new_link
|
|
333
334
|
|
fosslight_util/help.py
CHANGED
|
@@ -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():
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
fosslight_util/_get_downloadable_url.py,sha256=
|
|
2
|
+
fosslight_util/_get_downloadable_url.py,sha256=DbbZLN52Nwe4HxKing5Zf87RSPJD-9IKVGpu2W0498A,12689
|
|
3
3
|
fosslight_util/compare_yaml.py,sha256=eLqqCLgERxRHN5vsnpQVMXIEU862Lx66mD_y4uMgQE4,2916
|
|
4
4
|
fosslight_util/constant.py,sha256=zElnWOzXt020sYiFTiRQn8ZjZyZpL3aPmfAqfQLcxJk,2278
|
|
5
5
|
fosslight_util/correct.py,sha256=1WEAL-9_KhjFPLucPhv0PNN3K7avm0z8mU6sTuSyeHM,3864
|
|
6
6
|
fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
|
|
7
|
-
fosslight_util/download.py,sha256=
|
|
7
|
+
fosslight_util/download.py,sha256=yGRmvIhZk83ueA0QrCIO_fwQKCcy4yogwFLnkL_bDj8,18985
|
|
8
8
|
fosslight_util/exclude.py,sha256=fDmBsZJ_F7O9Oh2T-07R03XNbElo1tFaf_z01KfSAqU,2399
|
|
9
|
-
fosslight_util/help.py,sha256=
|
|
9
|
+
fosslight_util/help.py,sha256=iyWmAaUQSHJtWv5mjFv0f3YoDVlDgEqdsDDEyImEUNc,2646
|
|
10
10
|
fosslight_util/oss_item.py,sha256=8W2HlwqGH3l1iPPdvycrRYKsBSBpqAkqYyYtBVPgMtY,6868
|
|
11
11
|
fosslight_util/output_format.py,sha256=BP23LspxawDZ_a99oWLVKWUQ-G7P5uoUpjEXhkRFKwc,8801
|
|
12
12
|
fosslight_util/parsing_yaml.py,sha256=2zx_N5lMkXT1dRmfJMpzlrru-y_2F_CkVbGlba6vQpU,5380
|
|
@@ -24,9 +24,9 @@ fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,
|
|
|
24
24
|
fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
|
|
25
25
|
fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
|
|
26
26
|
fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
|
|
27
|
-
fosslight_util-2.1.
|
|
28
|
-
fosslight_util-2.1.
|
|
29
|
-
fosslight_util-2.1.
|
|
30
|
-
fosslight_util-2.1.
|
|
31
|
-
fosslight_util-2.1.
|
|
32
|
-
fosslight_util-2.1.
|
|
27
|
+
fosslight_util-2.1.22.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
28
|
+
fosslight_util-2.1.22.dist-info/METADATA,sha256=bw1E1MxG5-7DG9MXaFlrx2A9t4-PMbnhoOyrGjMNfoo,6156
|
|
29
|
+
fosslight_util-2.1.22.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
30
|
+
fosslight_util-2.1.22.dist-info/entry_points.txt,sha256=0yZggRWNwDaClDG8UmUA10UFG8cVX3Jiy5gG9nW7hJs,68
|
|
31
|
+
fosslight_util-2.1.22.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
|
|
32
|
+
fosslight_util-2.1.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|