From 838ac06ebbfa4bed78ae77d4cb74050cc6f73994 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 26 Nov 2017 21:25:01 +0100 Subject: [PATCH] Fix: StringTree misparsed key = "val # blah" Signed-off-by: Jan Lindemann --- tools/python/jwutils/stree/serdes.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/python/jwutils/stree/serdes.py b/tools/python/jwutils/stree/serdes.py index c36fd2b..c712438 100644 --- a/tools/python/jwutils/stree/serdes.py +++ b/tools/python/jwutils/stree/serdes.py @@ -6,14 +6,18 @@ def _cleanup_line(line): r = '' in_quote = None for c in line: - if c == in_quote: - in_quote = None + # slog(DEBUG, "in_quote = >" + str(in_quote) + "<") + if in_quote is not None: + if c == in_quote: + in_quote = None else: if c in [ '"', "'" ]: in_quote = c 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] == '[':