|
From: Fuzzyman <fuz...@vo...> - 2005-12-14 09:27:48
|
Jim Vickroy wrote:
> Is interpolation supported in default specifications or is this a
> total abuse of the package? If interpolations are supported, then I
> do not understand how to make them work in the specification file.
> Here is the output from the attached script:
>
Interpolation is working - there is a bug in your logic :-D
Your string containing the interpolation value is :
string(default="fuzzy-%(man)s")
You have defined 'man' in your DEFAULT section to be :
string(default="man")
So ConfigObj replaces ``%(man)s`` with ``string(default="man")``. The
result is :
fuzzy-string(default="man")
Try replacing the line in your DEFAULT section with :
man = wuzzy
That should do something a bit more expected. :-)
*However* - that will then raise an error because the default section
doesn't contain a valid check.
Your code will still print "validation succeeded" - because check is now
a dictionary, which doesn't evaluate to False.
if check:
print '*** validation succeeded ***'
Should be changed to :
if check == True::
print '*** validation succeeded ***'
The answer is for validation to *not* be done on the 'DEFAULT' section.
I'm targeting all the discussed recent changes/bugfixes for a 4.1.0 release.
All the best,
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
> <output>
> sys.platform: win32
> sys.version: 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC
> v.1310 32 bit (Intel)]
> sys.getwindowsversion(): (5, 1, 2600, 2, 'Service Pack 2')
> sys.winver: 2.4
>
> configobj.__version__: 4.0.2
> validate.__version__: 0.2.0
>
> *** validation succeeded ***
> Traceback (most recent call last):
> File "C:\Documents and Settings\jim.vickroy\My
> Documents\Projects\_experimental_\pythonutils\configobj\test-reader.py",
> line 55, in ?
> assert facts['interpolated string'] == 'fuzzy-man',
> facts['interpolated string']
> AssertionError: fuzzy-string(default="man")
> </output>
>
>
> Thanks,
> -- jv
|