diff --git a/tools/python/jwutils/stree/serdes.py b/tools/python/jwutils/stree/serdes.py index 953fc53..eb1d8fd 100644 --- a/tools/python/jwutils/stree/serdes.py +++ b/tools/python/jwutils/stree/serdes.py @@ -1,13 +1,28 @@ from StringTree import * from jwutils.log import * +def _cleanup_line(line): + line = line.strip() + r = '' + in_quote = None + for c in line: + if c == in_quote: + in_quote = None + else: + if c in [ '"', "'" ]: + in_quote = c + elif c == '#': + return r.strip() + r += c + return r + def parse(s): # export slog(DEBUG, "parsing", s) root = StringTree('', content='root') sec = '' for line in s.splitlines(): slog(DEBUG, "line=", line) - line = line.strip() + line = _cleanup_line(line) if not len(line): continue if line[0] == '[':