|
3 | 3 |
|
4 | 4 | from __future__ import unicode_literals |
5 | 5 |
|
6 | | -import json |
7 | 6 | import re |
8 | 7 |
|
9 | 8 | # pylint: disable=wrong-import-position |
@@ -79,38 +78,6 @@ def _GetAvailableVersions(self, version_strings): |
79 | 78 |
|
80 | 79 | return available_versions |
81 | 80 |
|
82 | | - def GetLatestVersionWithAPI(self, project_name, version_definition): |
83 | | - """Retrieves the latest version for a given project using the PyPi API. |
84 | | -
|
85 | | - Args: |
86 | | - project_name (str): name of the project. |
87 | | - version_definition (ProjectVersionDefinition): project version definition |
88 | | - or None. |
89 | | -
|
90 | | - Returns: |
91 | | - str: latest version number or None if not available. |
92 | | - """ |
93 | | - earliest_version = None |
94 | | - latest_version = None |
95 | | - |
96 | | - if version_definition: |
97 | | - earliest_version = version_definition.GetEarliestVersion() |
98 | | - if earliest_version and earliest_version[0] == '==': |
99 | | - return '.'.join(earliest_version[1:]) |
100 | | - |
101 | | - latest_version = version_definition.GetLatestVersion() |
102 | | - |
103 | | - pypi_url = 'https://pypi.org/pypi/{0:s}/json'.format(project_name) |
104 | | - page_content = self.DownloadPageContent(pypi_url) |
105 | | - |
106 | | - api_data = json.loads(page_content) |
107 | | - releases = api_data.get('releases', {}) |
108 | | - version_strings = releases.keys() |
109 | | - available_versions = self._GetAvailableVersions(version_strings) |
110 | | - |
111 | | - return self._GetLatestVersion( |
112 | | - earliest_version, latest_version, available_versions) |
113 | | - |
114 | 81 | # pylint: disable=unused-argument |
115 | 82 | def GetLatestVersion(self, project_name, version_definition): |
116 | 83 | """Retrieves the latest version number for a given project name. |
|
0 commit comments