1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-10 15:13:35 +02:00

Removed polyglots unicode_type usage

This commit is contained in:
2020-04-20 19:25:28 +02:00
parent ef7e2b10be
commit 128705f258
130 changed files with 657 additions and 716 deletions

View File

@@ -3,7 +3,6 @@ from struct import calcsize, unpack, unpack_from
from collections import namedtuple
from ebook_converter.utils.fonts.utils import get_font_names2, get_font_characteristics
from ebook_converter.polyglot.builtins import unicode_type
__license__ = 'GPL v3'
@@ -45,7 +44,7 @@ class FontMetadata(object):
elif wt == 700:
wt = 'bold'
else:
wt = unicode_type(wt)
wt = str(wt)
self.font_weight = wt
self.font_stretch = ('ultra-condensed', 'extra-condensed',

View File

@@ -6,7 +6,7 @@ from ebook_converter import walk, prints, as_unicode
from ebook_converter.constants import (config_dir, iswindows, isosx, plugins, DEBUG,
isworker, filesystem_encoding)
from ebook_converter.utils.fonts.metadata import FontMetadata, UnsupportedFont
from ebook_converter.polyglot.builtins import itervalues, unicode_type
from ebook_converter.polyglot.builtins import itervalues
__license__ = 'GPL v3'
@@ -261,7 +261,7 @@ class FontScanner(Thread):
'''
from ebook_converter.utils.fonts.utils import (supports_text,
panose_to_css_generic_family, get_printable_characters)
if not isinstance(text, unicode_type):
if not isinstance(text, str):
raise TypeError(u'%r is not unicode'%text)
text = get_printable_characters(text)
found = {}

View File

@@ -1,5 +1,4 @@
from struct import pack, unpack_from
from ebook_converter.polyglot.builtins import unicode_type
__license__ = 'GPL v3'
@@ -68,7 +67,7 @@ class ByteCode(dict):
return float(number), index
def write_float(self, f, encoding='ignored'):
s = unicode_type(f).upper()
s = str(f).upper()
if s[:2] == "0.":
s = s[1:]
elif s[:3] == "-0.":

View File

@@ -6,7 +6,7 @@ from functools import partial
from ebook_converter.utils.icu import safe_chr, ord_string
from ebook_converter.utils.fonts.sfnt.container import Sfnt
from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont, NoGlyphs
from ebook_converter.polyglot.builtins import unicode_type, iteritems, itervalues
from ebook_converter.polyglot.builtins import iteritems, itervalues
__license__ = 'GPL v3'
@@ -106,7 +106,7 @@ def pdf_subset(sfnt, glyphs):
def safe_ord(x):
return ord_string(unicode_type(x))[0]
return ord_string(str(x))[0]
def subset(raw, individual_chars, ranges=(), warnings=None):
@@ -343,12 +343,12 @@ def all():
print('No glyphs!')
continue
except UnsupportedFont as e:
unsupported.append((font['full_name'], font['path'], unicode_type(e)))
unsupported.append((font['full_name'], font['path'], str(e)))
print('Unsupported!')
continue
except Exception as e:
print('Failed!')
failed.append((font['full_name'], font['path'], unicode_type(e)))
failed.append((font['full_name'], font['path'], str(e)))
else:
averages.append(sum(itervalues(new_stats))/sum(itervalues(old_stats)) * 100)
print('Reduced to:', '%.1f'%averages[-1] , '%')

View File

@@ -2,7 +2,7 @@ import struct
from io import BytesIO
from collections import defaultdict
from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type, as_bytes
from ebook_converter.polyglot.builtins import iteritems, itervalues, as_bytes
__license__ = 'GPL v3'
@@ -394,7 +394,7 @@ def get_bmp_glyph_ids(table, bmp, codes):
def get_glyph_ids(raw, text, raw_is_table=False):
if not isinstance(text, unicode_type):
if not isinstance(text, str):
raise TypeError('%r is not a unicode object'%text)
if raw_is_table:
table = raw
@@ -420,7 +420,7 @@ def get_glyph_ids(raw, text, raw_is_table=False):
def supports_text(raw, text, has_only_printable_chars=False):
if not isinstance(text, unicode_type):
if not isinstance(text, str):
raise TypeError('%r is not a unicode object'%text)
if not has_only_printable_chars:
text = get_printable_characters(text)