Commits

Boris FELD committed 4f9da8d Merge

Merge with upstream default branch

Comments (0)

Files changed (3)

distutils2/command/__init__.py

 from distutils2.errors import DistutilsModuleError
 from distutils2.util import resolve_name
 
+__all__ = ['get_command_names', 'set_command', 'get_command_class',
+           'STANDARD_COMMANDS']
+
 _COMMANDS = {
     'check': 'distutils2.command.check.check',
     'test': 'distutils2.command.test.test',
     'upload': 'distutils2.command.upload.upload',
     'upload_docs': 'distutils2.command.upload_docs.upload_docs'}
 
+STANDARD_COMMANDS = set(_COMMANDS)
+
 
 def get_command_names():
     """Return registered commands"""

distutils2/dist.py

 from distutils2 import logger
 from distutils2.metadata import Metadata
 from distutils2.config import Config
-from distutils2.command import get_command_class
+from distutils2.command import get_command_class, STANDARD_COMMANDS
 
 # Regex to define acceptable Distutils command names.  This is not *quite*
 # the same as a Python NAME -- I don't allow leading underscores.  The fact
         print(header + ":")
 
         for cmd in commands:
-            cls = self.cmdclass.get(cmd)
-            if not cls:
-                cls = get_command_class(cmd)
-            try:
-                description = cls.description
-            except AttributeError:
-                description = "(no description available)"
+            cls = self.cmdclass.get(cmd) or get_command_class(cmd)
+            description = getattr(cls, 'description',
+                                  '(no description available)')
 
             print("  %-*s  %s" % (max_length, cmd, description))
 
     def _get_command_groups(self):
         """Helper function to retrieve all the command class names divided
-        into standard commands (listed in distutils2.command.__all__)
-        and extra commands (given in self.cmdclass and not standard
-        commands).
+        into standard commands (listed in
+        distutils2.command.STANDARD_COMMANDS) and extra commands (given in
+        self.cmdclass and not standard commands).
         """
-        from distutils2.command import __all__ as std_commands
         extra_commands = [cmd for cmd in self.cmdclass
-                          if cmd not in std_commands]
-        return std_commands, extra_commands
+                          if cmd not in STANDARD_COMMANDS]
+        return STANDARD_COMMANDS, extra_commands
 
     def print_commands(self):
         """Print out a help message listing all available commands with a
         description of each.  The list is divided into standard commands
-        (listed in distutils2.command.__all__) and extra commands
+        (listed in distutils2.command.STANDARD_COMMANDS) and extra commands
         (given in self.cmdclass and not standard commands).  The
         descriptions come from the command class attribute
         'description'.
                                     "Extra commands",
                                     max_length)
 
-
     # -- Command class/object methods ----------------------------------
 
-
     def get_command_obj(self, command, create=1):
         """Return the command object for 'command'.  Normally this object
         is cached on a previous call to 'get_command_obj()'; if no command

distutils2/metadata.py

     _HAS_DOCUTILS = False
 
 # public API of this module
-__all__ = ('Metadata', 'PKG_INFO_ENCODING',
-           'PKG_INFO_PREFERRED_VERSION')
+__all__ = ['Metadata', 'PKG_INFO_ENCODING',
+           'PKG_INFO_PREFERRED_VERSION']
 
 # Encoding used for the PKG-INFO files
 PKG_INFO_ENCODING = 'utf-8'