1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-03-16 06:33:31 +01:00

Removed polyglot codepoint_to_chr

This commit is contained in:
2020-04-20 19:29:05 +02:00
parent 128705f258
commit eac0b98d6f
11 changed files with 20 additions and 25 deletions

View File

@@ -6,7 +6,7 @@ from ebook_converter.utils.filenames import ascii_filename
from ebook_converter.utils.fonts.scanner import font_scanner, NoFonts
from ebook_converter.utils.fonts.utils import panose_to_css_generic_family, is_truetype_font
from ebook_converter.utils.icu import ord_string
from ebook_converter.polyglot.builtins import codepoint_to_chr, iteritems
from ebook_converter.polyglot.builtins import iteritems
__license__ = 'GPL v3'
@@ -121,7 +121,7 @@ def do_map(m, points):
if base < p < limit:
yield m[p - base]
else:
yield codepoint_to_chr(p)
yield chr(p)
def map_symbol_text(text, font):

View File

@@ -9,7 +9,7 @@ import urllib.parse
from ebook_converter import relpath, guess_type, prints, force_unicode
from ebook_converter.utils.config_base import tweaks
from ebook_converter.polyglot.builtins import codepoint_to_chr, getcwd, iteritems, itervalues, as_unicode
from ebook_converter.polyglot.builtins import getcwd, iteritems, itervalues, as_unicode
from ebook_converter.polyglot.urllib import unquote
@@ -157,7 +157,7 @@ def get_title_sort_pat(lang=None):
return ans
_ignore_starts = '\'"'+''.join(codepoint_to_chr(x) for x in
_ignore_starts = '\'"'+''.join(chr(x) for x in
list(range(0x2018, 0x201e))+[0x2032, 0x2033])

View File

@@ -6,7 +6,7 @@ import re
from ebook_converter import force_unicode
from ebook_converter.ebooks.metadata import MetaInformation
from ebook_converter.polyglot.builtins import codepoint_to_chr, string_or_bytes, int_to_byte
from ebook_converter.polyglot.builtins import string_or_bytes, int_to_byte
title_pat = re.compile(br'\{\\info.*?\{\\title(.*?)(?<!\\)\}', re.DOTALL)
author_pat = re.compile(br'\{\\info.*?\{\\author(.*?)(?<!\\)\}', re.DOTALL)
@@ -90,7 +90,7 @@ def decode(raw, codec):
def uni(match):
try:
return codepoint_to_chr(int(match.group(1)))
return chr(int(match.group(1)))
except Exception:
return '?'

View File

@@ -17,7 +17,7 @@ from ebook_converter import (isbytestring, as_unicode, get_types_map)
from ebook_converter.ebooks.oeb.parse_utils import barename, XHTML_NS, namespace, XHTML, parse_html, NotHTML
from ebook_converter.utils.cleantext import clean_xml_chars
from ebook_converter.utils.short_uuid import uuid4
from ebook_converter.polyglot.builtins import iteritems, string_or_bytes, itervalues, codepoint_to_chr
from ebook_converter.polyglot.builtins import iteritems, string_or_bytes, itervalues
from ebook_converter.polyglot.urllib import unquote as urlunquote
@@ -431,7 +431,7 @@ def serialize(data, media_type, pretty_print=False):
return bytes(data)
ASCII_CHARS = frozenset(codepoint_to_chr(x) for x in range(128))
ASCII_CHARS = frozenset(chr(x) for x in range(128))
UNIBYTE_CHARS = frozenset(x.encode('ascii') for x in ASCII_CHARS)
USAFE = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
'abcdefghijklmnopqrstuvwxyz'

View File

@@ -9,7 +9,6 @@ from ebook_converter.ebooks.pdb.formatreader import FormatReader
from ebook_converter.ebooks.compression.palmdoc import decompress_doc
from ebook_converter.utils.imghdr import identify
from ebook_converter.utils.img import save_cover_data_to, Canvas, image_from_data
from ebook_converter.polyglot.builtins import codepoint_to_chr
__license__ = 'GPL v3'
@@ -714,7 +713,7 @@ class Reader(FormatReader):
elif c == 0xa0:
html += '&nbsp;'
else:
html += codepoint_to_chr(c)
html += chr(c)
offset += 1
if offset in paragraph_offsets:
need_set_p_id = True

View File

@@ -4,7 +4,7 @@ from datetime import datetime
from ebook_converter.constants import ispy3
from ebook_converter.utils.logging import default_log
from ebook_converter.polyglot.builtins import iteritems, codepoint_to_chr
from ebook_converter.polyglot.builtins import iteritems
from ebook_converter.polyglot.binary import as_hex_bytes
@@ -89,7 +89,7 @@ class Name(str):
raw = bytearray(raw)
sharp = ord(b'#')
buf = (
codepoint_to_chr(x).encode('ascii') if 33 < x < 126 and x != sharp else
chr(x).encode('ascii') if 33 < x < 126 and x != sharp else
'#{:x}'.format(x).encode('ascii') for x in raw)
stream.write(b'/'+b''.join(buf))

View File

@@ -15,7 +15,6 @@ import os, re
from ebook_converter.ebooks.rtf2xml import copy
from ebook_converter.utils.mreplace import MReplace
from ebook_converter.ptempfile import better_mktemp
from ebook_converter.polyglot.builtins import codepoint_to_chr
from . import open_for_read, open_for_write
@@ -95,7 +94,7 @@ class Tokenize:
uni_len = len(match_obj.group(0))
if uni_char < 0:
uni_char += 65536
uni_char = codepoint_to_chr(uni_char).encode('ascii', 'xmlcharrefreplace').decode('ascii')
uni_char = chr(uni_char).encode('ascii', 'xmlcharrefreplace').decode('ascii')
self.__uc_char = self.__uc_value[-1]
# there is only an unicode char
if len(token)<= uni_len: