summaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-08-09 20:21:21 (GMT)
committerEvan Martin <martine@danga.com>2011-08-16 18:35:56 (GMT)
commit9c8b25515b43e0502f1c9c00d4ce4a6755143f3b (patch)
treee528b90eb2a2f5f2c9fae75d5c81c691092877ba /misc
parent667d16d123e7eb6d9525146c13bdc90f251e7fc9 (diff)
downloadNinja-9c8b25515b43e0502f1c9c00d4ce4a6755143f3b.zip
Ninja-9c8b25515b43e0502f1c9c00d4ce4a6755143f3b.tar.gz
Ninja-9c8b25515b43e0502f1c9c00d4ce4a6755143f3b.tar.bz2
add escaping function to python module
Diffstat (limited to 'misc')
-rw-r--r--misc/ninja.py8
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('$', '$$')