summaryrefslogtreecommitdiff
path: root/cliff
diff options
context:
space:
mode:
authorDoug Hellmann <doug@doughellmann.com>2017-09-26 17:17:08 -0400
committerDoug Hellmann <doug@doughellmann.com>2017-09-26 17:17:08 -0400
commita9719bc23ea3ad90cbad9ab743e678f491e85f0a (patch)
tree0ed966cb85facc9ea96fcddff78aa803bb5cad10 /cliff
parent8b77ece17ba32eb7ac1914418c86b5446a575673 (diff)
downloadcliff-a9719bc23ea3ad90cbad9ab743e678f491e85f0a.tar.gz
handle more varied top_level.txt files in distributions2.9.1
Deal with distributions that do not have the top_level.txt metadata file, or that have more than one module name listed in it. Change-Id: I7d21f4ba674ee95d072b0bc8e5f22b5b4b7a32b4 Closes-Bug: #1719465 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Diffstat (limited to 'cliff')
-rw-r--r--cliff/command.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/cliff/command.py b/cliff/command.py
index cfd6d17..859ac47 100644
--- a/cliff/command.py
+++ b/cliff/command.py
@@ -36,12 +36,17 @@ def _get_distributions_by_modules():
results = {}
for dist in pkg_resources.working_set:
try:
- mod_name = dist.get_metadata('top_level.txt').strip()
- except KeyError:
- # Could not retrieve metadata. Ignore.
+ mod_names = dist.get_metadata('top_level.txt').strip()
+ except Exception:
+ # Could not retrieve metadata. Either the file is not
+ # present or we cannot read it. Ignore the
+ # distribution.
pass
else:
- results[mod_name] = dist.project_name
+ # Distributions may include multiple top-level
+ # packages (see setuptools for an example).
+ for mod_name in mod_names.splitlines():
+ results[mod_name] = dist.project_name
_dists_by_mods = results
return _dists_by_mods