aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/configfile.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-10-16 11:45:20 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-10-16 11:45:20 -0400
commit08d03ae0ebaf64fe3a79a8b636c0d21d33f1d4ba (patch)
tree0b77184bc3ffa2f427a0eea7470ace4d6fa5b1e2 /klippy/configfile.py
parent368703fd78ae7256d8989acdc164b524e27cd320 (diff)
downloadkutter-08d03ae0ebaf64fe3a79a8b636c0d21d33f1d4ba.tar.gz
kutter-08d03ae0ebaf64fe3a79a8b636c0d21d33f1d4ba.tar.xz
kutter-08d03ae0ebaf64fe3a79a8b636c0d21d33f1d4ba.zip
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>
Diffstat (limited to 'klippy/configfile.py')
-rw-r--r--klippy/configfile.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/klippy/configfile.py b/klippy/configfile.py
index 57e61740..a7696324 100644
--- a/klippy/configfile.py
+++ b/klippy/configfile.py
@@ -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)