basestring normailization for python3.
This commit is contained in:
parent
9561666355
commit
44aac5f362
1 changed files with 18 additions and 1 deletions
19
secretary.py
19
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',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue