diff options
author | Evan Martin <martine@danga.com> | 2011-08-09 20:21:21 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-08-16 18:35:56 (GMT) |
commit | 9c8b25515b43e0502f1c9c00d4ce4a6755143f3b (patch) | |
tree | e528b90eb2a2f5f2c9fae75d5c81c691092877ba | |
parent | 667d16d123e7eb6d9525146c13bdc90f251e7fc9 (diff) | |
download | Ninja-9c8b25515b43e0502f1c9c00d4ce4a6755143f3b.zip Ninja-9c8b25515b43e0502f1c9c00d4ce4a6755143f3b.tar.gz Ninja-9c8b25515b43e0502f1c9c00d4ce4a6755143f3b.tar.bz2 |
add escaping function to python module
-rw-r--r-- | misc/ninja.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/misc/ninja.py b/misc/ninja.py index abde596..7fa4bf1 100644 --- a/misc/ninja.py +++ b/misc/ninja.py @@ -84,3 +84,11 @@ class Writer(object): if isinstance(input, list): return input return [input] + + +def escape(string): + """Escape a string such that it can be embedded into a Ninja file without + further interpretation.""" + assert '\n' not in string, 'Ninja syntax does not allow newlines' + # We only have one special metacharacter: '$'. + return string.replace('$', '$$') |