Simplify command introspection inside usage().
authorZac Medico <zmedico@gentoo.org>
Sat, 8 Aug 2009 21:34:52 +0000 (21:34 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 8 Aug 2009 21:34:52 +0000 (21:34 -0000)
svn path=/main/trunk/; revision=13951

bin/portageq

index 084c20cbb3a201e382cb527892d5063346f2d1a0..a166eb2b5a40fd2dc1b5a687b90fe51496ca795c 100755 (executable)
@@ -534,16 +534,13 @@ def usage(argv):
        # Show our commands -- we do this by scanning the functions in this
        # file, and formatting each functions documentation.
        #
-       commands = [x for x in globals() if x not in \
-                               ("usage", "__doc__", "__name__", "main", "os", "portage", \
-                               "sys", "__builtins__", "types", "string","exithandler")]
-       commands.sort()
+       commands = sorted(k for k, v in globals().iteritems() \
+               if type(v) is types.FunctionType and \
+               k not in ('usage', 'main', 'exithandler'))
 
        for name in commands:
                # Drop non-functions
                obj = globals()[name]
-               if  (type(obj) != types.FunctionType):
-                       continue
 
                doc = obj.__doc__
                if (doc == None):