Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
6 changes: 6 additions & 0 deletions 6 CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v4.11.4
=======

* #377: In ``PathDistribution._name_from_stem``, avoid including
parts of the extension in the result.

v4.11.3
=======

Expand Down
15 changes: 12 additions & 3 deletions 15 importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,11 +958,20 @@ def _normalized_name(self):
stem = os.path.basename(str(self._path))
return self._name_from_stem(stem) or super()._normalized_name

def _name_from_stem(self, stem):
name, ext = os.path.splitext(stem)
@staticmethod
def _name_from_stem(stem):
"""
>>> PathDistribution._name_from_stem('foo-3.0.egg-info')
'foo'
>>> PathDistribution._name_from_stem('CherryPy-3.0.dist-info')
'CherryPy'
>>> PathDistribution._name_from_stem('face.egg-info')
'face'
"""
filename, ext = os.path.splitext(stem)
if ext not in ('.dist-info', '.egg-info'):
return
name, sep, rest = stem.partition('-')
name, sep, rest = filename.partition('-')
return name


Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.