Skip to content

Commit 17958ea

Browse files
Chris Billingtonwarsaw
authored andcommitted
Allow .egg-info files (i.e. not directories)
1 parent 28b9914 commit 17958ea

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

importlib_metadata/_hooks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from pathlib2 import Path
1919

2020
FileNotFoundError = IOError, OSError
21+
NotADirectoryError = IOError, OSError
2122
__metaclass__ = type
2223

2324

@@ -84,8 +85,7 @@ def _search_path(cls, root, pattern):
8485
return (
8586
item
8687
for item in root.iterdir()
87-
if item.is_dir()
88-
and re.match(
88+
if re.match(
8989
cls.search_template.format(pattern=normalized),
9090
str(item.name),
9191
flags=re.IGNORECASE,
@@ -99,7 +99,7 @@ def __init__(self, path):
9999
self._path = path
100100

101101
def read_text(self, filename):
102-
with suppress(FileNotFoundError):
102+
with suppress(FileNotFoundError, NotADirectoryError):
103103
with self._path.joinpath(filename).open(encoding='utf-8') as fp:
104104
return fp.read()
105105
return None

importlib_metadata/api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ def metadata(self):
195195
The returned object will have keys that name the various bits of
196196
metadata. See PEP 566 for details.
197197
"""
198-
text = self.read_text('METADATA') or self.read_text('PKG-INFO')
198+
text = (
199+
self.read_text('METADATA')
200+
or self.read_text('PKG-INFO')
201+
or self.read_text('')
202+
)
199203
return _email_message_from_string(text)
200204

201205
@property
@@ -246,7 +250,7 @@ def _read_dist_info_reqs(self):
246250

247251
def _read_egg_info_reqs(self):
248252
source = self.read_text('requires.txt')
249-
return self._deps_from_requires_text(source)
253+
return source and self._deps_from_requires_text(source)
250254

251255
@classmethod
252256
def _deps_from_requires_text(cls, source):

0 commit comments

Comments
 (0)