changeset 69:b9d9a94bfa19

override section now works
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 09 Jun 2011 09:36:08 -0700
parents 65609d7ba63d
children 7ec0ca0134ff
files pyloader/factory.py tests/test.ini tests/test_ini.txt
diffstat 3 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pyloader/factory.py	Thu Jun 09 09:29:06 2011 -0700
+++ b/pyloader/factory.py	Thu Jun 09 09:36:08 2011 -0700
@@ -8,6 +8,7 @@
 import loader
 import os
 import sys
+from copy import deepcopy
 from optparse import OptionParser
 from ConfigParser import InterpolationDepthError
 from ConfigParser import InterpolationMissingOptionError
@@ -183,7 +184,7 @@
                     if overridden_section in seen:
                         pass # TODO
                     create_section(overridden_section, iniconfig[overridden_section])
-                # TODO: sect = config[path].copy()
+                sect = deepcopy(config[path])
 
             if 'path' not in sect:
                 # add the path to section dict
--- a/tests/test.ini	Thu Jun 09 09:29:06 2011 -0700
+++ b/tests/test.ini	Thu Jun 09 09:36:08 2011 -0700
@@ -15,6 +15,6 @@
 [foo:@:fibonacci]
 
 [bar:fibonacci]
-n=1
+n=5
 
 [extended-fibonacci:@:four=4,five=5:fibonacci]
--- a/tests/test_ini.txt	Thu Jun 09 09:29:06 2011 -0700
+++ b/tests/test_ini.txt	Thu Jun 09 09:36:08 2011 -0700
@@ -48,3 +48,9 @@
     '%(fibonacci)s'
     >>> [fib(i) for i in range(6)]
     ['one', 'one', 'two', 'three', 5, 8]
+
+Override a section with additional arguments, [bar:fibonacci], n=5::
+
+    >>> bar = inifactory.load('bar')
+    >>> bar # [1,1,2,3,5,8][5]
+    8