[Python-checkins] distutils2: Undo potentially confusing name change.

eric.araujo python-checkins at python.org
Mon Nov 14 15:24:08 CET 2011


http://hg.python.org/distutils2/rev/b9c9600aaca2
changeset:   1243:b9c9600aaca2
user:        Éric Araujo <merwok at netwok.org>
date:        Sat Nov 12 05:08:01 2011 +0100
summary:
  Undo potentially confusing name change.

This method was named reinitialize_command in distutils and accompanied
by a comment suggesting to change it to get_reinitialized_command.
Following that, I did the change for distutils2, but it proved
confusing: The Distribution object has an internal cache of command
objects, to make sure only one instance is ever used, and the name
get_reinitialized_command could suggest that the object returned was
independent of that cache, which it was not.  I’m reverting the name
change to make code clearer.

files:
  CHANGES.txt                         |   1 +
  distutils2/command/bdist.py         |   2 +-
  distutils2/command/bdist_dumb.py    |   4 ++--
  distutils2/command/bdist_msi.py     |   6 +++---
  distutils2/command/bdist_wininst.py |   5 ++---
  distutils2/command/cmd.py           |   4 ++--
  distutils2/command/test.py          |   2 +-
  distutils2/dist.py                  |  15 ++++++++-------
  distutils2/tests/support.py         |   2 +-
  9 files changed, 21 insertions(+), 20 deletions(-)


diff --git a/CHANGES.txt b/CHANGES.txt
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -153,6 +153,7 @@
   [éric]
 - The signature of tests.support.LoggingCatcher.get_logs changed, see
   docstring [éric]
+- Rename get_reinitialized_command back to reinitialize_command [éric]
 
 
 1.0a3 - 2010-10-08
diff --git a/distutils2/command/bdist.py b/distutils2/command/bdist.py
--- a/distutils2/command/bdist.py
+++ b/distutils2/command/bdist.py
@@ -126,7 +126,7 @@
         # Reinitialize and run each command.
         for i in range(len(self.formats)):
             cmd_name = commands[i]
-            sub_cmd = self.get_reinitialized_command(cmd_name)
+            sub_cmd = self.reinitialize_command(cmd_name)
             sub_cmd.format = self.formats[i]
 
             # passing the owner and group names for tar archiving
diff --git a/distutils2/command/bdist_dumb.py b/distutils2/command/bdist_dumb.py
--- a/distutils2/command/bdist_dumb.py
+++ b/distutils2/command/bdist_dumb.py
@@ -80,8 +80,8 @@
         if not self.skip_build:
             self.run_command('build')
 
-        install = self.get_reinitialized_command('install_dist',
-                                                 reinit_subcommands=True)
+        install = self.reinitialize_command('install_dist',
+                                            reinit_subcommands=True)
         install.root = self.bdist_dir
         install.skip_build = self.skip_build
         install.warn_dir = False
diff --git a/distutils2/command/bdist_msi.py b/distutils2/command/bdist_msi.py
--- a/distutils2/command/bdist_msi.py
+++ b/distutils2/command/bdist_msi.py
@@ -183,13 +183,13 @@
         if not self.skip_build:
             self.run_command('build')
 
-        install = self.get_reinitialized_command('install_dist',
-                                                 reinit_subcommands=True)
+        install = self.reinitialize_command('install_dist',
+                                            reinit_subcommands=True)
         install.prefix = self.bdist_dir
         install.skip_build = self.skip_build
         install.warn_dir = False
 
-        install_lib = self.get_reinitialized_command('install_lib')
+        install_lib = self.reinitialize_command('install_lib')
         # we do not want to include pyc or pyo files
         install_lib.compile = False
         install_lib.optimize = 0
diff --git a/distutils2/command/bdist_wininst.py b/distutils2/command/bdist_wininst.py
--- a/distutils2/command/bdist_wininst.py
+++ b/distutils2/command/bdist_wininst.py
@@ -117,14 +117,13 @@
         if not self.skip_build:
             self.run_command('build')
 
-        install = self.get_reinitialized_command('install',
-                                                 reinit_subcommands=True)
+        install = self.reinitialize_command('install', reinit_subcommands=True)
         install.root = self.bdist_dir
         install.skip_build = self.skip_build
         install.warn_dir = False
         install.plat_name = self.plat_name
 
-        install_lib = self.get_reinitialized_command('install_lib')
+        install_lib = self.reinitialize_command('install_lib')
         # we do not want to include pyc or pyo files
         install_lib.compile = False
         install_lib.optimize = 0
diff --git a/distutils2/command/cmd.py b/distutils2/command/cmd.py
--- a/distutils2/command/cmd.py
+++ b/distutils2/command/cmd.py
@@ -318,8 +318,8 @@
         cmd_obj.ensure_finalized()
         return cmd_obj
 
-    def get_reinitialized_command(self, command, reinit_subcommands=False):
-        return self.distribution.get_reinitialized_command(
+    def reinitialize_command(self, command, reinit_subcommands=False):
+        return self.distribution.reinitialize_command(
             command, reinit_subcommands)
 
     def run_command(self, command):
diff --git a/distutils2/command/test.py b/distutils2/command/test.py
--- a/distutils2/command/test.py
+++ b/distutils2/command/test.py
@@ -56,7 +56,7 @@
         prev_syspath = sys.path[:]
         try:
             # build release
-            build = self.get_reinitialized_command('build')
+            build = self.reinitialize_command('build')
             self.run_command('build')
             sys.path.insert(0, build.build_lib)
 
diff --git a/distutils2/dist.py b/distutils2/dist.py
--- a/distutils2/dist.py
+++ b/distutils2/dist.py
@@ -5,9 +5,9 @@
 
 from distutils2 import logger
 from distutils2.util import strtobool, resolve_name
+from distutils2.config import Config
 from distutils2.errors import (PackagingOptionError, PackagingArgError,
                                PackagingModuleError, PackagingClassError)
-from distutils2.config import Config
 from distutils2.command import get_command_class, STANDARD_COMMANDS
 from distutils2.command.cmd import Command
 from distutils2.metadata import Metadata
@@ -635,9 +635,9 @@
             except ValueError, msg:
                 raise PackagingOptionError(msg)
 
-    def get_reinitialized_command(self, command, reinit_subcommands=False):
+    def reinitialize_command(self, command, reinit_subcommands=False):
         """Reinitializes a command to the state it was in when first
-        returned by 'get_command_obj()': ie., initialized but not yet
+        returned by 'get_command_obj()': i.e., initialized but not yet
         finalized.  This provides the opportunity to sneak option
         values in programmatically, overriding or supplementing
         user-supplied values from the config files and command line.
@@ -649,10 +649,11 @@
         'reinit_subcommands' is true, also reinitializes the command's
         sub-commands, as declared by the 'sub_commands' class attribute (if
         it has one).  See the "install_dist" command for an example.  Only
-        reinitializes the sub-commands that actually matter, ie. those
-        whose test predicates return true.
+        reinitializes the sub-commands that actually matter, i.e. those
+        whose test predicate return true.
 
-        Returns the reinitialized command object.
+        Returns the reinitialized command object.  It will be the same
+        object as the one stored in the self.command_obj attribute.
         """
         if not isinstance(command, Command):
             command_name = command
@@ -670,7 +671,7 @@
 
         if reinit_subcommands:
             for sub in command.get_sub_commands():
-                self.get_reinitialized_command(sub, reinit_subcommands)
+                self.reinitialize_command(sub, reinit_subcommands)
 
         return command
 
diff --git a/distutils2/tests/support.py b/distutils2/tests/support.py
--- a/distutils2/tests/support.py
+++ b/distutils2/tests/support.py
@@ -262,7 +262,7 @@
     Useful for mocking one dependency command in the tests for another
     command, see e.g. the dummy build command in test_build_scripts.
     """
-    # XXX does not work with dist.get_reinitialized_command, which typechecks
+    # XXX does not work with dist.reinitialize_command, which typechecks
     # and wants a finalized attribute
 
     def __init__(self, **kwargs):

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


More information about the Python-checkins mailing list