Skip to content

Commit 1927d76

Browse files
committed
Reverted pypi changes
1 parent fc22c88 commit 1927d76

File tree

2 files changed

+1
-37
lines changed

2 files changed

+1
-37
lines changed

l2tdevtools/download_helpers/pypi.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from __future__ import unicode_literals
55

6-
import json
76
import re
87

98
# pylint: disable=wrong-import-position
@@ -79,38 +78,6 @@ def _GetAvailableVersions(self, version_strings):
7978

8079
return available_versions
8180

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-
11481
# pylint: disable=unused-argument
11582
def GetLatestVersion(self, project_name, version_definition):
11683
"""Retrieves the latest version number for a given project name.

tests/download_helpers/pypi.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ def testGetLatestVersion(self):
3030

3131
latest_version = download_helper.GetLatestVersion(self._PROJECT_NAME, None)
3232

33-
latest_version_with_api = download_helper.GetLatestVersionWithAPI(
34-
self._PROJECT_NAME, None)
35-
36-
self.assertEqual(latest_version, latest_version_with_api)
33+
self.assertEqual(latest_version, self._PROJECT_VERSION)
3734

3835
def testGetDownloadURL(self):
3936
"""Tests the GetDownloadURL functions."""

0 commit comments

Comments
 (0)