mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
StringTree fix: Comments were not ignored in quotes
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
07a328d9a8
commit
7007c894b8
2 changed files with 8 additions and 8 deletions
|
|
@ -26,7 +26,7 @@ def cleanup_string(s):
|
||||||
return s
|
return s
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
if is_quoted(s):
|
if is_quoted(s):
|
||||||
return s[1:-1]
|
return s[1:-1].replace('\\' + s[0], s[0])
|
||||||
return s
|
return s
|
||||||
|
|
||||||
class StringTree: # export
|
class StringTree: # export
|
||||||
|
|
@ -52,18 +52,18 @@ class StringTree: # export
|
||||||
logcontent = "not-yet"
|
logcontent = "not-yet"
|
||||||
if hasattr(self, "content"):
|
if hasattr(self, "content"):
|
||||||
logcontent = self.content
|
logcontent = self.content
|
||||||
slog(DEBUG, "+ setting", content, "at path \"" + str(path_) + "\" to", logcontent)
|
slog(DEBUG, "+ setting >" + str(content) + "< at path \"" + str(path_) + "\" to", logcontent)
|
||||||
if content is not None:
|
|
||||||
content = cleanup_string(content)
|
|
||||||
if path_ is None:
|
if path_ is None:
|
||||||
self.content = content
|
self.content = cleanup_string(content)
|
||||||
|
slog(DEBUG, " -- content = >" + str(content) + "<, self.content = >" + str(self.content) + "<")
|
||||||
return self
|
return self
|
||||||
path = cleanup_string(path_)
|
path = cleanup_string(path_)
|
||||||
components = path.split('.')
|
components = path.split('.')
|
||||||
l = len(components)
|
l = len(components)
|
||||||
if len(path) == 0 or l == 0:
|
if len(path) == 0 or l == 0:
|
||||||
assert self.content is None
|
assert self.content is None
|
||||||
self.content = content
|
self.content = cleanup_string(content)
|
||||||
|
slog(DEBUG, " -- content = >" + str(content) + "<, self.content = >" + str(self.content) + "<")
|
||||||
#self.children[content] = StringTree(None, content)
|
#self.children[content] = StringTree(None, content)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ class StringTree: # export
|
||||||
def value(self):
|
def value(self):
|
||||||
if len(self.children) == 0:
|
if len(self.children) == 0:
|
||||||
return None
|
return None
|
||||||
return next(reversed(self.children))
|
return self.children[next(reversed(self.children))].content
|
||||||
|
|
||||||
def dump(self, prio, caller=None, *args):
|
def dump(self, prio, caller=None, *args):
|
||||||
if caller is None:
|
if caller is None:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ def _cleanup_line(line):
|
||||||
else:
|
else:
|
||||||
if c in [ '"', "'" ]:
|
if c in [ '"', "'" ]:
|
||||||
in_quote = c
|
in_quote = c
|
||||||
elif c == '#':
|
elif in_quote is None and c == '#':
|
||||||
return r.strip()
|
return r.strip()
|
||||||
r += c
|
r += c
|
||||||
return r
|
return r
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue