[Python-checkins] cpython: Let pysetup list exit with a non-zero code when no result is found (#11409).

eric.araujo python-checkins at python.org
Fri Jul 29 14:35:30 CEST 2011


http://hg.python.org/cpython/rev/88545218e155
changeset:   71571:88545218e155
user:        Éric Araujo <merwok at netwok.org>
date:        Fri Jul 29 02:20:39 2011 +0200
summary:
  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.

files:
  Lib/packaging/run.py |  8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)


diff --git a/Lib/packaging/run.py b/Lib/packaging/run.py
--- a/Lib/packaging/run.py
+++ b/Lib/packaging/run.py
@@ -358,8 +358,10 @@
     dists = get_distributions(use_egg_info=True)
     if 'all' in opts or opts['args'] == []:
         results = dists
+        listall = True
     else:
         results = [d for d in dists if d.name.lower() in opts['args']]
+        listall = False
 
     number = 0
     for dist in results:
@@ -368,7 +370,11 @@
 
     print()
     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:
         print('Found %d projects installed.' % number)
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list