PackageFinder._get_index_urls_locations only needs req_name

and InstallRequirement does not need its url_name property anymore
This commit is contained in:
Xavier Fernandez 2015-03-27 17:31:05 +01:00
parent 02c6d2117e
commit 8bff8b5411
3 changed files with 10 additions and 17 deletions

View File

@ -291,7 +291,7 @@ class PackageFinder(object):
RemovedInPip7Warning,
)
def _get_index_urls_locations(self, req):
def _get_index_urls_locations(self, req_name):
"""Returns the locations found via self.index_urls
Checks the url_name on the main (first in the list) index and
@ -299,7 +299,7 @@ class PackageFinder(object):
"""
def mkurl_pypi_url(url):
loc = posixpath.join(url, url_name)
loc = posixpath.join(url, req_url_name)
# For maximum compatibility with easy_install, ensure the path
# ends in a trailing slash. Although this isn't in the spec
# (and PyPI can handle it without the slash) some other index
@ -309,7 +309,7 @@ class PackageFinder(object):
loc = loc + '/'
return loc
url_name = req.url_name
req_url_name = urllib_parse.quote(req_name.lower())
if self.index_urls:
# Check that we have the url_name correctly spelled:
@ -325,16 +325,16 @@ class PackageFinder(object):
warnings.warn(
"Failed to find %r at %s. It is suggested to upgrade "
"your index to support normalized names as the name in "
"/simple/{name}." % (req.name, main_index_url),
"/simple/{name}." % (req_name, main_index_url),
RemovedInPip8Warning,
)
url_name = self._find_url_name(
req_url_name = self._find_url_name(
Link(self.index_urls[0], trusted=True),
url_name,
) or req.url_name
req_url_name,
) or req_url_name
if url_name is not None:
if req_url_name is not None:
return [mkurl_pypi_url(url) for url in self.index_urls]
return []
@ -346,7 +346,7 @@ class PackageFinder(object):
See _link_package_versions for details on which files are accepted
"""
index_locations = self._get_index_urls_locations(req)
index_locations = self._get_index_urls_locations(req.name)
file_locations, url_locations = self._sort_locations(index_locations)
fl_file_loc, fl_url_loc = self._sort_locations(self.find_links)
file_locations.extend(fl_file_loc)

View File

@ -16,7 +16,6 @@ from email.parser import FeedParser
from pip._vendor import pkg_resources, six
from pip._vendor.distlib.markers import interpret as markers_interpret
from pip._vendor.six.moves import configparser
from pip._vendor.six.moves.urllib import parse as urllib_parse
import pip.wheel
@ -317,12 +316,6 @@ class InstallRequirement(object):
return None
return native_str(self.req.project_name)
@property
def url_name(self):
if self.req is None:
return None
return urllib_parse.quote(self.req.project_name.lower())
@property
def setup_py(self):
try:

View File

@ -737,7 +737,7 @@ def test_get_index_urls_locations():
finder = PackageFinder(
[], ['file://index1/', 'file://index2'], session=PipSession())
locations = finder._get_index_urls_locations(
InstallRequirement.from_line('Complex_Name'))
InstallRequirement.from_line('Complex_Name').name)
assert locations == ['file://index1/complex-name/',
'file://index2/complex-name/']