ConfigParser
Manlio Perillo
NOmanlio_perilloSPAM at libero.it
Wed Nov 10 12:03:30 EST 2004
On Wed, 10 Nov 2004 15:39:42 +0100, Ivo Woltring <Python at IvoNet.nl>
wrote:
>On Wed, 10 Nov 2004 10:39:27 GMT, Manlio Perillo
><NOmanlio_perilloSPAM at libero.it> wrote:
>
>>Regards.
>>
>>Since sections in CongiParser files are delimited by [ and ], why
>>there is not an escape (and unescape) function for escaping
>>&, [, and ] characters to &, [ and ] ?
>>
>>
>>
>>
>>Thanks Manlio Perillo
>
>just subclass from ConfigParser and add the functionality youself
>
Actually I have written two functions:
def escape(data):
"""Escape &, [ and ] a string of data.
"""
data = data.replace("&", "&")
data = data.replace("[", "[")
data = data.replace("]", "]")
return data
def unescape(data):
"""Unescape &, <, and > in a string of data.
"""
data = data.replace("[", "[")
data = data.replace("]", "]")
# must do ampersand last
return data.replace("&", "&")
Maybe also '\n' to &nl; translation should be performed.
Thanks and regards Manlio Perillo
More information about the Python-list
mailing list