[pypy-svn] r32827 - in pypy/dist/pypy/config: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon Oct 2 17:23:06 CEST 2006
Author: cfbolz
Date: Mon Oct 2 17:23:04 2006
New Revision: 32827
Modified:
pypy/dist/pypy/config/config.py
pypy/dist/pypy/config/test/test_config.py
Log:
make it possible to say --usemodules=-math to disable a module which is by
default enabled.
Modified: pypy/dist/pypy/config/config.py
==============================================================================
--- pypy/dist/pypy/config/config.py (original)
+++ pypy/dist/pypy/config/config.py Mon Oct 2 17:23:04 2006
@@ -284,11 +284,16 @@
values = value.split(",")
for value in values:
value = value.strip()
+ if value.startswith("-"):
+ value = value[1:]
+ set_to = False
+ else:
+ set_to = True
option = getattr(self, value, None)
if option is None:
raise ValueError("did not find option %s" % (value, ))
getattr(config, self._name).setoption(
- value, True, who='cmdline')
+ value, set_to, who='cmdline')
except ValueError, e:
raise optparse.OptionValueError(e.args[0])
parser.add_option(help=self._name, action='callback', type='string',
Modified: pypy/dist/pypy/config/test/test_config.py
==============================================================================
--- pypy/dist/pypy/config/test/test_config.py (original)
+++ pypy/dist/pypy/config/test/test_config.py Mon Oct 2 17:23:04 2006
@@ -167,6 +167,8 @@
default=False),
BoolOption("strdict", "use dictionaries optimized for string keys",
default=False),
+ BoolOption("normal", "do nothing special",
+ default=True),
], cmdline="--test")
descr = OptionDescription("all", '', [group])
config = Config(descr)
@@ -177,6 +179,7 @@
assert config.test.smallint
assert config.test.strjoin
assert config.test.strdict
+ assert config.test.normal
config = Config(descr)
parser = to_optparse(config, ['test'])
@@ -186,6 +189,17 @@
assert config.test.smallint
assert not config.test.strjoin
assert not config.test.strdict
+ assert config.test.normal
+
+ config = Config(descr)
+ parser = to_optparse(config, ['test'])
+ (options, args) = parser.parse_args(
+ args=['--test=-normal,smallint'])
+
+ assert config.test.smallint
+ assert not config.test.strjoin
+ assert not config.test.strdict
+ assert not config.test.normal
def test_config_start():
descr = make_description()
More information about the pypy-svn
mailing list