add doc strings and lint
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
"""
|
||||||
|
Utility functions and shared variables like DEFAULT_USER_AGENT are here.
|
||||||
|
"""
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from . import __version__
|
from . import __version__
|
||||||
@@ -8,6 +12,7 @@ DEFAULT_USER_AGENT: str = (
|
|||||||
|
|
||||||
|
|
||||||
def latest_version_pypi(package_name: str, user_agent: str = DEFAULT_USER_AGENT) -> str:
|
def latest_version_pypi(package_name: str, user_agent: str = DEFAULT_USER_AGENT) -> str:
|
||||||
|
"""Latest waybackpy version on PyPi."""
|
||||||
request_url = "https://pypi.org/pypi/" + package_name + "/json"
|
request_url = "https://pypi.org/pypi/" + package_name + "/json"
|
||||||
headers = {"User-Agent": user_agent}
|
headers = {"User-Agent": user_agent}
|
||||||
response = requests.get(request_url, headers=headers)
|
response = requests.get(request_url, headers=headers)
|
||||||
@@ -20,13 +25,14 @@ def latest_version_pypi(package_name: str, user_agent: str = DEFAULT_USER_AGENT)
|
|||||||
and data["info"]["version"] is not None
|
and data["info"]["version"] is not None
|
||||||
):
|
):
|
||||||
return str(data["info"]["version"])
|
return str(data["info"]["version"])
|
||||||
else:
|
|
||||||
raise ValueError("Could not get latest pypi version")
|
raise ValueError("Could not get latest pypi version")
|
||||||
|
|
||||||
|
|
||||||
def latest_version_github(
|
def latest_version_github(
|
||||||
package_name: str, user_agent: str = DEFAULT_USER_AGENT
|
package_name: str, user_agent: str = DEFAULT_USER_AGENT
|
||||||
) -> str:
|
) -> str:
|
||||||
|
"""Latest waybackpy version on GitHub."""
|
||||||
request_url = (
|
request_url = (
|
||||||
"https://api.github.com/repos/akamhy/" + package_name + "/releases?per_page=1"
|
"https://api.github.com/repos/akamhy/" + package_name + "/releases?per_page=1"
|
||||||
)
|
)
|
||||||
@@ -40,5 +46,5 @@ def latest_version_github(
|
|||||||
and "tag_name" in data[0]
|
and "tag_name" in data[0]
|
||||||
):
|
):
|
||||||
return str(data[0]["tag_name"])
|
return str(data[0]["tag_name"])
|
||||||
else:
|
|
||||||
raise ValueError("Could not get latest github version")
|
raise ValueError("Could not get latest github version")
|
||||||
|
Reference in New Issue
Block a user