]> granicus.if.org Git - python/commitdiff
Added 'dump_options()' for debugging output.
authorGreg Ward <gward@python.net>
Sun, 28 May 2000 23:54:00 +0000 (23:54 +0000)
committerGreg Ward <gward@python.net>
Sun, 28 May 2000 23:54:00 +0000 (23:54 +0000)
Lib/distutils/cmd.py

index c21ea03e6df16466140bbb3c52cf5f5b181f1f62..f80338920e781777e5eadcb90b1b8886c37423dc 100644 (file)
@@ -135,6 +135,21 @@ class Command:
         raise RuntimeError, \
               "abstract method -- subclass %s must override" % self.__class__
 
+
+    def dump_options (self, header=None, indent=""):
+        from distutils.fancy_getopt import longopt_xlate
+        if header is None:
+            header = "command options for '%s':" % self.get_command_name()
+        print indent + header
+        indent = indent + "  "
+        for (option, _, _) in self.user_options:
+            option = string.translate(option, longopt_xlate)
+            if option[-1] == "=":
+                option = option[:-1]
+            value = getattr(self, option)
+            print indent + "%s = %s" % (option, value)
+
+
     def run (self):
         """A command's raison d'etre: carry out the action it exists
            to perform, controlled by the options initialized in