I'm trying to parse a .conf file with ConfigParser, and some of the values have a '%' in the value.
Example of the config below:
[global]
workgroup = WORKGROUP
server string = %h server (Samba, Ubuntu)
When I parse this using RawConfigParser, it sets server string
to
%h server (Samba, Ubuntu)\n\n\n\ndns proxy = no\n\n\n\n\n\n\n\n...REST_OF_CONFIG_SECTION
Where the bunch of \n
are blank lines between config options. And when I use the normal ConfigParser
, I get an InterpolationSyntaxError
with the error
'%' must be followed by '%' or '(', found: '%h server (Samba, Ubuntu)\n\n\n\ndns proxy = no\n\n\n\n\n\n\n\n
Editing the string before passing it to ConfigParser (replacing % with %%) parses it, but does the same issue as RawConfigParser where it parses the rest of the options as a single line.
How am I supposed to properly parse values that have a % in them?