mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +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
|
||||
s = s.strip()
|
||||
if is_quoted(s):
|
||||
return s[1:-1]
|
||||
return s[1:-1].replace('\\' + s[0], s[0])
|
||||
return s
|
||||
|
||||
class StringTree: # export
|
||||
|
|
@ -52,18 +52,18 @@ class StringTree: # export
|
|||
logcontent = "not-yet"
|
||||
if hasattr(self, "content"):
|
||||
logcontent = self.content
|
||||
slog(DEBUG, "+ setting", content, "at path \"" + str(path_) + "\" to", logcontent)
|
||||
if content is not None:
|
||||
content = cleanup_string(content)
|
||||
slog(DEBUG, "+ setting >" + str(content) + "< at path \"" + str(path_) + "\" to", logcontent)
|
||||
if path_ is None:
|
||||
self.content = content
|
||||
self.content = cleanup_string(content)
|
||||
slog(DEBUG, " -- content = >" + str(content) + "<, self.content = >" + str(self.content) + "<")
|
||||
return self
|
||||
path = cleanup_string(path_)
|
||||
components = path.split('.')
|
||||
l = len(components)
|
||||
if len(path) == 0 or l == 0:
|
||||
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)
|
||||
return self
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ class StringTree: # export
|
|||
def value(self):
|
||||
if len(self.children) == 0:
|
||||
return None
|
||||
return next(reversed(self.children))
|
||||
return self.children[next(reversed(self.children))].content
|
||||
|
||||
def dump(self, prio, caller=None, *args):
|
||||
if caller is None:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ def _cleanup_line(line):
|
|||
else:
|
||||
if c in [ '"', "'" ]:
|
||||
in_quote = c
|
||||
elif c == '#':
|
||||
elif in_quote is None and c == '#':
|
||||
return r.strip()
|
||||
r += c
|
||||
return r
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue