Change string detection to use basestring
@@ -4,25 +4,26 @@ import logging
import os
import re
+import six
+
import reportlab
+import xhtml2pdf.default
+import xhtml2pdf.parser
from reportlab.lib.enums import TA_LEFT
from reportlab.lib.fonts import addMapping
-from reportlab.lib.pagesizes import landscape, A4
+from reportlab.lib.pagesizes import A4, landscape
from reportlab.lib.styles import ParagraphStyle
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.platypus.frames import Frame, ShowBoundaryValue
from reportlab.platypus.paraparser import ParaFrag, ps2tt, tt2ps
-import six
-
-import xhtml2pdf.default
-import xhtml2pdf.parser
-from xhtml2pdf.util import getSize, getCoords, getFile, pisaFileObject, \
- getFrameDimensions, getColor, set_value, copy_attrs
+from xhtml2pdf.util import (copy_attrs, getColor, getCoords, getFile,
+ getFrameDimensions, getSize, pisaFileObject,
+ set_value)
from xhtml2pdf.w3c import css
-from xhtml2pdf.xhtml2pdf_reportlab import PmlPageTemplate, PmlTableOfContents, \
- PmlParagraph, PmlParagraphAndImage, PmlPageCount
-
+from xhtml2pdf.xhtml2pdf_reportlab import (PmlPageCount, PmlPageTemplate,
+ PmlParagraph, PmlParagraphAndImage,
+ PmlTableOfContents)
TupleType = tuple
ListType = list
@@ -167,7 +168,7 @@ class pisaCSSBuilder(css.CSSBuilder):
if isinstance(data['src'], list):
for part in uri:
- if isinstance(part, str) or isinstance(part, unicode):
+ if isinstance(part, basestring):
fonts.append(part)
else:
fonts.append(uri)
@@ -199,7 +200,7 @@ class pisaCSSBuilder(css.CSSBuilder):
def _getFromData(self, data, attr, default=None, func=None):
if not func:
- func = lambda x: x
+ def func(x): return x
if type(attr) in (list, tuple):
for a in attr:
