summaryrefslogtreecommitdiff
path: root/support/lib
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2014-12-12 11:44:29 +0100
committerMichael Schwarz <michi.schwarz@gmail.com>2014-12-12 11:44:29 +0100
commitf9fa53eef8e1183c4f7e3f9e0dd463ec1babdc86 (patch)
treef212ca5d7037e2eb28954fa9517191b53d6d080e /support/lib
parent60b25ad13d0fdee926006bc728b031c4da1fb931 (diff)
downloadpogojig-f9fa53eef8e1183c4f7e3f9e0dd463ec1babdc86.tar.gz
pogojig-f9fa53eef8e1183c4f7e3f9e0dd463ec1babdc86.tar.bz2
pogojig-f9fa53eef8e1183c4f7e3f9e0dd463ec1babdc86.zip
Added support for recording dependencies while compiling OpenSCAD files.
Diffstat (limited to 'support/lib')
-rw-r--r--support/lib/util.py20
1 files changed, 19 insertions, 1 deletions
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()