[pypy-svn] r32062 - in pypy/branch/config-in-more-places/pypy/config: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Sep 7 18:34:28 CEST 2006


Author: cfbolz
Date: Thu Sep  7 18:34:26 2006
New Revision: 32062

Modified:
   pypy/branch/config-in-more-places/pypy/config/config.py
   pypy/branch/config-in-more-places/pypy/config/test/test_config.py
Log:
if no paths are specified, all options are created


Modified: pypy/branch/config-in-more-places/pypy/config/config.py
==============================================================================
--- pypy/branch/config-in-more-places/pypy/config/config.py	(original)
+++ pypy/branch/config-in-more-places/pypy/config/config.py	Thu Sep  7 18:34:26 2006
@@ -104,7 +104,8 @@
                 if include_groups:
                     paths.append('.'.join(currpath + [attr]))
                 currpath.append(attr)
-                paths += value.getpaths(currpath=currpath)
+                paths += value.getpaths(include_groups=include_groups,
+                                        currpath=currpath)
                 currpath.pop()
             else:
                 paths.append('.'.join(currpath + [attr]))
@@ -267,9 +268,11 @@
                           callback=_callback, *argnames)
 
 
-def to_optparse(config, parser=None):
+def to_optparse(config, useoptions=None, parser=None):
     if parser is None:
         parser = optparse.OptionParser()
+    if useoptions is None:
+        useoptions = config.getpaths(include_groups=True)
     for path in useoptions:
         if path.endswith(".*"):
             path = path[:-2]
@@ -287,6 +290,10 @@
                 continue
             else:
                 chunks = option.cmdline.split(' ')
-            option.add_optparse_option(chunks, parser, subconf)
+            try:
+                option.add_optparse_option(chunks, parser, subconf)
+            except ValueError:
+                # an option group that does not only contain bool values
+                pass
     return parser
 

Modified: pypy/branch/config-in-more-places/pypy/config/test/test_config.py
==============================================================================
--- pypy/branch/config-in-more-places/pypy/config/test/test_config.py	(original)
+++ pypy/branch/config-in-more-places/pypy/config/test/test_config.py	Thu Sep  7 18:34:26 2006
@@ -221,7 +221,7 @@
     group = OptionDescription('group', [dummy1, dummy2])
     config = Config(group)
 
-    parser = to_optparse(config, config.getpaths())
+    parser = to_optparse(config)
     py.test.raises(SystemExit,
         "(options, args) = parser.parse_args(args=['--dummy1'])")
  



More information about the Pypy-commit mailing list