Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTMLPage cleanup and egg_info_matches fix #5819

Merged
merged 3 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/5819.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix incorrect parsing of egg names if pip needs to guess the package name.
1 change: 1 addition & 0 deletions news/5819.trivial
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Simplify always-true conditions in ``HTMLPage.get_page()``.
33 changes: 16 additions & 17 deletions src/pip/_internal/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def egg_info_matches(
return None
if search_name is None:
full_match = match.group(0)
return full_match[full_match.index('-'):]
return full_match.split('-', 1)[-1]
name = match.group(0).lower()
# To match the "safe" name that pkg_resources creates:
name = name.replace('_', '-')
Expand Down Expand Up @@ -731,7 +731,7 @@ def __str__(self):
return self.url

@classmethod
def get_page(cls, link, skip_archives=True, session=None):
def get_page(cls, link, session=None):
if session is None:
raise TypeError(
"get_page() missing 1 required keyword argument: 'session'"
Expand All @@ -748,22 +748,21 @@ def get_page(cls, link, skip_archives=True, session=None):
return None

try:
if skip_archives:
filename = link.filename
for bad_ext in ARCHIVE_EXTENSIONS:
if filename.endswith(bad_ext):
content_type = cls._get_content_type(
url, session=session,
filename = link.filename
for bad_ext in ARCHIVE_EXTENSIONS:
if filename.endswith(bad_ext):
content_type = cls._get_content_type(
url, session=session,
)
if content_type.lower().startswith('text/html'):
break
else:
logger.debug(
'Skipping page %s because of Content-Type: %s',
link,
content_type,
)
if content_type.lower().startswith('text/html'):
break
else:
logger.debug(
'Skipping page %s because of Content-Type: %s',
link,
content_type,
)
return
return

logger.debug('Getting page %s', url)

Expand Down