|
From: Michael F. <fuz...@vo...> - 2006-02-27 20:30:41
|
George Flaherty wrote:
> I have been evaluating ConfigObj4 and I was wondering if you could answer two questions.....
>
> 1. Can I have an ini file with empty values and some other values? Or am I missing some default option?
> Assume I have the following property file (notice no sections)
>
> foobar.mapfile=junk
> #Path to the .xml mapfile
>
> foobar.mapfile.name=morejunk
> #Path to the mapfile
>
> foobar.export.csvpath=
> #Path to the csv directory
>
>
Empty values are not currently supported by ConfigObj. Are they standard
in most other tools that use an 'ini style' format ?
I've never come across them before, but this is the second question
about them in as many weeks.
> My test code is the following:
> --------------------------------------------
> from configobj import ConfigObj
> import os
> import string
>
> def test():
> configFile = os.path.join('C:/georgef/work/pyWork/classes','test.properties')
> configHandler = ConfigObj(configFile)
> return configHandler['marketmax.export.csvpath']
>
> if __name__ == '__main__':
> print test()
>
> ***But this is raising a Parsing Error?
> Which seems to come from the empty property of "foobar.export.csvpath="
> Am I just missing some option?
>
>
> 2. I am attempting to utilize a single ini file to drive python and ant build scripts. So it would be ideal utilize a "sort-of-ant/java-interpolation" if possible: Again assume I have the following ini file.
>
> Myhome.dir=C:/foo/bar
> Myhome.bin=${Myhome.dir}/bin
>
> Is it possible to do something like ${value} vs. %(value)s?
>
>
ConfigObj supports ConfigParser style interpolation. Values to be
interpolated *from* should be in the 'DEFAULT' section.
See the ConfigParser docs for the style of interpolation it uses :
http://docs.python.org/lib/module-ConfigParser.html
And the ConfigObj docs for ConfigObj specific info :
http://www.voidspace.org.uk/python/configobj.html#interpolation
Basically is uses '%(name)s', so the short answer would be no.
However, by using the ``walk`` method of ConfigObj and copying the
interpolation code, it shouldn't be *that* hard to add yourself.
Lack of support for empty values may be a show stopper for you though.
All the best,
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
> Thank you
> George Flaherty
>
>
>
>
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
|