Fix: StringTree misparsed key = "val # blah"

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2017-11-26 21:25:01 +01:00
commit 838ac06ebb

View file

@ -6,6 +6,8 @@ def _cleanup_line(line):
r = ''
in_quote = None
for c in line:
# slog(DEBUG, "in_quote = >" + str(in_quote) + "<")
if in_quote is not None:
if c == in_quote:
in_quote = None
else:
@ -14,6 +16,8 @@ def _cleanup_line(line):
elif in_quote is None and c == '#':
return r.strip()
r += c
if len(r) >= 2 and r[0] in [ '"', "'" ] and r[-1] == r[0]:
return r[1:-1]
return r
def parse(s): # export
@ -23,6 +27,7 @@ def parse(s): # export
for line in s.splitlines():
slog(DEBUG, "line=", line)
line = _cleanup_line(line)
#slog(DEBUG, "cleaned line=", line)
if not len(line):
continue
if line[0] == '[':