summaryrefslogtreecommitdiff
path: root/Lib/distutils/dist.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-06-24 00:23:20 +0000
committerGreg Ward <gward@python.net>2000-06-24 00:23:20 +0000
commit051a98f0d44ea2b0978138ad6d5060808ef5fb6e (patch)
tree6c45f9ac228404b9760fff561c6d65a6c23f0ca3 /Lib/distutils/dist.py
parent5835978600b3e7afca1c027b02565b208c583d7f (diff)
downloadcpython-051a98f0d44ea2b0978138ad6d5060808ef5fb6e.tar.gz
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Diffstat (limited to 'Lib/distutils/dist.py')
-rw-r--r--Lib/distutils/dist.py37
1 files changed, 27 insertions, 10 deletions
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index 88bd94a470..2e4951ff88 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -437,11 +437,14 @@ class Distribution:
negative_opt = copy (negative_opt)
negative_opt.update (cmd_class.negative_opt)
- # Check for help_options in command class
- # They have a different format (tuple of four) so we need to preprocess them here
- help_options = []
- if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType:
- help_options = map(lambda x:(x[0],x[1],x[2]),cmd_class.help_options)
+ # Check for help_options in command class. They have a different
+ # format (tuple of four) so we need to preprocess them here.
+ if (hasattr(cmd_class, 'help_options') and
+ type (cmd_class.help_options) is ListType):
+ help_options = fix_help_options(cmd_class.help_options)
+ else:
+ help_optiosn = []
+
# All commands support the global options too, just by adding
# in 'global_options'.
@@ -453,12 +456,14 @@ class Distribution:
self._show_help(parser, display_options=0, commands=[cmd_class])
return
- if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType:
+ if (hasattr(cmd_class, 'help_options') and
+ type (cmd_class.help_options) is ListType):
help_option_found=0
for help_option in cmd_class.help_options:
if hasattr(opts, parser.get_attr_name(help_option[0])):
help_option_found=1
- #print "showing help for option %s of command %s" % (help_option[0],cmd_class)
+ #print "showing help for option %s of command %s" % \
+ # (help_option[0],cmd_class)
if callable(help_option[3]):
help_option[3]()
else:
@@ -518,9 +523,10 @@ class Distribution:
klass = command
else:
klass = self.get_command_class (command)
- if hasattr(klass,"help_options") and type (klass.help_options) is ListType:
- parser.set_option_table (klass.user_options+
- map(lambda x:(x[0],x[1],x[2]),klass.help_options))
+ if (hasattr(klass, 'help_options') and
+ type (klass.help_options) is ListType):
+ parser.set_option_table (klass.user_options +
+ fix_help_options(klass.help_options))
else:
parser.set_option_table (klass.user_options)
parser.print_help ("Options for '%s' command:" % klass.__name__)
@@ -890,6 +896,17 @@ class DistributionMetadata:
# class DistributionMetadata
+
+def fix_help_options (options):
+ """Convert a 4-tuple 'help_options' list as found in various command
+ classes to the 3-tuple form required by FancyGetopt.
+ """
+ new_options = []
+ for help_tuple in options:
+ new_options.append(help_tuple[0:3])
+ return new_options
+
+
if __name__ == "__main__":
dist = Distribution ()
print "ok"