configfile: Strip trailing comments
The Python 2.x ConfigParser doesn't support stripping of trailing '#' style comments. Do that manually before parsing the config. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
368703fd78
commit
08d03ae0eb
|
@ -150,6 +150,14 @@ class PrinterConfig:
|
|||
lines[lineno] = '#' + lines[lineno]
|
||||
return "\n".join(lines)
|
||||
def _build_config_wrapper(self, data):
|
||||
# Strip trailing comments from config
|
||||
lines = data.split('\n')
|
||||
for i, line in enumerate(lines):
|
||||
pos = line.find('#')
|
||||
if pos >= 0:
|
||||
lines[i] = line[:pos]
|
||||
data = '\n'.join(lines)
|
||||
# Read and process config file
|
||||
sfile = StringIO.StringIO(data)
|
||||
fileconfig = ConfigParser.RawConfigParser()
|
||||
fileconfig.readfp(sfile)
|
||||
|
|
Loading…
Reference in New Issue