summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/cmd.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-04-15 22:15:07 (GMT)
committerGreg Ward <gward@python.net>2000-04-15 22:15:07 (GMT)
commit02a1a2b077e969e5fef8504cece5852bf641552d (patch)
tree4adea05076d4dab820180e6c9290ae9b1d7b28a4 /Lib/distutils/cmd.py
parent4a3dd2dcc2fae12b6736822731848c557b80d0e3 (diff)
downloadcpython-02a1a2b077e969e5fef8504cece5852bf641552d.zip
cpython-02a1a2b077e969e5fef8504cece5852bf641552d.tar.gz
cpython-02a1a2b077e969e5fef8504cece5852bf641552d.tar.bz2
Cleaned up/simplified error-handling:
- DistutilsOptionError is now documented as it's actually used, ie. to indicate bogus option values (usually user options, eg. from the command-line) - added DistutilsSetupError to indicate errors that definitely arise in the setup script - got rid of DistutilsValueError, and changed all usage of it to either DistutilsSetupError or ValueError as appropriate - simplified a bunch of option get/set methods in Command and Distribution classes -- just pass on AttributeError most of the time, rather than turning it into something else
Diffstat (limited to 'Lib/distutils/cmd.py')
-rw-r--r--Lib/distutils/cmd.py42
1 files changed, 14 insertions, 28 deletions
diff --git a/Lib/distutils/cmd.py b/Lib/distutils/cmd.py
index b3d1664..d8e4137 100644
--- a/Lib/distutils/cmd.py
+++ b/Lib/distutils/cmd.py
@@ -161,38 +161,28 @@ class Command:
def get_option (self, option):
"""Return the value of a single option for this command. Raise
- DistutilsOptionError if 'option' is not known."""
- try:
- return getattr (self, option)
- except AttributeError:
- raise DistutilsOptionError, \
- "command %s: no such option %s" % \
- (self.get_command_name(), option)
+ AttributeError if 'option' is not known."""
+ return getattr (self, option)
def get_options (self, *options):
"""Return (as a tuple) the values of several options for this
- command. Raise DistutilsOptionError if any of the options in
+ command. Raise AttributeError if any of the options in
'options' are not known."""
values = []
- try:
- for opt in options:
- values.append (getattr (self, opt))
- except AttributeError, name:
- raise DistutilsOptionError, \
- "command %s: no such option %s" % \
- (self.get_command_name(), name)
-
+ for opt in options:
+ values.append (getattr (self, opt))
+
return tuple (values)
-
+
def set_option (self, option, value):
"""Set the value of a single option for this command. Raise
- DistutilsOptionError if 'option' is not known."""
+ AttributeError if 'option' is not known."""
if not hasattr (self, option):
- raise DistutilsOptionError, \
+ raise AttributeError, \
"command '%s': no such option '%s'" % \
(self.get_command_name(), option)
if value is not None:
@@ -200,7 +190,7 @@ class Command:
def set_options (self, **optval):
"""Set the values of several options for this command. Raise
- DistutilsOptionError if any of the options specified as
+ AttributeError if any of the options specified as
keyword arguments are not known."""
for k in optval.keys():
@@ -236,14 +226,10 @@ class Command:
src_cmd_obj = self.distribution.find_command_obj (src_cmd)
src_cmd_obj.ensure_ready ()
- try:
- for (src_option, dst_option) in option_pairs:
- if getattr (self, dst_option) is None:
- self.set_option (dst_option,
- src_cmd_obj.get_option (src_option))
- except AttributeError, name:
- # duh, which command?
- raise DistutilsOptionError, "unknown option %s" % name
+ for (src_option, dst_option) in option_pairs:
+ if getattr (self, dst_option) is None:
+ self.set_option (dst_option,
+ src_cmd_obj.get_option (src_option))
def find_peer (self, command, create=1):