]> Devi Nivas Git - chevron.git/commitdiff
python 3 working
authornoah morrison <noah@morrison.ph>
Tue, 18 Nov 2014 02:33:17 +0000 (21:33 -0500)
committernoah morrison <noah@morrison.ph>
Tue, 18 Nov 2014 02:41:23 +0000 (21:41 -0500)
entei.py

index 447c2b4857e1d86deb69e07c61fb95dffcb6d30e..59f19021414e78a227e0c44fc26505e08db9549f 100755 (executable)
--- a/entei.py
+++ b/entei.py
@@ -2,7 +2,14 @@
 
 import json
 
-from sys import argv
+from sys import argv, version
+
+python3 = False
+if version > '3':
+    python3 = True
+
+    def unicode(x, y):
+        return x
 
 class UnclosedSection(Exception):
     """Raised when you have unbalanced section tags"""
@@ -360,9 +367,15 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache',
                 part_out = part_out.rstrip(' ')
 
             # Add the partials output to the ouput
-            output += part_out.decode('utf-8')
+            if python3:
+                output += part_out
+            else:
+                output += part_out.decode('utf-8')
 
-    return output.encode('utf-8')
+    if python3:
+        return output
+    else:
+        return output.encode('utf-8')
 
 
 def main(data, template, **kwargs):