From f9fa53eef8e1183c4f7e3f9e0dd463ec1babdc86 Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Fri, 12 Dec 2014 11:44:29 +0100 Subject: Added support for recording dependencies while compiling OpenSCAD files. --- support/lib/util.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'support/lib/util.py') diff --git a/support/lib/util.py b/support/lib/util.py index a3bc3dc..bede240 100644 --- a/support/lib/util.py +++ b/support/lib/util.py @@ -1,4 +1,4 @@ -import contextlib, subprocess, tempfile, shutil +import contextlib, subprocess, tempfile, shutil, re, os @contextlib.contextmanager @@ -16,3 +16,21 @@ def command(args): process.wait() assert not process.returncode + + +def bash_escape_string(string): + return "'{}'".format(re.sub("'", "'\"'\"'", string)) + + +def write_file(path, data): + temp_path = path + '~' + + with open(temp_path, 'wb') as file: + file.write(data) + + os.rename(temp_path, path) + + +def read_file(path): + with open(path, 'rb') as file: + return file.read() -- cgit