ConfigObj: possible to change the comment signifier?

19 views
Skip to first unread message

sgharvey

unread,
Mar 23, 2008, 12:57:02 PM3/23/08
to pythonutils
I'm assuming this is the right place to post this, because of all the
ConfigObj updates posted in here.


I've dug around the web and in the ConfigObj documentation...

Is it possible to change what character is used to signify a comment?
Say, from '#' to ';'?

I need to parse an .ini file created by an AXIS 70U, a device
whose .ini format I cannot change... worst comes to worst, I can just
work out something involving re.sub, but I'd rather not (another place
for things to go wrong in).

Thanks,
Samuel Harvey

Michael Foord

unread,
Mar 23, 2008, 1:51:09 PM3/23/08
to pytho...@googlegroups.com

Hello Samuel,

This list is rather old and abandoned. ConfigObj has its own list:

https://lists.sourceforge.net/lists/listinfo/configobj-develop

A deliberate decision was made to make ConfigObj rather stricter than
ConfigParser in the comment characters it accepts. This makes the config
files it works with more uniform and the parser rather nicer.

You've discovered the downside to the this decision. :-)

Changing the behaviour of ConfigObj would mean changing the regular
expressions it uses in its core parser. I don't think it is a
modification we could accept back into the core - so I'm afraid you'd be
a bit on your own with it. Sorry.

It looks like an re.sub approach might be better.

Michael Foord
http://www.manning.com/foord

> Thanks,
> Samuel Harvey
> >

sgharvey

unread,
Mar 24, 2008, 2:41:47 AM3/24/08
to pythonutils
On Mar 23, 10:51 am, Michael Foord <fuzzy...@voidspace.org.uk> wrote:
> sgharvey wrote:
> > Is it possible to change what character is used to signify a comment?
> > Say, from '#' to ';'?
>
> Hello Samuel,
>
> Changing the behaviour of ConfigObj would mean changing the regular
> expressions it uses in its core parser. I don't think it is a
> modification we could accept back into the core - so I'm afraid you'd be
> a bit on your own with it. Sorry.
>
> It looks like an re.sub approach might be better.
>
> Michael Foordhttp://www.manning.com/foord
>
> > Thanks,
> > Samuel Harvey

Eh, such is life. I've had so much fun writing my own parser
anyways...

Thanks,
Samuel
Reply all
Reply to author
Forward
0 new messages