diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-02-13 19:36:58 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-02-14 11:11:05 +0200 |
commit | 2131ab187c0a482904a2d3a8a60942ce23f10348 (patch) | |
tree | 457ab08b45dbf4781ef78a7caf4edf20d779fda8 /yarnstep.py | |
parent | e40d9119c43e475951b1ce63cd9d67b44516cd89 (diff) | |
download | bumper-2131ab187c0a482904a2d3a8a60942ce23f10348.tar.gz |
Add preliminary initial scenario
Diffstat (limited to 'yarnstep.py')
-rw-r--r-- | yarnstep.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/yarnstep.py b/yarnstep.py index 1935cc6..30ccae1 100644 --- a/yarnstep.py +++ b/yarnstep.py @@ -58,3 +58,30 @@ def iter_over_files(root): def cat(filename): with open(filename) as f: return f.read() + + +def write_file(filename, data): + dirname = os.path.dirname(filename) + if not os.path.exists(dirname): + os.makedirs(dirname) + with open(filename, 'w') as f: + f.write(data) + + +def unescape_backslashes(s): + result = '' + while s: + if s.startswith('\\') and len(s) > 1: + result += unescape_char(s[1]) + s = s[2:] + else: + result += s[0] + s = s[1:] + return result + + +def unescape_char(c): + table = { + 'n': '\n', + } + return table.get(c, c) |