upgrade to CAM v2.0
[stack/cam.git] / cam / utils.py
diff --git a/cam/utils.py b/cam/utils.py
new file mode 100644 (file)
index 0000000..e5685f2
--- /dev/null
@@ -0,0 +1,16 @@
+import os
+
+
+_template_dir = os.path.join(os.path.dirname(__file__), 'templates')
+
+
+def render(output_file, template_name, args):
+    tpl = open(os.path.join(_template_dir, template_name), 'r')
+    outfd = open(output_file, 'w')
+    outfd.write(tpl.read() % args)
+    tpl.close()
+    outfd.close()
+
+
+def parse_bool(s):
+    return s.lower() in ('1', 'y', 'yes', 'true', 'on')