mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-11 23:53:34 +02:00
Removed polyglots unicode_type usage
This commit is contained in:
@@ -4,7 +4,6 @@ from collections import namedtuple
|
||||
from ebook_converter.customize import CatalogPlugin
|
||||
from ebook_converter.library.catalogs import FIELDS
|
||||
from ebook_converter.customize.conversion import DummyReporter
|
||||
from ebook_converter.polyglot.builtins import unicode_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -152,14 +151,14 @@ class CSV_XML(CatalogPlugin):
|
||||
item = '%.2g' % (item / 2)
|
||||
|
||||
# Convert HTML to markdown text
|
||||
if isinstance(item, unicode_type):
|
||||
if isinstance(item, str):
|
||||
opening_tag = re.search(r'<(\w+)( |>)', item)
|
||||
if opening_tag:
|
||||
closing_tag = re.search(r'<\/%s>$' % opening_tag.group(1), item)
|
||||
if closing_tag:
|
||||
item = html2text(item)
|
||||
|
||||
outstr.append('"%s"' % unicode_type(item).replace('"', '""'))
|
||||
outstr.append('"%s"' % str(item).replace('"', '""'))
|
||||
|
||||
outfile.write(','.join(outstr) + '\n')
|
||||
outfile.close()
|
||||
@@ -175,8 +174,8 @@ class CSV_XML(CatalogPlugin):
|
||||
for field in fields:
|
||||
if field.startswith('#'):
|
||||
val = db.get_field(r['id'], field, index_is_id=True)
|
||||
if not isinstance(val, unicode_type):
|
||||
val = unicode_type(val)
|
||||
if not isinstance(val, str):
|
||||
val = str(val)
|
||||
item = getattr(E, field.replace('#', '_'))(val)
|
||||
record.append(item)
|
||||
|
||||
@@ -186,11 +185,11 @@ class CSV_XML(CatalogPlugin):
|
||||
val = r[field]
|
||||
if not val:
|
||||
continue
|
||||
if not isinstance(val, (bytes, unicode_type)):
|
||||
if not isinstance(val, (bytes, str)):
|
||||
if (fm.get(field, {}).get('datatype', None) ==
|
||||
'rating' and val):
|
||||
val = '%.2g' % (val / 2)
|
||||
val = unicode_type(val)
|
||||
val = str(val)
|
||||
item = getattr(E, field)(val)
|
||||
record.append(item)
|
||||
|
||||
@@ -219,7 +218,7 @@ class CSV_XML(CatalogPlugin):
|
||||
|
||||
if 'series' in fields and r['series']:
|
||||
record.append(E.series(r['series'],
|
||||
index=unicode_type(r['series_index'])))
|
||||
index=str(r['series_index'])))
|
||||
|
||||
if 'cover' in fields and r['cover']:
|
||||
record.append(E.cover(r['cover'].replace(os.sep, '/')))
|
||||
|
||||
Reference in New Issue
Block a user