Skip to content

Commit

Permalink
Merge pull request #55 from tuhinmallick/komment/main
Browse files Browse the repository at this point in the history
Documented 1 item across 1 file
  • Loading branch information
tuhinmallick authored Sep 18, 2024
2 parents 8b213e0 + 9872580 commit c659771
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions check_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
import requests

def check_version(package, version):
"""
Retrieves metadata from PyPI and checks if a specified package has released
the given version. It returns `True` if the version is found, indicating the
package supports it, and `False` otherwise. The check relies on successful
HTTP request to retrieve package data.
Args:
package (str): Used to specify the name of a Python package for which the
version will be checked on PyPI (Python Package Index). It represents
the identifier of the software being queried.
version (str): Used as a value to search for in the 'releases' list of the
package's data retrieved from PyPI, indicating a specific version
number of the package.
Returns:
bool: 1 for True and 0 for False, indicating whether a specified package
version exists on PyPI. The result depends on the package name and version
provided as arguments.
"""
url = f"https://pypi.org/pypi/{package}/json"
response = requests.get(url)
if response.status_code == 200:
Expand Down

0 comments on commit c659771

Please sign in to comment.