summaryrefslogtreecommitdiff
path: root/rest-api-templates/transform.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest-api-templates/transform.py')
-rw-r--r--rest-api-templates/transform.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/rest-api-templates/transform.py b/rest-api-templates/transform.py
index c3a030064..88f7d2e67 100644
--- a/rest-api-templates/transform.py
+++ b/rest-api-templates/transform.py
@@ -21,6 +21,11 @@ import os.path
import pystache
import shutil
import tempfile
+import sys
+
+if sys.version_info[0] == 3:
+ def unicode(v):
+ return str(v)
class Transform(object):
@@ -52,10 +57,10 @@ class Transform(object):
dest_exists = os.path.exists(dest_file)
if dest_exists and not self.overwrite:
return
- with tempfile.NamedTemporaryFile() as out:
+ with tempfile.NamedTemporaryFile(mode='w+') as out:
out.write(renderer.render(self.template, model))
out.flush()
if not dest_exists or not filecmp.cmp(out.name, dest_file):
- print "Writing %s" % dest_file
+ print("Writing %s" % dest_file)
shutil.copyfile(out.name, dest_file)