mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-20 21:21:35 +02:00
Removed polyglots unicode_type usage
This commit is contained in:
@@ -11,7 +11,7 @@ from ebook_converter.ebooks.oeb.stylizer import Stylizer
|
||||
from ebook_converter.ebooks.oeb.transforms.flatcss import KeyMapper
|
||||
from ebook_converter.ebooks.mobi.utils import convert_color_for_font_tag
|
||||
from ebook_converter.utils.imghdr import identify
|
||||
from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -151,7 +151,7 @@ class MobiMLizer(object):
|
||||
return "%dem" % int(round(ptsize / embase))
|
||||
|
||||
def preize_text(self, text, pre_wrap=False):
|
||||
text = unicode_type(text)
|
||||
text = str(text)
|
||||
if pre_wrap:
|
||||
# Replace n consecutive spaces with n-1 NBSP + space
|
||||
text = re.sub(r' {2,}', lambda m:('\xa0'*(len(m.group())-1) + ' '), text)
|
||||
@@ -199,7 +199,7 @@ class MobiMLizer(object):
|
||||
bstate.nested.append(para)
|
||||
if tag == 'li' and len(istates) > 1:
|
||||
istates[-2].list_num += 1
|
||||
para.attrib['value'] = unicode_type(istates[-2].list_num)
|
||||
para.attrib['value'] = str(istates[-2].list_num)
|
||||
elif tag in NESTABLE_TAGS and istate.rendered:
|
||||
para = wrapper = bstate.nested[-1]
|
||||
elif not self.opts.mobi_ignore_margins and left > 0 and indent >= 0:
|
||||
@@ -228,7 +228,7 @@ class MobiMLizer(object):
|
||||
while vspace > 0:
|
||||
wrapper.addprevious(etree.Element(XHTML('br')))
|
||||
vspace -= 1
|
||||
if istate.halign != 'auto' and isinstance(istate.halign, (bytes, unicode_type)):
|
||||
if istate.halign != 'auto' and isinstance(istate.halign, (bytes, str)):
|
||||
if isinstance(istate.halign, bytes):
|
||||
istate.halign = istate.halign.decode('utf-8')
|
||||
para.attrib['align'] = istate.halign
|
||||
@@ -285,7 +285,7 @@ class MobiMLizer(object):
|
||||
|
||||
if fsize != 3:
|
||||
inline = etree.SubElement(inline, XHTML('font'),
|
||||
size=unicode_type(fsize))
|
||||
size=str(fsize))
|
||||
if istate.family == 'monospace':
|
||||
inline = etree.SubElement(inline, XHTML('tt'))
|
||||
if istate.italic:
|
||||
@@ -447,7 +447,7 @@ class MobiMLizer(object):
|
||||
(72/self.profile.dpi)))
|
||||
except:
|
||||
continue
|
||||
result = unicode_type(pixs)
|
||||
result = str(pixs)
|
||||
istate.attrib[prop] = result
|
||||
if 'width' not in istate.attrib or 'height' not in istate.attrib:
|
||||
href = self.current_spine_item.abshref(elem.attrib['src'])
|
||||
@@ -464,8 +464,8 @@ class MobiMLizer(object):
|
||||
else:
|
||||
if 'width' not in istate.attrib and 'height' not in \
|
||||
istate.attrib:
|
||||
istate.attrib['width'] = unicode_type(width)
|
||||
istate.attrib['height'] = unicode_type(height)
|
||||
istate.attrib['width'] = str(width)
|
||||
istate.attrib['height'] = str(height)
|
||||
else:
|
||||
ar = width / height
|
||||
if 'width' not in istate.attrib:
|
||||
@@ -473,13 +473,13 @@ class MobiMLizer(object):
|
||||
width = int(istate.attrib['height'])*ar
|
||||
except:
|
||||
pass
|
||||
istate.attrib['width'] = unicode_type(int(width))
|
||||
istate.attrib['width'] = str(int(width))
|
||||
else:
|
||||
try:
|
||||
height = int(istate.attrib['width'])/ar
|
||||
except:
|
||||
pass
|
||||
istate.attrib['height'] = unicode_type(int(height))
|
||||
istate.attrib['height'] = str(int(height))
|
||||
item.unload_data_from_memory()
|
||||
elif tag == 'hr' and asfloat(style['width']) > 0 and style._get('width') not in {'100%', 'auto'}:
|
||||
raww = style._get('width')
|
||||
|
||||
Reference in New Issue
Block a user