mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-10 07:03:35 +02:00
Removed polyglots unicode_type usage
This commit is contained in:
@@ -15,7 +15,7 @@ from ebook_converter.utils.localization import lang_as_iso639_1
|
||||
from ebook_converter.utils.xml_parse import safe_xml_fromstring
|
||||
from ebook_converter.utils.img import save_cover_data_to
|
||||
from ebook_converter.ebooks.oeb.base import urlnormalize
|
||||
from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||
from ebook_converter.polyglot.binary import as_base64_unicode
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ class FB2MLizer(object):
|
||||
metadata['author'] = '<author><first-name></first-name><last-name></last-name></author>'
|
||||
|
||||
metadata['keywords'] = ''
|
||||
tags = list(map(unicode_type, self.oeb_book.metadata.subject))
|
||||
tags = list(map(str, self.oeb_book.metadata.subject))
|
||||
if tags:
|
||||
tags = ', '.join(prepare_string_for_xml(x) for x in tags)
|
||||
metadata['keywords'] = '<keywords>%s</keywords>'%tags
|
||||
@@ -168,12 +168,12 @@ class FB2MLizer(object):
|
||||
year = publisher = isbn = ''
|
||||
identifiers = self.oeb_book.metadata['identifier']
|
||||
for x in identifiers:
|
||||
if x.get(OPF('scheme'), None).lower() == 'uuid' or unicode_type(x).startswith('urn:uuid:'):
|
||||
metadata['id'] = unicode_type(x).split(':')[-1]
|
||||
if x.get(OPF('scheme'), None).lower() == 'uuid' or str(x).startswith('urn:uuid:'):
|
||||
metadata['id'] = str(x).split(':')[-1]
|
||||
break
|
||||
if metadata['id'] is None:
|
||||
self.log.warn('No UUID identifier found')
|
||||
metadata['id'] = unicode_type(uuid.uuid4())
|
||||
metadata['id'] = str(uuid.uuid4())
|
||||
|
||||
try:
|
||||
date = self.oeb_book.metadata['date'][0]
|
||||
@@ -235,7 +235,7 @@ class FB2MLizer(object):
|
||||
</description>''') % metadata
|
||||
|
||||
# Remove empty lines.
|
||||
return '\n'.join(filter(unicode_type.strip, header.splitlines()))
|
||||
return '\n'.join(filter(str.strip, header.splitlines()))
|
||||
|
||||
def fb2_footer(self):
|
||||
return '</FictionBook>'
|
||||
@@ -246,8 +246,8 @@ class FB2MLizer(object):
|
||||
cover_href = None
|
||||
|
||||
# Get the raster cover if it's available.
|
||||
if self.oeb_book.metadata.cover and unicode_type(self.oeb_book.metadata.cover[0]) in self.oeb_book.manifest.ids:
|
||||
id = unicode_type(self.oeb_book.metadata.cover[0])
|
||||
if self.oeb_book.metadata.cover and str(self.oeb_book.metadata.cover[0]) in self.oeb_book.manifest.ids:
|
||||
id = str(self.oeb_book.metadata.cover[0])
|
||||
cover_item = self.oeb_book.manifest.ids[id]
|
||||
if cover_item.media_type in OEB_RASTER_IMAGES:
|
||||
cover_href = cover_item.href
|
||||
|
||||
Reference in New Issue
Block a user