|
From: <Jim...@no...> - 2005-12-14 12:36:32
|
----- Original Message ----- From: Fuzzyman <fuz...@vo...> Date: Wednesday, December 14, 2005 2:29 am Subject: Re: [Configobj-develop] interpolation supported in the specification file ? > 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. :-) OK, thanks for the correction. > > *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 ***' Thanks again. > > The answer is for validation to *not* be done on the 'DEFAULT' > section. Is it, therefore, correct to conclude that interpolations are best done in a config file because, if present in a configspec file, they can not be validated, but that this will change with the 4.1.0 release? > 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 > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through > log files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD > SPLUNK!http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |