Commit 6f10cff4 authored by Jason R. Coombs's avatar Jason R. Coombs

Extract function for resolving the dist factory for a path item entry

parent 9ff9a0d6
...@@ -2035,20 +2035,24 @@ def find_on_path(importer, path_item, only=False): ...@@ -2035,20 +2035,24 @@ def find_on_path(importer, path_item, only=False):
# scan for .egg and .egg-info in directory # scan for .egg and .egg-info in directory
path_item_entries = _by_version_descending(entries) path_item_entries = _by_version_descending(entries)
for entry in path_item_entries: for entry in path_item_entries:
lower = entry.lower()
fullpath = os.path.join(path_item, entry) fullpath = os.path.join(path_item, entry)
factory = dist_factory(path_item, entry, only)
for dist in factory(fullpath):
yield dist
def dist_factory(path_item, entry, only):
lower = entry.lower()
is_meta = any(map(lower.endswith, ('.egg-info', '.dist-info'))) is_meta = any(map(lower.endswith, ('.egg-info', '.dist-info')))
dists = ( return (
distributions_from_metadata(fullpath) distributions_from_metadata
if is_meta else if is_meta else
find_distributions(fullpath) find_distributions
if not only and _is_egg_path(entry) else if not only and _is_egg_path(entry) else
resolve_egg_link(fullpath) resolve_egg_link
if not only and lower.endswith('.egg-link') else if not only and lower.endswith('.egg-link') else
NoDists()(fullpath) NoDists()
) )
for dist in dists:
yield dist
class NoDists: class NoDists:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment