Commit 73c175f5 authored by Éric Araujo's avatar Éric Araujo

Let pysetup list exit with a non-zero code when no result is found (#11409).

“pysetup list” or “pysetup list --all” will continue to return 0 if no
distribution is found (it’s not an error), but “pysetup list
some.project” will now exit with 1 if no matching installed distribution
is found.  Based on a patch by Kelsey Hightower.
parent 2527796a
...@@ -358,8 +358,10 @@ def _list(dispatcher, args, **kw): ...@@ -358,8 +358,10 @@ def _list(dispatcher, args, **kw):
dists = get_distributions(use_egg_info=True) dists = get_distributions(use_egg_info=True)
if 'all' in opts or opts['args'] == []: if 'all' in opts or opts['args'] == []:
results = dists results = dists
listall = True
else: else:
results = [d for d in dists if d.name.lower() in opts['args']] results = [d for d in dists if d.name.lower() in opts['args']]
listall = False
number = 0 number = 0
for dist in results: for dist in results:
...@@ -368,7 +370,11 @@ def _list(dispatcher, args, **kw): ...@@ -368,7 +370,11 @@ def _list(dispatcher, args, **kw):
print() print()
if number == 0: if number == 0:
print('Nothing seems to be installed.') if listall:
print('Nothing seems to be installed.')
else:
print('No matching distribution found.')
return 1
else: else:
print('Found %d projects installed.' % number) print('Found %d projects installed.' % number)
......
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