diff options
| -rw-r--r-- | pkg_resources/__init__.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index d9154e6d..82b4ce51 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2045,12 +2045,29 @@ def find_on_path(importer, path_item, only=False): if not only and _is_egg_path(entry) else resolve_egg_link(fullpath) if not only and lower.endswith('.egg-link') else - () + NoDists()(fullpath) ) for dist in dists: yield dist +class NoDists: + """ + >>> bool(NoDists()) + False + + >>> list(NoDists()('anything')) + [] + """ + def __bool__(self): + return False + if six.PY2: + __nonzero__ = __bool__ + + def __call__(self, fullpath): + return iter(()) + + def safe_listdir(path): """ Attempt to list contents of path, but suppress some exceptions. |
