Reading multiline values using ConfigParser
jkrukoff at ltgc.com
Thu Jun 21 16:34:50 CEST 2007
> -----Original Message-----
> From: python-list-bounces+jkrukoff=ltgc.com at python.org [mailto:python-
> list-bounces+jkrukoff=ltgc.com at python.org] On Behalf Of Phoe6
> Sent: Wednesday, June 20, 2007 8:51 PM
> To: python-list at python.org
> Subject: Re: Reading multiline values using ConfigParser
> On Jun 20, 10:35 pm, "John Krukoff" <jkruk... at ltgc.com> wrote:
> > > Is there anyway, I can include multi-line value in the configfile? I
> > Following the link to RFC 822 (http://www.faqs.org/rfcs/rfc822.html)
> > indicates that you can spread values out over multiple lines as long as
> > there is a space or tab character imeediately after the CRLF.
> Thanks for the response. It did work!
> >>> config = ConfigParser()
> >>> config.read("Testcases.txt")
> >>> output = config.get("Information", "Testcases")
> >>> print output
> >>> output
> However, as I am going to provide Testcases.txt to be "user editable",
> I cannot assume or "ask users" to provide value testcases surronded by
> spaces. I got to figure out a workaround here.
Sounds like you're stuck modifying ConfigParser to do what you want, or
writing your own configuration file parsing utilities.
>From looking through the ConfigParser source, looks like all the parsing
work is inside the _read method, so shouldn't be too painful to make a
subclass that does what you want.
helot at comcast.net
More information about the Python-list