diff options
author | Luca Falavigna <dktrkranz@debian.org> | 2010-06-15 14:28:28 +0000 |
---|---|---|
committer | Luca Falavigna <dktrkranz@debian.org> | 2010-06-15 14:28:28 +0000 |
commit | 0ed55e71a9f4b9cda836c6a4a5408cece60db0c6 (patch) | |
tree | b1e82f6e428ac15ed9b4de93e48d8079420d537d /src/engine/SCons/Script/SConsOptions.py | |
parent | fe00e4f75ba00298c30d6854b245c2a42c6542b8 (diff) | |
parent | 738149c9bfb9965d013d01ef99f9bb1c2819e7e8 (diff) |
Merge commit 'upstream/2.0.0'
Diffstat (limited to 'src/engine/SCons/Script/SConsOptions.py')
-rw-r--r-- | src/engine/SCons/Script/SConsOptions.py | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index 545162b..913a6ee 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -21,20 +21,14 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Script/SConsOptions.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Script/SConsOptions.py 5023 2010/06/14 22:05:46 scons" import optparse import re -import string import sys import textwrap -try: - no_hyphen_re = re.compile(r'(\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') -except re.error: - # Pre-2.0 Python versions don't have the (?<= negative - # look-behind assertion. - no_hyphen_re = re.compile(r'(\s+|-*\w{2,}-(?=\w{2,}))') +no_hyphen_re = re.compile(r'(\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') try: from gettext import gettext @@ -55,9 +49,10 @@ def diskcheck_convert(value): if value is None: return [] if not SCons.Util.is_List(value): - value = string.split(value, ',') + value = value.split(',') result = [] - for v in map(string.lower, value): + for v in value: + v = v.lower() if v == 'all': result = diskcheck_all elif v == 'none': @@ -65,7 +60,7 @@ def diskcheck_convert(value): elif v in diskcheck_all: result.append(v) else: - raise ValueError, v + raise ValueError(v) return result class SConsValues(optparse.Values): @@ -139,7 +134,7 @@ class SConsValues(optparse.Values): Sets an option from an SConscript file. """ if not name in self.settable: - raise SCons.Errors.UserError, "This option is not settable from a SConscript file: %s"%name + raise SCons.Errors.UserError("This option is not settable from a SConscript file: %s"%name) if name == 'num_jobs': try: @@ -147,19 +142,19 @@ class SConsValues(optparse.Values): if value < 1: raise ValueError except ValueError: - raise SCons.Errors.UserError, "A positive integer is required: %s"%repr(value) + raise SCons.Errors.UserError("A positive integer is required: %s"%repr(value)) elif name == 'max_drift': try: value = int(value) except ValueError: - raise SCons.Errors.UserError, "An integer is required: %s"%repr(value) + raise SCons.Errors.UserError("An integer is required: %s"%repr(value)) elif name == 'duplicate': try: value = str(value) except ValueError: - raise SCons.Errors.UserError, "A string is required: %s"%repr(value) + raise SCons.Errors.UserError("A string is required: %s"%repr(value)) if not value in SCons.Node.FS.Valid_Duplicates: - raise SCons.Errors.UserError, "Not a valid duplication style: %s" % value + raise SCons.Errors.UserError("Not a valid duplication style: %s" % value) # Set the duplicate style right away so it can affect linking # of SConscript files. SCons.Node.FS.set_duplicate(value) @@ -167,8 +162,8 @@ class SConsValues(optparse.Values): try: value = diskcheck_convert(value) except ValueError, v: - raise SCons.Errors.UserError, "Not a valid diskcheck value: %s"%v - if not self.__dict__.has_key('diskcheck'): + raise SCons.Errors.UserError("Not a valid diskcheck value: %s"%v) + if 'diskcheck' not in self.__dict__: # No --diskcheck= option was specified on the command line. # Set this right away so it can affect the rest of the # file/Node lookups while processing the SConscript files. @@ -177,12 +172,12 @@ class SConsValues(optparse.Values): try: value = int(value) except ValueError: - raise SCons.Errors.UserError, "An integer is required: %s"%repr(value) + raise SCons.Errors.UserError("An integer is required: %s"%repr(value)) elif name == 'md5_chunksize': try: value = int(value) except ValueError: - raise SCons.Errors.UserError, "An integer is required: %s"%repr(value) + raise SCons.Errors.UserError("An integer is required: %s"%repr(value)) elif name == 'warn': if SCons.Util.is_String(value): value = [value] @@ -197,7 +192,7 @@ class SConsOption(optparse.Option): if self.nargs in (1, '?'): return self.check_value(opt, value) else: - return tuple(map(lambda v, o=opt, s=self: s.check_value(o, v), value)) + return tuple([self.check_value(opt, v) for v in value]) def process(self, opt, value, values, parser): @@ -214,7 +209,7 @@ class SConsOption(optparse.Option): def _check_nargs_optional(self): if self.nargs == '?' and self._short_opts: fmt = "option %s: nargs='?' is incompatible with short options" - raise SCons.Errors.UserError, fmt % self._short_opts[0] + raise SCons.Errors.UserError(fmt % self._short_opts[0]) try: _orig_CONST_ACTIONS = optparse.Option.CONST_ACTIONS @@ -292,7 +287,7 @@ class SConsOptionParser(optparse.OptionParser): # Value explicitly attached to arg? Pretend it's the next # argument. if "=" in arg: - (opt, next_arg) = string.split(arg, "=", 1) + (opt, next_arg) = arg.split("=", 1) rargs.insert(0, next_arg) had_explicit_value = True else: @@ -356,7 +351,7 @@ class SConsOptionParser(optparse.OptionParser): group = self.add_option_group(group) self.local_option_group = group - result = apply(group.add_option, args, kw) + result = group.add_option(*args, **kw) if result: # The option was added succesfully. We now have to add the @@ -461,7 +456,7 @@ class SConsIndentedHelpFormatter(optparse.IndentedHelpFormatter): result.append("%*s%s\n" % (self.help_position, "", line)) elif opts[-1] != "\n": result.append("\n") - return string.join(result, "") + return "".join(result) # For consistent help output across Python versions, we provide a # subclass copy of format_option_strings() and these two variables. @@ -473,7 +468,7 @@ class SConsIndentedHelpFormatter(optparse.IndentedHelpFormatter): def format_option_strings(self, option): """Return a comma-separated list of option strings & metavariables.""" if option.takes_value(): - metavar = option.metavar or string.upper(option.dest) + metavar = option.metavar or option.dest.upper() short_opts = [] for sopt in option._short_opts: short_opts.append(self._short_opt_fmt % (sopt, metavar)) @@ -489,7 +484,7 @@ class SConsIndentedHelpFormatter(optparse.IndentedHelpFormatter): else: opts = long_opts + short_opts - return string.join(opts, ", ") + return ", ".join(opts) def Parser(version): """ @@ -580,7 +575,7 @@ def Parser(version): raise OptionValueError("Warning: %s is not a valid config type" % value) setattr(parser.values, option.dest, value) opt_config_help = "Controls Configure subsystem: %s." \ - % string.join(config_options, ", ") + % ", ".join(config_options) op.add_option('--config', nargs=1, type="string", dest="config", default="auto", @@ -604,7 +599,7 @@ def Parser(version): debug_options = ["count", "explain", "findlibs", "includes", "memoizer", "memory", "objects", "pdb", "presub", "stacktrace", - "time"] + deprecated_debug_options.keys() + "time"] + list(deprecated_debug_options.keys()) def opt_debug(option, opt, value, parser, debug_options=debug_options, @@ -618,12 +613,12 @@ def Parser(version): parser.values.delayed_warnings = [] msg = deprecated_debug_options[value] w = "The --debug=%s option is deprecated%s." % (value, msg) - t = (SCons.Warnings.DeprecatedWarning, w) + t = (SCons.Warnings.DeprecatedDebugOptionsWarning, w) parser.values.delayed_warnings.append(t) else: raise OptionValueError("Warning: %s is not a valid debug type" % value) opt_debug_help = "Print various types of debugging information: %s." \ - % string.join(debug_options, ", ") + % ", ".join(debug_options) op.add_option('--debug', nargs=1, type="string", dest="debug", default=[], @@ -654,7 +649,7 @@ def Parser(version): SCons.Node.FS.set_duplicate(value) opt_duplicate_help = "Set the preferred duplication methods. Must be one of " \ - + string.join(SCons.Node.FS.Valid_Duplicates, ", ") + + ", ".join(SCons.Node.FS.Valid_Duplicates) op.add_option('--duplicate', nargs=1, type="string", @@ -802,7 +797,7 @@ def Parser(version): def opt_tree(option, opt, value, parser, tree_options=tree_options): import Main tp = Main.TreePrinter() - for o in string.split(value, ','): + for o in value.split(','): if o == 'all': tp.derived = False elif o == 'derived': @@ -816,7 +811,7 @@ def Parser(version): parser.values.tree_printers.append(tp) opt_tree_help = "Print a dependency tree in various formats: %s." \ - % string.join(tree_options, ", ") + % ", ".join(tree_options) op.add_option('--tree', nargs=1, type="string", @@ -846,7 +841,7 @@ def Parser(version): def opt_warn(option, opt, value, parser, tree_options=tree_options): if SCons.Util.is_String(value): - value = string.split(value, ',') + value = value.split(',') parser.values.warn.extend(value) op.add_option('--warn', '--warning', |