summaryrefslogtreecommitdiff
path: root/pkg_resources
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2017-09-09 11:41:47 -0400
committerJason R. Coombs <jaraco@jaraco.com>2017-09-09 11:41:47 -0400
commita95cd91de2c314640fdd5466a67c44f1642f9803 (patch)
tree929c85a46af33625f6e8a33ff27dd8c3335fa8e1 /pkg_resources
parent7e173ffb2da7cbdbf0c90b491779402aa74a6b42 (diff)
downloadpython-setuptools-git-a95cd91de2c314640fdd5466a67c44f1642f9803.tar.gz
Assign dists just once
Diffstat (limited to 'pkg_resources')
-rw-r--r--pkg_resources/__init__.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 7b5043dc..87568c2e 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -2049,18 +2049,18 @@ def find_on_path(importer, path_item, only=False):
for entry in path_item_entries:
lower = entry.lower()
fullpath = os.path.join(path_item, entry)
- if lower.endswith('.egg-info') or lower.endswith('.dist-info'):
- dists = distributions_from_metadata(fullpath)
- for dist in dists:
- yield dist
- elif not only and _is_egg_path(entry):
- dists = find_distributions(fullpath)
- for dist in dists:
- yield dist
- elif not only and lower.endswith('.egg-link'):
- dists = resolve_egg_link(fullpath)
- for dist in dists:
- yield dist
+ dists = (
+ distributions_from_metadata(fullpath)
+ if lower.endswith('.egg-info')
+ or lower.endswith('.dist-info') else
+ find_distributions(fullpath)
+ if not only and _is_egg_path(entry) else
+ resolve_egg_link(fullpath)
+ if not only and lower.endswith('.egg-link') else
+ ()
+ )
+ for dist in dists:
+ yield dist
def distributions_from_metadata(path):