Feature request

9 views
Skip to first unread message

haizaar

unread,
Oct 4, 2009, 9:59:25 AM10/4/09
to iniparse-discuss
Good day iniparse developers. The module works great, however it would
be great to have this additional functionality:

1. iniparse claims to be fully compatible with ConfigParser, however
it does not support value substitution documented here
http://docs.python.org/library/configparser.html (see first ini file
example).

2. I'd really like to be able to put spaces/tabs before keyword. Like
this:
[mysection]
fruite = apple
vegetable = tomato

Thanks!

--
Zaar

Paramjit Oberoi

unread,
Oct 5, 2009, 10:34:20 AM10/5/09
to iniparse...@googlegroups.com
Variable substitution is only implemented in the backward compatible
ConfigParser interface at the moment. The attribute access interface
does not support it. But you're right - it should.

Leading spaces/tabs cause a syntax error with ConfigParser... so do
you mean you'd like a relaxed parsing mode that allows it, even though
it would be incompatible?

-param

haizaar

unread,
Oct 6, 2009, 6:28:03 AM10/6/09
to iniparse-discuss


On Oct 5, 5:34 pm, Paramjit Oberoi <psobe...@gmail.com> wrote:
> Variable substitution is only implemented in the backward compatible
> ConfigParser interface at the moment.  The attribute access interface
> does not support it.  But you're right - it should.
Is it hard to implement? May be you can provide me with some pointer
on how to do it myself.

>
> Leading spaces/tabs cause a syntax error with ConfigParser... so do
> you mean you'd like a relaxed parsing mode that allows it, even though
> it would be incompatible?
Actually I'm new to Python and was pretty surprised with the fact that
leading spaces/tabs are not supported, because in other C/C++
libraries I've used so far it was OK. As far as I've seen Ruby config
parser supports this feature as well.
I would not call incompatible, it would be still backward-compatible
with ConfigParser. Iniparse will just have more features.
If you implement it, I'm ready to test it right away.

>
> -param
>
> On Sun, Oct 4, 2009 at 6:59 AM, haizaar <haiz...@gmail.com> wrote:
>
> > Good day iniparse developers. The module works great, however it would
> > be great to have this additional functionality:
>
> > 1. iniparse claims to be fully compatible with ConfigParser, however
> > it does not support value substitution documented here
> >http://docs.python.org/library/configparser.html(see first ini file

Paramjit Oberoi

unread,
Oct 13, 2009, 10:09:48 AM10/13/09
to iniparse...@googlegroups.com, hai...@gmail.com
Hi,

Sorry for not replying promptly... Too much real-life going on at the moment.

> Is it hard to implement? May be you can provide me with some pointer
> on how to do it myself.

The implementation of variable interpolation is quite straightforward
- see the _interpolate() function in compat.ConfigParser and
compat.SafeConfigParser. That will have to move to a function within
INISection, I suppose.

The complicated questions are: (1) how do turn interpolation on and
off. Maybe use separate classes, like ConfigParser does? That's a
bit more convoluted since there are multiple iniparse classes -
INIConfig and INISection. (2) Remove existing variable interpolation
code from the compat.* classes, and make sure they work without it.

> Actually I'm new to Python and was pretty surprised with the fact that
> leading spaces/tabs are not supported, because in other C/C++
> libraries I've used so far it was OK. As far as I've seen Ruby config
> parser supports this feature as well.
> I would not call  incompatible, it would be still backward-compatible
> with ConfigParser. Iniparse will just have more features.
> If you implement it, I'm ready to test it right away.

I'll think about the feature... meanwhile, here's one thing you can
do. INIParse supports parsing streams instead of files. If you
wrapped your file in a function that removed leading whitespace on
reading, and added it back on writing, you could get this behavior
without any changes to iniparse.

-param

Reply all
Reply to author
Forward
0 new messages