Created
June 26, 2019 03:05
-
-
Save bkhanale/94a93326465d4755c5fa2ebecd52cd18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parse_requirements_file(requirements_file): | |
""" | |
Parses the requirements out of the pip requirements.txt file | |
:return: | |
A list of the names of the packages found in requirements_file. | |
""" | |
data = [] | |
for line_number, line in enumerate(requirements_file): | |
if line.startswith('#'): | |
continue | |
try: | |
res = Requirement.parse(line) | |
req = {'package_name': res.project_name, | |
'version': res.specs[0][1], | |
'line_number': line_number, | |
} | |
data.append(req) | |
except (ValueError, RequirementParseError): | |
pass | |
return data | |
def get_latest_version(package): | |
""" | |
Gets the latest version available for the package. | |
:return: | |
A string with the latest version of the package. | |
""" | |
pypi = xmlrpc_client.ServerProxy(PYPI_URL) | |
return pypi.package_releases(package)[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment