New Thread- Supporting Multiline values in ConfigParser
gagsl-py2 at yahoo.com.ar
Tue Jun 26 03:26:47 CEST 2007
En Mon, 25 Jun 2007 11:06:04 -0300, Phoe6 <orsenthil at gmail.com> escribió:
> I took the approach of Subclassing ConfigParser to support multiline
> values without leading white-spaces, but am struct at which position
> in _read I should modify to accomodate the non-leading whitespace
> based multiline values.
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.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:
(that is, if the line is not a section header and it's not a new option
and there is a current section and option; those two last conditions same
as the previous version).
But you'll have to experiment - I've not tested it.
More information about the Python-list