From 9c8b25515b43e0502f1c9c00d4ce4a6755143f3b Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Tue, 9 Aug 2011 13:21:21 -0700 Subject: add escaping function to python module --- misc/ninja.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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('$', '$$') -- cgit v0.12