|
From: Michael F. <ar...@vo...> - 2008-10-14 22:12:54
|
Steve Lee wrote:
> Hi I've just discovered configObj through some software I'm working on
> and find it very useful and well designed
>
> However I have a problem with using # in default strings
>
> colour = string(default="#ff00dd")
>
> errors. It appears the # is incorrectly being interpreted as a
> comment, and looks like a bug in the regular expression.
>
> Is this a known problem and does it have a workaround? I can't see any
> way to have a literal #
>
>
Damn - so it turns out that the only way to tell if a hash is inside
quotes or a comment marker is to parse the string fully. As most of the
parsing (pulling out list values with or without quotes etc) is done
inside validate it would be 'inconvenient' to move this inside ConfigObj.
This is because configspecs actually have a slightly different syntax to
normal ConfigObj - even with 'list_values' set to False this is invalid
syntax:
name = string(default="#ff00dd")
You can actually get round this by using triple quotes:
name = '''string(default="#ff00dd")'''
Slightly ugly but it works. I'm working on a longer term fix where
ConfigObj won't parse comments in configspecs - and let validate remove
them instead (implementing support for comments in validate itself).
Michael
> thanks
>
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.theotherdelia.co.uk/
http://www.resolverhacks.net/
|