fosslight-util 2.1.14__py3-none-any.whl → 2.1.16__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.
@@ -42,12 +42,17 @@ def extract_name_version_from_link(link):
42
42
  oss_version = match.group(2)
43
43
  elif key == "cocoapods":
44
44
  oss_name = f"cocoapods:{origin_name}"
45
+ elif key == "go":
46
+ if origin_name.endswith('/'):
47
+ origin_name = origin_name[:-1]
48
+ oss_name = f"go:{origin_name}"
49
+ oss_version = match.group(2)
45
50
  except Exception as ex:
46
51
  logger.info(f"extract_name_version_from_link {key}:{ex}")
47
52
  if oss_name and (not oss_version):
48
- if key in ["pypi", "maven", "npm", "npm2", "pub"]:
53
+ if key in ["pypi", "maven", "npm", "npm2", "pub", "go"]:
49
54
  oss_version, link = get_latest_package_version(link, key, origin_name)
50
- logger.debug(f'Try to download with the latest version:{link}')
55
+ logger.info(f'Try to download with the latest version:{link}')
51
56
  break
52
57
  return oss_name, oss_version, link, key
53
58
 
@@ -76,8 +81,13 @@ def get_latest_package_version(link, pkg_type, oss_name):
76
81
  if pub_response.status_code == 200:
77
82
  find_version = pub_response.json().get('latest').get('version')
78
83
  link_with_version = f'https://pub.dev/packages/{oss_name}/versions/{find_version}'
84
+ elif pkg_type == 'go':
85
+ go_response = requests.get(f'https://proxy.golang.org/{oss_name}/@latest')
86
+ if go_response.status_code == 200:
87
+ find_version = go_response.json().get('Version')
88
+ link_with_version = f'https://pkg.go.dev/{oss_name}@{find_version}'
79
89
  except Exception as e:
80
- logger.debug(f'Fail to get latest package version({link}:{e})')
90
+ logger.info(f'Fail to get latest package version({link}:{e})')
81
91
  return find_version, link_with_version
82
92
 
83
93
 
@@ -98,10 +108,42 @@ def get_downloadable_url(link):
98
108
  ret, result_link = get_download_location_for_npm(new_link)
99
109
  elif pkg_type == "pub":
100
110
  ret, result_link = get_download_location_for_pub(new_link)
111
+ elif pkg_type == "go":
112
+ ret, result_link = get_download_location_for_go(new_link)
101
113
 
102
114
  return ret, result_link, oss_name, oss_version
103
115
 
104
116
 
117
+ def get_download_location_for_go(link):
118
+ # get the url for downloading source file: https://proxy.golang.org/<module>/@v/VERSION.zip
119
+ ret = False
120
+ new_link = ''
121
+ host = 'https://proxy.golang.org'
122
+
123
+ try:
124
+ dn_loc_re = re.findall(r'pkg.go.dev\/([^\@]+)\@?([^\/]*)', link)
125
+ if dn_loc_re:
126
+ oss_name = dn_loc_re[0][0]
127
+ if oss_name.endswith('/'):
128
+ oss_name = oss_name[:-1]
129
+ oss_version = dn_loc_re[0][1]
130
+
131
+ new_link = f'{host}/{oss_name}/@v/{oss_version}.zip'
132
+ try:
133
+ res = urlopen(new_link)
134
+ if res.getcode() == 200:
135
+ ret = True
136
+ else:
137
+ logger.warning(f'Cannot find the valid link for go (url:{new_link}')
138
+ except Exception as e:
139
+ logger.warning(f'Fail to find the valid link for go (url:{new_link}: {e}')
140
+ except Exception as error:
141
+ ret = False
142
+ logger.warning(f'Cannot find the link for go (url:{link}({(new_link)})): {error}')
143
+
144
+ return ret, new_link
145
+
146
+
105
147
  def get_download_location_for_pypi(link):
106
148
  # get the url for downloading source file: https://docs.pypi.org/api/ Predictable URLs
107
149
  ret = False
@@ -26,6 +26,7 @@ import platform
26
26
  import subprocess
27
27
  import re
28
28
  from typing import Tuple
29
+ import urllib.parse
29
30
 
30
31
  logger = logging.getLogger(constant.LOGGER_NAME)
31
32
  compression_extension = {".tar.bz2", ".tar.gz", ".tar.xz", ".tgz", ".tar", ".zip", ".jar", ".bz2"}
@@ -256,7 +257,9 @@ def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch="", s
256
257
  m = re.match(r"^(ht|f)tp(s?)\:\/\/", git_url)
257
258
  protocol = m.group()
258
259
  if protocol:
259
- git_url = git_url.replace(protocol, f"{protocol}{id}:{git_token}@")
260
+ encoded_git_token = urllib.parse.quote(git_token, safe='')
261
+ encoded_id = urllib.parse.quote(id, safe='')
262
+ git_url = git_url.replace(protocol, f"{protocol}{encoded_id}:{encoded_git_token}@")
260
263
  except Exception as error:
261
264
  logger.info(f"Failed to insert id, token to git url:{error}")
262
265
  success, oss_version = download_git_repository(refs_to_checkout, git_url, target_dir, tag)
fosslight_util/help.py CHANGED
@@ -3,7 +3,10 @@
3
3
  # Copyright (c) 2021 LG Electronics Inc.
4
4
  # SPDX-License-Identifier: Apache-2.0
5
5
  import sys
6
- import pkg_resources
6
+ try:
7
+ from importlib.metadata import version, PackageNotFoundError
8
+ except ImportError:
9
+ from importlib_metadata import version, PackageNotFoundError # Python <3.8
7
10
 
8
11
  _HELP_MESSAGE_COMMON = """
9
12
  _______ _______ _______ _______ ___ ___ __
@@ -50,7 +53,10 @@ class PrintHelpMsg():
50
53
  def print_package_version(pkg_name: str, msg: str = "", exitopt: bool = True) -> str:
51
54
  if msg == "":
52
55
  msg = f"{pkg_name} Version:"
53
- cur_version = pkg_resources.get_distribution(pkg_name).version
56
+ try:
57
+ cur_version = version(pkg_name)
58
+ except PackageNotFoundError:
59
+ cur_version = "unknown"
54
60
 
55
61
  if exitopt:
56
62
  print(f'{msg} {cur_version}')
fosslight_util/set_log.py CHANGED
@@ -6,7 +6,6 @@
6
6
  import logging
7
7
  import os
8
8
  from pathlib import Path
9
- import pkg_resources
10
9
  import sys
11
10
  import platform
12
11
  from . import constant as constant
@@ -15,6 +14,11 @@ import coloredlogs
15
14
  from typing import Tuple
16
15
  from logging import Logger
17
16
 
17
+ try:
18
+ from importlib.metadata import version, PackageNotFoundError
19
+ except ImportError:
20
+ from importlib_metadata import version, PackageNotFoundError # Python <3.8
21
+
18
22
 
19
23
  def init_check_latest_version(pkg_version="", main_package_name=""):
20
24
 
@@ -92,9 +96,11 @@ def init_log(log_file: str, create_file: bool = True, stream_log_level: int = lo
92
96
  if main_package_name != "":
93
97
  pkg_info = main_package_name
94
98
  try:
95
- pkg_version = pkg_resources.get_distribution(main_package_name).version
99
+ pkg_version = version(main_package_name)
96
100
  init_check_latest_version(pkg_version, main_package_name)
97
101
  pkg_info = main_package_name + " v" + pkg_version
102
+ except PackageNotFoundError:
103
+ logger.debug('Cannot check the version: Package not found')
98
104
  except Exception as error:
99
105
  logger.debug('Cannot check the version:' + str(error))
100
106
  _result_log["Tool Info"] = pkg_info
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-util
3
- Version: 2.1.14
3
+ Version: 2.1.16
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Author: LG Electronics
@@ -1,17 +1,17 @@
1
1
  fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- fosslight_util/_get_downloadable_url.py,sha256=cn5ahD04YzetTx8PAXnqRMF_i8iA4dKUPZ7Fi9QXm3I,9286
2
+ fosslight_util/_get_downloadable_url.py,sha256=5QBEM1Ac_T3vhBUPJYSMkaGrI1A_f3VWDptxfVwMiy8,10976
3
3
  fosslight_util/compare_yaml.py,sha256=eLqqCLgERxRHN5vsnpQVMXIEU862Lx66mD_y4uMgQE4,2916
4
4
  fosslight_util/constant.py,sha256=Ig3ACm9_QirE4389Wt-IfxOqRkVOUjqGnX1B05z2Byo,2151
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=5nLe0oE1pUHEawM4kLlryusPBlk6ptEvy4HtqwFmCMs,16292
7
+ fosslight_util/download.py,sha256=3Ha9aS74Chy3D0qPLJvH5ZQ8hjK674WMhQ1JWD7HMZU,16488
8
8
  fosslight_util/exclude.py,sha256=fDmBsZJ_F7O9Oh2T-07R03XNbElo1tFaf_z01KfSAqU,2399
9
- fosslight_util/help.py,sha256=M3_XahUkP794US9Q0NS6ujmGvrFFnKBHsTU95Fg1KpA,2181
9
+ fosslight_util/help.py,sha256=Bmyz-eFP0X0qUfgFPrWiuyUPE0TLQfWjgfHTzJBIInc,2377
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
13
13
  fosslight_util/read_excel.py,sha256=-QvrdxaNqYOpIm1H7ZqIEh5NLvFPymZo6BAOZcQmQug,5263
14
- fosslight_util/set_log.py,sha256=Xpa94AiOyGEK8ucaYkvkAllvlen1Pq_d6UG6kPYBYBc,3780
14
+ fosslight_util/set_log.py,sha256=AbcLFLvY9GSOYSN0a110wO5gNcyc8KKnNjl7GxHEW9A,4008
15
15
  fosslight_util/spdx_licenses.py,sha256=GvMNe_D4v2meapTVwPu2BJXInnTo3_gIzg669eJhUu0,3691
16
16
  fosslight_util/timer_thread.py,sha256=5VbZENQPD-N0NUmzEktqGr6Am-e7vxD79K05mmr29g0,433
17
17
  fosslight_util/write_cyclonedx.py,sha256=hq817j-0OM89B8jtZKgHgvVa0YEaYHlz_8R5vNpe21I,9662
@@ -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.14.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
- fosslight_util-2.1.14.dist-info/METADATA,sha256=tf14st0xgl7NnQjGzMwFiASC0CC1gHAXSBsnSIWCWI0,6500
29
- fosslight_util-2.1.14.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
- fosslight_util-2.1.14.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
31
- fosslight_util-2.1.14.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
32
- fosslight_util-2.1.14.dist-info/RECORD,,
27
+ fosslight_util-2.1.16.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ fosslight_util-2.1.16.dist-info/METADATA,sha256=IYoZfRycYeh0UbXcYfEulbBMdjlHlJQAEA7926o_Gpk,6500
29
+ fosslight_util-2.1.16.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
+ fosslight_util-2.1.16.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
31
+ fosslight_util-2.1.16.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
32
+ fosslight_util-2.1.16.dist-info/RECORD,,