summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/compat/_scons_optparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/compat/_scons_optparse.py')
-rw-r--r--src/engine/SCons/compat/_scons_optparse.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/engine/SCons/compat/_scons_optparse.py b/src/engine/SCons/compat/_scons_optparse.py
index 5db4c90..ac5b448 100644
--- a/src/engine/SCons/compat/_scons_optparse.py
+++ b/src/engine/SCons/compat/_scons_optparse.py
@@ -643,8 +643,7 @@ class Option:
else:
setattr(self, attr, None)
if attrs:
- attrs = attrs.keys()
- attrs.sort()
+ attrs = sorted(attrs.keys())
raise OptionError(
"invalid keyword arguments: %s" % string.join(attrs, ", "),
self)
@@ -693,7 +692,7 @@ class Option:
if self.choices is None:
raise OptionError(
"must supply a list of choices for type 'choice'", self)
- elif type(self.choices) not in (types.TupleType, types.ListType):
+ elif type(self.choices) not in (tuple, list):
raise OptionError(
"choices must be a list of strings ('%s' supplied)"
% string.split(str(type(self.choices)), "'")[1], self)
@@ -737,12 +736,12 @@ class Option:
raise OptionError(
"callback not callable: %r" % self.callback, self)
if (self.callback_args is not None and
- type(self.callback_args) is not types.TupleType):
+ type(self.callback_args) is not tuple):
raise OptionError(
"callback_args, if supplied, must be a tuple: not %r"
% self.callback_args, self)
if (self.callback_kwargs is not None and
- type(self.callback_kwargs) is not types.DictType):
+ type(self.callback_kwargs) is not dict):
raise OptionError(
"callback_kwargs, if supplied, must be a dict: not %r"
% self.callback_kwargs, self)
@@ -855,14 +854,13 @@ try:
except NameError:
(True, False) = (1, 0)
-try:
- types.UnicodeType
-except AttributeError:
+try: unicode
+except NameError:
def isbasestring(x):
- return isinstance(x, types.StringType)
+ return isinstance(x, str)
else:
def isbasestring(x):
- return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
+ return isinstance(x, str) or isinstance(x, unicode)
class Values:
@@ -879,7 +877,7 @@ class Values:
def __cmp__(self, other):
if isinstance(other, Values):
return cmp(self.__dict__, other.__dict__)
- elif isinstance(other, types.DictType):
+ elif isinstance(other, dict):
return cmp(self.__dict__, other)
else:
return -1
@@ -1040,7 +1038,7 @@ class OptionContainer:
"""add_option(Option)
add_option(opt_str, ..., kwarg=val, ...)
"""
- if type(args[0]) is types.StringType:
+ if type(args[0]) is str:
option = apply(self.option_class, args, kwargs)
elif len(args) == 1 and not kwargs:
option = args[0]
@@ -1351,7 +1349,7 @@ class OptionParser (OptionContainer):
def add_option_group(self, *args, **kwargs):
# XXX lots of overlap with OptionContainer.add_option()
- if type(args[0]) is types.StringType:
+ if type(args[0]) is str:
group = apply(OptionGroup, (self,) + args, kwargs)
elif len(args) == 1 and not kwargs:
group = args[0]