basestring normailization for python3.

This commit is contained in:
Christopher Ramírez 2014-07-19 22:04:23 -06:00
parent 9561666355
commit 44aac5f362

View file

@ -14,7 +14,6 @@ Secretary
engine = Renderer(template_file) engine = Renderer(template_file)
result = engine.render(template_var1=...) result = engine.render(template_var1=...)
""" """
from __future__ import unicode_literals, print_function
import io import io
import re import re
@ -23,6 +22,24 @@ import logging
import zipfile import zipfile
from xml.dom.minidom import parseString from xml.dom.minidom import parseString
from jinja2 import Environment, Undefined 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 = { FLOW_REFERENCES = {
'text:p' : 'text:p', 'text:p' : 'text:p',