From 5a87040e101fa39a5e0a44eb44e0cf46653eafe4 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 12 Nov 2017 16:08:34 +0100 Subject: [PATCH] stree/serdes.py: Allow quoted = in rhs of assignment Signed-off-by: Jan Lindemann --- tools/python/jwutils/stree/serdes.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/python/jwutils/stree/serdes.py b/tools/python/jwutils/stree/serdes.py index 50e5c07..b3b575f 100644 --- a/tools/python/jwutils/stree/serdes.py +++ b/tools/python/jwutils/stree/serdes.py @@ -41,11 +41,20 @@ def parse(s): # export assert(len(sec) > 0) sec = '.'.join(sec.split('.')[0:-1]) continue - assignment = line.split('=') - if len(assignment) != 2: + lhs = '' + rhs = None + for c in line: + if rhs is None: + if c == '=': + rhs = '' + continue + lhs += c + continue + rhs += c + + if rhs is None: raise Exception("failed to parse assignment", line) - slog(DEBUG, "sec=", sec, "assignment=", assignment) - root.add(sec + '.' + cleanup_string(assignment[0]), quote(assignment[1])) + root.add(sec + '.' + cleanup_string(lhs), quote(cleanup_string(rhs))) return root def read(path): # export