fosslight-util 2.1.6__py3-none-any.whl → 2.1.7__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.
@@ -103,31 +103,35 @@ def get_downloadable_url(link):
103
103
 
104
104
 
105
105
  def get_download_location_for_pypi(link):
106
- # get the url for downloading source file in pypi.org/project/(oss_name)/(oss_version)/#files
106
+ # get the url for downloading source file: https://docs.pypi.org/api/ Predictable URLs
107
107
  ret = False
108
108
  new_link = ''
109
+ host = 'https://files.pythonhosted.org'
109
110
 
110
111
  try:
111
112
  dn_loc_re = re.findall(r'pypi.org\/project\/?([^\/]*)\/?([^\/]*)', link)
112
113
  oss_name = dn_loc_re[0][0]
114
+ oss_name = re.sub(r"[-_.]+", "-", oss_name).lower()
113
115
  oss_version = dn_loc_re[0][1]
114
116
 
115
- pypi_url = 'https://pypi.org/project/' + oss_name + '/' + oss_version + '/#files'
116
-
117
- content = urlopen(pypi_url).read().decode('utf8')
118
- bs_obj = BeautifulSoup(content, 'html.parser')
119
-
120
- card_file_list = bs_obj.findAll('div', {'class': 'card file__card'})
121
-
122
- for card_file in card_file_list:
123
- file_code = card_file.find('code').text
124
- if file_code.lower() == "source":
125
- new_link = card_file.find('a').attrs['href']
117
+ new_link = f'{host}/packages/source/{oss_name[0]}/{oss_name}/{oss_name}-{oss_version}.tar.gz'
118
+ try:
119
+ res = urlopen(new_link)
120
+ if res.getcode() == 200:
126
121
  ret = True
127
- break
122
+ else:
123
+ logger.warning(f'Cannot find the valid link for pypi (url:{new_link}')
124
+ except Exception as e:
125
+ oss_name = re.sub(r"[-]+", "_", oss_name).lower()
126
+ new_link = f'{host}/packages/source/{oss_name[0]}/{oss_name}/{oss_name}-{oss_version}.tar.gz'
127
+ res = urlopen(new_link)
128
+ if res.getcode() == 200:
129
+ ret = True
130
+ else:
131
+ logger.warning(f'Cannot find the valid link for pypi (url:{new_link}')
128
132
  except Exception as error:
129
133
  ret = False
130
- logger.warning('Cannot find the link for pypi (url:'+link+') '+str(error))
134
+ logger.warning(f'Cannot find the link for pypi (url:{link}({(new_link)})) e:{str(error)}')
131
135
 
132
136
  return ret, new_link
133
137
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-util
3
- Version: 2.1.6
3
+ Version: 2.1.7
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Author: LG Electronics
@@ -1,5 +1,5 @@
1
1
  fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- fosslight_util/_get_downloadable_url.py,sha256=63ZPI4KCpUFgL4oheKm8zvekuCRzpwNkVaLJcA-uA90,9010
2
+ fosslight_util/_get_downloadable_url.py,sha256=tZz7UTUuLAbz2muXocOb9epMY_6RXIt-GEM8jhN0c3o,9315
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=3iUipan8ZX8sbyIIGAPtMkAGvZ4YucjeJwx1K1Bx_z4,3897
@@ -23,9 +23,9 @@ fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,
23
23
  fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
24
24
  fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
25
25
  fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
26
- fosslight_util-2.1.6.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
27
- fosslight_util-2.1.6.dist-info/METADATA,sha256=OsRvKhy8cfvJT8I5gwcIdUGburctGkgk5R4reUene1M,6499
28
- fosslight_util-2.1.6.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
29
- fosslight_util-2.1.6.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
30
- fosslight_util-2.1.6.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
31
- fosslight_util-2.1.6.dist-info/RECORD,,
26
+ fosslight_util-2.1.7.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
27
+ fosslight_util-2.1.7.dist-info/METADATA,sha256=_SbQsVJDKbUmd3C0i1fs7C-B9z92g_SLHWrQVb2mi_s,6499
28
+ fosslight_util-2.1.7.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
29
+ fosslight_util-2.1.7.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
30
+ fosslight_util-2.1.7.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
31
+ fosslight_util-2.1.7.dist-info/RECORD,,