[pypy-svn] r33144 - in pypy/branch/even-more-config2/pypy/config: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Oct 11 00:16:58 CEST 2006


Author: cfbolz
Date: Wed Oct 11 00:16:56 2006
New Revision: 33144

Modified:
   pypy/branch/even-more-config2/pypy/config/config.py
   pypy/branch/even-more-config2/pypy/config/test/test_config.py
Log:
remove hack that allowed one to use --usemodules=... because it is no longer
needed.


Modified: pypy/branch/even-more-config2/pypy/config/config.py
==============================================================================
--- pypy/branch/even-more-config2/pypy/config/config.py	(original)
+++ pypy/branch/even-more-config2/pypy/config/config.py	Wed Oct 11 00:16:56 2006
@@ -301,32 +301,7 @@
                       for child in self._children])
 
     def add_optparse_option(self, argnames, parser, config):
-        for child in self._children:
-            if (not isinstance(child, BoolOption) or
-                child.cmdline is not DEFAULT_OPTION_NAME):
-                raise ValueError(
-                    "cannot make OptionDescription %s a cmdline option" % (
-                        self._name, ))
-        def _callback(option, opt_str, value, parser, *args, **kwargs):
-            try:
-                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, set_to, who='cmdline')
-            except ValueError, e:
-                raise optparse.OptionValueError(e.args[0])
-        option = parser.add_option(help=self.doc, action='callback',
-                                   type='string', callback=_callback,
-                                   *argnames)
+        return
 
 
 def to_optparse(config, useoptions=None, parser=None):
@@ -362,11 +337,7 @@
                 continue
             else:
                 chunks = option.cmdline.split(' ')
-            try:
-                grp = get_group(path, subconf._cfgimpl_descr.doc)
-                option.add_optparse_option(chunks, grp, subconf)
-            except ValueError:
-                # an option group that does not only contain bool values
-                pass
+            grp = get_group(path, subconf._cfgimpl_descr.doc)
+            option.add_optparse_option(chunks, grp, subconf)
     return parser
 

Modified: pypy/branch/even-more-config2/pypy/config/test/test_config.py
==============================================================================
--- pypy/branch/even-more-config2/pypy/config/test/test_config.py	(original)
+++ pypy/branch/even-more-config2/pypy/config/test/test_config.py	Wed Oct 11 00:16:56 2006
@@ -174,50 +174,6 @@
     py.test.raises(SystemExit,
             "(options, args) = parser.parse_args(args=['--no-bool4'])")
 
-def test_optparse_boolgroup():
-    group = OptionDescription("test", '', [
-        BoolOption("smallint", "use tagged integers",
-                   default=False),
-        BoolOption("strjoin", "use strings optimized for addition",
-                   default=False),
-        BoolOption("strslice", "use strings optimized for slicing",
-                   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)
-    parser = to_optparse(config, ['test'])
-    (options, args) = parser.parse_args(
-        args=['--test=smallint,strjoin,strdict'])
-    
-    assert config.test.smallint
-    assert config.test.strjoin
-    assert config.test.strdict
-    assert config.test.normal
-
-    config = Config(descr)
-    parser = to_optparse(config, ['test'])
-    (options, args) = parser.parse_args(
-        args=['--test=smallint'])
-    
-    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()
     config = Config(descr)



More information about the Pypy-commit mailing list