From a95cd91de2c314640fdd5466a67c44f1642f9803 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 9 Sep 2017 11:41:47 -0400 Subject: Assign dists just once --- pkg_resources/__init__.py | 24 ++++++++++++------------ 1 file 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): -- cgit v1.2.1