summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-07-27 17:27:45 (GMT)
committerSteven Knight <knight@baldmt.com>2003-07-27 17:27:45 (GMT)
commit784bfda1c79778638356ae85b3ff748c55aed544 (patch)
tree426a767241c944e22302050d4921df6a323a1ab8 /src
parented8786e2997389da9467e543b0be9173c486f235 (diff)
downloadSCons-784bfda1c79778638356ae85b3ff748c55aed544.zip
SCons-784bfda1c79778638356ae85b3ff748c55aed544.tar.gz
SCons-784bfda1c79778638356ae85b3ff748c55aed544.tar.bz2
Correct the spelling of validator.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/RELEASE.txt5
-rw-r--r--src/engine/SCons/Options.py21
-rw-r--r--src/engine/SCons/OptionsTests.py33
4 files changed, 52 insertions, 10 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index db99ddc..acefe96 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -58,6 +58,9 @@ RELEASE 0.XX - XXX
distutils warning message about adding the (incorrect) library
directory to your search path.
+ - Correct the spelling of the "validater" option to "validator."
+ Add a DeprecatedWarning when the old spelling is used.
+
From Gary Oberbrunner:
- Report the target being built in error messages when building
diff --git a/src/RELEASE.txt b/src/RELEASE.txt
index 298cfda..3cf87ca 100644
--- a/src/RELEASE.txt
+++ b/src/RELEASE.txt
@@ -27,6 +27,11 @@ RELEASE 0.XX - XXX
Please note the following important changes since release 0.90:
+ - The spelling of the 'validater' keyword argument to the
+ Options.Add() method has been corrected to 'validator'. The old
+ spelling still works but has been deprecated and generates a
+ warning.
+
Please note the following important changes since release 0.14:
- SCons now tries to verify that Microsoft Visual Studio (including
diff --git a/src/engine/SCons/Options.py b/src/engine/SCons/Options.py
index cbe642a..45f607f 100644
--- a/src/engine/SCons/Options.py
+++ b/src/engine/SCons/Options.py
@@ -29,9 +29,11 @@ variables to a scons build.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import os.path
+
import SCons.Errors
import SCons.Util
-import os.path
+import SCons.Warnings
class Options:
@@ -55,14 +57,14 @@ class Options:
self.files = files
- def Add(self, key, help="", default=None, validater=None, converter=None):
+ def Add(self, key, help="", default=None, validator=None, converter=None, **kw):
"""
Add an option.
key - the name of the variable
help - optional help text for the options
default - optional default value
- validater - optional function that is called to validate the option's value
+ validator - optional function that is called to validate the option's value
Called with (key, value, environment)
converter - optional function that is called to convert the option's value before
putting it in the environment.
@@ -71,6 +73,13 @@ class Options:
if not SCons.Util.is_valid_construction_var(key):
raise SCons.Errors.UserError, "Illegal Options.Add() key `%s'" % key
+ if kw.has_key('validater'):
+ SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
+ "The 'validater' keyword of the Options.Add() method is deprecated\n" +\
+ "and should be changed to 'validator'.")
+ if validator is None:
+ validator = kw['validater']
+
class Option:
pass
@@ -78,7 +87,7 @@ class Options:
option.key = key
option.help = help
option.default = default
- option.validater = validater
+ option.validator = validator
option.converter = converter
self.options.append(option)
@@ -129,8 +138,8 @@ class Options:
# Finally validate the values:
for option in self.options:
- if option.validater:
- option.validater(option.key, env.subst('${%s}'%option.key), env)
+ if option.validator:
+ option.validator(option.key, env.subst('${%s}'%option.key), env)
def Save(self, filename, env):
"""
diff --git a/src/engine/SCons/OptionsTests.py b/src/engine/SCons/OptionsTests.py
index 90ff153..87fbc9a 100644
--- a/src/engine/SCons/OptionsTests.py
+++ b/src/engine/SCons/OptionsTests.py
@@ -23,12 +23,14 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import string
+import sys
import unittest
import TestSCons
+
import SCons.Options
import SCons.Util
-import sys
-import string
+import SCons.Warnings
class Environment:
@@ -73,14 +75,14 @@ class OptionsTestCase(unittest.TestCase):
assert o.key == 'VAR'
assert o.help == ''
assert o.default == None
- assert o.validater == None
+ assert o.validator == None
assert o.converter == None
o = opts.options[1]
assert o.key == 'ANSWER'
assert o.help == 'THE answer to THE question'
assert o.default == "42"
- o.validater(o.key, o.converter(o.default), {})
+ o.validator(o.key, o.converter(o.default), {})
def test_it(var, opts=opts):
exc_caught = None
@@ -93,6 +95,29 @@ class OptionsTestCase(unittest.TestCase):
test_it('foo-bar')
test_it('foo.bar')
+ save = {}
+ save['warn'] = SCons.Warnings.warn
+ save['DeprecatedWarning'] = SCons.Warnings.DeprecatedWarning
+ def warn(type, message, save=save):
+ save['type'] = type
+ save['message'] = message
+ SCons.Warnings.warn = warn
+ SCons.Warnings.DeprecatedWarning = "xyzzy"
+
+ try:
+ opts.Add('MISSPELLED',
+ 'test using the old validater keyword',
+ "42",
+ validater=check,
+ converter=lambda x: int(x) + 12)
+ finally:
+ SCons.Warnings.DeprecatedWarning = save['DeprecatedWarning']
+ SCons.Warnings.warn = save['warn']
+ assert save['type'] == "xyzzy", save['type']
+ assert string.find(save['message'], "keyword of the Options.Add() method", save['message'] != -1), save['message']
+ o = opts.options[2]
+ o.validator(o.key, o.converter(o.default), {})
+
def test_Update(self):
"""Test updating an Environment"""