Changed references to the command class 'options' attribute to 'user_options'.
Related docstring changes. Unrelated comment changes.
This commit is contained in:
parent
bbeceeaf9a
commit
4c96db1a65
|
@ -24,9 +24,10 @@ from distutils import util
|
||||||
# to look for a Python module named after the command.
|
# to look for a Python module named after the command.
|
||||||
command_re = re.compile (r'^[a-zA-Z]([a-zA-Z0-9_]*)$')
|
command_re = re.compile (r'^[a-zA-Z]([a-zA-Z0-9_]*)$')
|
||||||
|
|
||||||
# Defining this as a global is probably inadequate -- what about
|
# This is a barebones help message generated displayed when the user
|
||||||
# listing the available options (or even commands, which can vary
|
# runs the setup script with no arguments at all. More useful help
|
||||||
# quite late as well)
|
# is generated with various --help options: global help, list commands,
|
||||||
|
# and per-command help.
|
||||||
usage = """\
|
usage = """\
|
||||||
usage: %s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
|
usage: %s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
|
||||||
or: %s --help
|
or: %s --help
|
||||||
|
@ -50,22 +51,22 @@ def setup (**attrs):
|
||||||
Distribution instance.
|
Distribution instance.
|
||||||
|
|
||||||
The 'cmdclass' argument, if supplied, is a dictionary mapping
|
The 'cmdclass' argument, if supplied, is a dictionary mapping
|
||||||
command names to command classes. Each command encountered on the
|
command names to command classes. Each command encountered on
|
||||||
command line will be turned into a command class, which is in turn
|
the command line will be turned into a command class, which is in
|
||||||
instantiated; any class found in 'cmdclass' is used in place of the
|
turn instantiated; any class found in 'cmdclass' is used in place
|
||||||
default, which is (for command 'foo_bar') class 'FooBar' in module
|
of the default, which is (for command 'foo_bar') class 'foo_bar'
|
||||||
'distutils.command.foo_bar'. The command object must provide an
|
in module 'distutils.command.foo_bar'. The command class must
|
||||||
'options' attribute which is a list of option specifiers for
|
provide a 'user_options' attribute which is a list of option
|
||||||
'distutils.fancy_getopt'. Any command-line options between the
|
specifiers for 'distutils.fancy_getopt'. Any command-line
|
||||||
current and the next command are used to set attributes in the
|
options between the current and the next command are used to set
|
||||||
current command object.
|
attributes of the current command object.
|
||||||
|
|
||||||
When the entire command-line has been successfully parsed, calls the
|
When the entire command-line has been successfully parsed, calls
|
||||||
'run' method on each command object in turn. This method will be
|
the 'run()' method on each command object in turn. This method
|
||||||
driven entirely by the Distribution object (which each command
|
will be driven entirely by the Distribution object (which each
|
||||||
object has a reference to, thanks to its constructor), and the
|
command object has a reference to, thanks to its constructor),
|
||||||
command-specific options that became attributes of each command
|
and the command-specific options that became attributes of each
|
||||||
object."""
|
command object."""
|
||||||
|
|
||||||
# Determine the distribution class -- either caller-supplied or
|
# Determine the distribution class -- either caller-supplied or
|
||||||
# our Distribution (see below).
|
# our Distribution (see below).
|
||||||
|
@ -313,11 +314,11 @@ class Distribution:
|
||||||
|
|
||||||
# Also make sure that the command object provides a list of its
|
# Also make sure that the command object provides a list of its
|
||||||
# known options
|
# known options
|
||||||
if not (hasattr (cmd_obj, 'options') and
|
if not (hasattr (cmd_obj, 'user_options') and
|
||||||
type (cmd_obj.options) is ListType):
|
type (cmd_obj.user_options) is ListType):
|
||||||
raise DistutilsClassError, \
|
raise DistutilsClassError, \
|
||||||
("command class %s must provide an 'options' attribute "+
|
("command class %s must provide " +
|
||||||
"(a list of tuples)") % \
|
"'user_options' attribute (a list of tuples)") % \
|
||||||
cmd_obj.__class__
|
cmd_obj.__class__
|
||||||
|
|
||||||
# Poof! like magic, all commands support the global
|
# Poof! like magic, all commands support the global
|
||||||
|
@ -327,14 +328,14 @@ class Distribution:
|
||||||
negative_opt = copy (negative_opt)
|
negative_opt = copy (negative_opt)
|
||||||
negative_opt.update (cmd_obj.negative_opt)
|
negative_opt.update (cmd_obj.negative_opt)
|
||||||
|
|
||||||
options = self.global_options + cmd_obj.options
|
options = self.global_options + cmd_obj.user_options
|
||||||
args = fancy_getopt (options, negative_opt,
|
args = fancy_getopt (options, negative_opt,
|
||||||
cmd_obj, args[1:])
|
cmd_obj, args[1:])
|
||||||
if cmd_obj.help:
|
if cmd_obj.help:
|
||||||
print_help (self.global_options,
|
print_help (self.global_options,
|
||||||
header="Global options:")
|
header="Global options:")
|
||||||
print
|
print
|
||||||
print_help (cmd_obj.options,
|
print_help (cmd_obj.user_options,
|
||||||
header="Options for '%s' command:" % command)
|
header="Options for '%s' command:" % command)
|
||||||
print
|
print
|
||||||
print usage
|
print usage
|
||||||
|
@ -357,7 +358,7 @@ class Distribution:
|
||||||
|
|
||||||
for command in self.commands:
|
for command in self.commands:
|
||||||
klass = self.find_command_class (command)
|
klass = self.find_command_class (command)
|
||||||
print_help (klass.options,
|
print_help (klass.user_options,
|
||||||
header="Options for '%s' command:" % command)
|
header="Options for '%s' command:" % command)
|
||||||
print
|
print
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue