From f1ada6f32ff7c9bd979a92146b24a7d491e77d77 Mon Sep 17 00:00:00 2001 From: Overwatch Date: Mon, 17 Nov 2014 12:56:51 +0100 Subject: [PATCH] - fixed cfg file parsing for strings - fixes in over.core.cmd --- core/app.py | 5 +++-- core/cmd.py | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/app.py b/core/app.py index d6df228..dd68a4a 100644 --- a/core/app.py +++ b/core/app.py @@ -17,9 +17,10 @@ prefix = textui.prefix # -------------------------------------------------- def _parse(data, dtype): + print('### called _parse(%s, %s)' %(repr(data), repr(dtype))) if dtype == 'str': - if data.startswith('\'') and data.endswith('\''): - value = data[1:-1].replace('\\\'', '\'') + if data.startswith('"') and data.endswith('"'): + value = data[1:-1].replace('\\"', '"') else: raise RuntimeError diff --git a/core/cmd.py b/core/cmd.py index f3ef5e0..a7d04d5 100644 --- a/core/cmd.py +++ b/core/cmd.py @@ -19,6 +19,13 @@ def capture_output(stream, fifo): stream.close() +def char_in_str(chars, string): + for char in chars: + if char in string: + return True + + return False + class Command: ''' A shell command with argument substitution and output capture. @@ -75,7 +82,7 @@ class Command: out.append(str(item)) if pretty: - return [('"%s"' %(a) if ' ' in a else a) for a in out] + return [('"%s"' %(a) if char_in_str(" ()[];\\", a) else a) for a in out] else: return out