mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2026-01-07 15:44:24 +01:00
refactor: cleanup
This commit is contained in:
@@ -5,7 +5,6 @@ from datetime import datetime
|
||||
import requests
|
||||
from packaging import version
|
||||
|
||||
|
||||
def is_package_on_pypi(package_name, version=None):
|
||||
"""
|
||||
Returns True if the package is on PyPI, False if it is not, and None if the status code is not 200 or 404.
|
||||
@@ -13,12 +12,7 @@ def is_package_on_pypi(package_name, version=None):
|
||||
optional_version = f"/{version}" if version else ""
|
||||
url = f"https://pypi.org/pypi/{package_name}{optional_version}/json"
|
||||
response = requests.get(url)
|
||||
if response.status_code == 200:
|
||||
return True
|
||||
elif response.status_code == 404:
|
||||
return False
|
||||
else:
|
||||
return None
|
||||
return response.status_code == 200 and len(response.json()['urls']) > 0
|
||||
|
||||
|
||||
def get_latest_package_version(package_name):
|
||||
|
||||
@@ -17,6 +17,7 @@ def test_is_package_on_pypi():
|
||||
assert is_package_on_pypi('jina-jina-jina') is False
|
||||
assert is_package_on_pypi('jina-jina-jina', '0.9.25') is False
|
||||
assert is_package_on_pypi('jina-jina-jina', '10.10.10') is False
|
||||
assert is_package_on_pypi('io', '0.0.1') is False
|
||||
|
||||
|
||||
def test_filter_packages_list():
|
||||
@@ -47,6 +48,8 @@ gtts~=2.2.3
|
||||
pydub~=123.123.123
|
||||
# non-existing package with correct version
|
||||
base64~=3.3.0
|
||||
# another non-existing package
|
||||
io~=0.0.1
|
||||
# not parsable version
|
||||
pdfminer.six>=20201018,<20211018
|
||||
# existing package without version
|
||||
|
||||
Reference in New Issue
Block a user