mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
Fix: StringTree misparsed key = "val # blah"
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
150bf5fd69
commit
838ac06ebb
1 changed files with 7 additions and 2 deletions
|
|
@ -6,14 +6,18 @@ def _cleanup_line(line):
|
||||||
r = ''
|
r = ''
|
||||||
in_quote = None
|
in_quote = None
|
||||||
for c in line:
|
for c in line:
|
||||||
if c == in_quote:
|
# slog(DEBUG, "in_quote = >" + str(in_quote) + "<")
|
||||||
in_quote = None
|
if in_quote is not None:
|
||||||
|
if c == in_quote:
|
||||||
|
in_quote = None
|
||||||
else:
|
else:
|
||||||
if c in [ '"', "'" ]:
|
if c in [ '"', "'" ]:
|
||||||
in_quote = c
|
in_quote = c
|
||||||
elif in_quote is None and c == '#':
|
elif in_quote is None and c == '#':
|
||||||
return r.strip()
|
return r.strip()
|
||||||
r += c
|
r += c
|
||||||
|
if len(r) >= 2 and r[0] in [ '"', "'" ] and r[-1] == r[0]:
|
||||||
|
return r[1:-1]
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def parse(s): # export
|
def parse(s): # export
|
||||||
|
|
@ -23,6 +27,7 @@ def parse(s): # export
|
||||||
for line in s.splitlines():
|
for line in s.splitlines():
|
||||||
slog(DEBUG, "line=", line)
|
slog(DEBUG, "line=", line)
|
||||||
line = _cleanup_line(line)
|
line = _cleanup_line(line)
|
||||||
|
#slog(DEBUG, "cleaned line=", line)
|
||||||
if not len(line):
|
if not len(line):
|
||||||
continue
|
continue
|
||||||
if line[0] == '[':
|
if line[0] == '[':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue