From 6c2e100abad1ae5e8dcb112e61040f0941da7d62 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 6 Nov 2017 13:40:02 +0100 Subject: Add: unescape function This will allow us to use \n in (selected) scenario step strings. --- yarns/lib.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'yarns') diff --git a/yarns/lib.py b/yarns/lib.py index d5559b1..486757c 100644 --- a/yarns/lib.py +++ b/yarns/lib.py @@ -62,6 +62,17 @@ def wait_for_port(port): else: return +def unescape(s): + t = '' + while s: + if s.startswith('\\n'): + t += '\n' + s = s[2:] + else: + t += s[0] + s = s[1:] + return t + def write(filename, data): with open(filename, 'w') as f: f.write(data) -- cgit v1.2.1