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:
@@ -10,7 +10,7 @@ from ebook_converter.ebooks.mobi.writer2 import (PALMDOC, UNCOMPRESSED)
|
||||
from ebook_converter.ebooks.mobi.utils import (encint, encode_trailing_data,
|
||||
align_block, detect_periodical, RECORD_SIZE, create_text_record)
|
||||
from ebook_converter.ebooks.mobi.writer2.indexer import Indexer
|
||||
from ebook_converter.polyglot.builtins import iteritems, unicode_type
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -48,7 +48,7 @@ class MobiWriter(object):
|
||||
self.log = oeb.log
|
||||
pt = None
|
||||
if oeb.metadata.publication_type:
|
||||
x = unicode_type(oeb.metadata.publication_type[0]).split(':')
|
||||
x = str(oeb.metadata.publication_type[0]).split(':')
|
||||
if len(x) > 1:
|
||||
pt = x[1].lower()
|
||||
self.publication_type = pt
|
||||
@@ -235,7 +235,7 @@ class MobiWriter(object):
|
||||
0 # Unused
|
||||
)) # 0 - 15 (0x0 - 0xf)
|
||||
uid = random.randint(0, 0xffffffff)
|
||||
title = normalize(unicode_type(metadata.title[0])).encode('utf-8')
|
||||
title = normalize(str(metadata.title[0])).encode('utf-8')
|
||||
|
||||
# 0x0 - 0x3
|
||||
record0.write(b'MOBI')
|
||||
@@ -278,7 +278,7 @@ class MobiWriter(object):
|
||||
|
||||
# 0x4c - 0x4f : Language specifier
|
||||
record0.write(iana2mobi(
|
||||
unicode_type(metadata.language[0])))
|
||||
str(metadata.language[0])))
|
||||
|
||||
# 0x50 - 0x57 : Input language and Output language
|
||||
record0.write(b'\0' * 8)
|
||||
@@ -455,7 +455,7 @@ class MobiWriter(object):
|
||||
'''
|
||||
Write the PalmDB header
|
||||
'''
|
||||
title = ascii_filename(unicode_type(self.oeb.metadata.title[0])).replace(
|
||||
title = ascii_filename(str(self.oeb.metadata.title[0])).replace(
|
||||
' ', '_')
|
||||
if not isinstance(title, bytes):
|
||||
title = title.encode('ascii')
|
||||
|
||||
@@ -8,7 +8,7 @@ from ebook_converter.ebooks import generate_masthead
|
||||
from ebook_converter.ebooks.oeb.base import OEB_RASTER_IMAGES
|
||||
from ebook_converter.ptempfile import PersistentTemporaryFile
|
||||
from ebook_converter.utils.imghdr import what
|
||||
from ebook_converter.polyglot.builtins import iteritems, unicode_type
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -79,7 +79,7 @@ class Resources(object):
|
||||
self.image_indices.add(0)
|
||||
elif self.is_periodical:
|
||||
# Generate a default masthead
|
||||
data = generate_masthead(unicode_type(self.oeb.metadata['title'][0]))
|
||||
data = generate_masthead(str(self.oeb.metadata['title'][0]))
|
||||
self.records.append(data)
|
||||
self.used_image_indices.add(0)
|
||||
self.image_indices.add(0)
|
||||
@@ -87,8 +87,8 @@ class Resources(object):
|
||||
|
||||
cover_href = self.cover_offset = self.thumbnail_offset = None
|
||||
if (oeb.metadata.cover and
|
||||
unicode_type(oeb.metadata.cover[0]) in oeb.manifest.ids):
|
||||
cover_id = unicode_type(oeb.metadata.cover[0])
|
||||
str(oeb.metadata.cover[0]) in oeb.manifest.ids):
|
||||
cover_id = str(oeb.metadata.cover[0])
|
||||
item = oeb.manifest.ids[cover_id]
|
||||
cover_href = item.href
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from ebook_converter.ebooks.mobi.utils import is_guide_ref_start
|
||||
from ebook_converter.ebooks.oeb.base import (
|
||||
OEB_DOCS, XHTML, XHTML_NS, XML_NS, namespace, prefixname, urlnormalize
|
||||
)
|
||||
from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -20,7 +20,7 @@ __docformat__ = 'restructuredtext en'
|
||||
class Buf(io.BytesIO):
|
||||
|
||||
def write(self, x):
|
||||
if isinstance(x, unicode_type):
|
||||
if isinstance(x, str):
|
||||
x = x.encode('utf-8')
|
||||
io.BytesIO.write(self, x)
|
||||
|
||||
@@ -226,7 +226,7 @@ class Serializer(object):
|
||||
buf.write(b'<div> <div height="1em"></div>')
|
||||
else:
|
||||
t = tocref.title
|
||||
if isinstance(t, unicode_type):
|
||||
if isinstance(t, str):
|
||||
t = t.encode('utf-8')
|
||||
buf.write(b'<div></div> <div> <h2 height="1em"><font size="+2"><b>' + t +
|
||||
b'</b></font></h2> <div height="1em"></div>')
|
||||
@@ -246,7 +246,7 @@ class Serializer(object):
|
||||
buf.write(b'0000000000')
|
||||
buf.write(b' ><font size="+1"><b><u>')
|
||||
t = tocitem.title
|
||||
if isinstance(t, unicode_type):
|
||||
if isinstance(t, str):
|
||||
t = t.encode('utf-8')
|
||||
buf.write(t)
|
||||
buf.write(b'</u></b></font></a></li>')
|
||||
@@ -364,7 +364,7 @@ class Serializer(object):
|
||||
text = text.replace(u'\u00AD', '') # Soft-hyphen
|
||||
if quot:
|
||||
text = text.replace('"', '"')
|
||||
if isinstance(text, unicode_type):
|
||||
if isinstance(text, str):
|
||||
text = unicodedata.normalize('NFC', text)
|
||||
self.buf.write(text.encode('utf-8'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user