New Thread- Supporting Multiline values in ConfigParser
O.R.Senthil Kumaran
orsenthil at users.sourceforge.net
Wed Jun 27 00:35:27 EDT 2007
* Gabriel Genellina <gagsl-py2 at yahoo.com.ar> [2007-06-25 22:26:47]:
> And how would you detect a multiline value?
> Because it is not a section nor looks like a new option?
>
> > I can guess, this portion in the _read function will require change,
> > any change to this affects the whole of parsing. :-( Can someone who
> > has done this before or understands ConfigParser better help me?
> >
> > # Section I am talking about
> > if line[0].isspace() and cursect is not None
> > and optname:
> >
> > value = line.strip()
> > if value:
> > cursect[optname] = "%s\n%s" %
> > (cursect[optname], value)
>
> Yes, I guess so.
> I'd try using this:
>
> if not self.SECTCRE.match(line) and not self.OPTCRE.match(line) and
> cursect is not None and optname:
>
Thanks Gabriel, this suggestion worked and helped me understand the
ConfigParser a bit better as well.
--
O.R.Senthil Kumaran
http://uthcode.sarovar.org
More information about the Python-list
mailing list