diff --git a/secretary.py b/secretary.py index d72d716..1155e48 100644 --- a/secretary.py +++ b/secretary.py @@ -14,7 +14,6 @@ Secretary engine = Renderer(template_file) result = engine.render(template_var1=...) """ -from __future__ import unicode_literals, print_function import io import re @@ -23,6 +22,24 @@ import logging import zipfile from xml.dom.minidom import parseString from jinja2 import Environment, Undefined +from __future__ import unicode_literals, print_function + +# Test python versions and normalize calls to basestring, unicode, etc. +try: + unicode = unicode +except NameError: + # 'unicode' is undefined, must be Python 3 + str = str + unicode = str + bytes = bytes + basestring = (str,bytes) +else: + # 'unicode' exists, must be Python 2 + str = str + unicode = unicode + bytes = str + basestring = basestring + FLOW_REFERENCES = { 'text:p' : 'text:p',