diff --git a/setup/translations.py b/setup/translations.py index 1490d705b6..da2e990410 100644 --- a/setup/translations.py +++ b/setup/translations.py @@ -23,7 +23,7 @@ from collections import defaultdict from functools import lru_cache, partial from locale import normalize as normalize_locale -from polyglot.builtins import codepoint_to_chr, iteritems +from polyglot.builtins import iteritems from setup import Command, __appname__, __version__, build_cache_dir, dump_json, edit_file, is_ci, require_git_master from setup.iso_codes import iso_data from setup.parallel_build import batched_parallel_jobs @@ -128,7 +128,7 @@ class POT(Command): # {{{ ans = [] for lineno, msg in msgs: ans.append(f'#: {path}:{lineno}') - slash = codepoint_to_chr(92) + slash = chr(92) msg = msg.replace(slash, slash*2).replace('"', r'\"').replace('\n', r'\n').replace('\r', r'\r').replace('\t', r'\t') ans.append(f'msgid "{msg}"') diff --git a/src/calibre/ebooks/docx/fonts.py b/src/calibre/ebooks/docx/fonts.py index db0a1748d4..1e99691497 100644 --- a/src/calibre/ebooks/docx/fonts.py +++ b/src/calibre/ebooks/docx/fonts.py @@ -13,7 +13,6 @@ from calibre.utils.filenames import ascii_filename from calibre.utils.fonts.scanner import NoFonts, font_scanner from calibre.utils.fonts.utils import is_truetype_font, panose_to_css_generic_family from calibre.utils.icu import ord_string -from polyglot.builtins import codepoint_to_chr Embed = namedtuple('Embed', 'name key subsetted') @@ -124,7 +123,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): diff --git a/src/calibre/ebooks/lit/reader.py b/src/calibre/ebooks/lit/reader.py index 0173e0cecb..60fad6712c 100644 --- a/src/calibre/ebooks/lit/reader.py +++ b/src/calibre/ebooks/lit/reader.py @@ -20,7 +20,7 @@ from calibre.ebooks.lit.maps import HTML_MAP, OPF_MAP from calibre.ebooks.oeb.base import urlnormalize, xpath from calibre.ebooks.oeb.reader import OEBReader from calibre_extensions import lzx, msdes -from polyglot.builtins import codepoint_to_chr, itervalues, string_or_bytes +from polyglot.builtins import itervalues, string_or_bytes from polyglot.urllib import unquote as urlunquote from polyglot.urllib import urldefrag @@ -109,7 +109,7 @@ def read_utf8_char(bytes, pos): raise LitError( f'Invalid UTF8 character: {bytes[pos:pos+i]!r}') c = (c << 6) | (b & 0x3F) - return codepoint_to_chr(c), pos+elsize + return chr(c), pos+elsize def consume_sized_utf8_string(bytes, zpad=False): @@ -250,9 +250,9 @@ class UnBinary: else: dynamic_tag += 1 errors += 1 - tag_name = '?'+codepoint_to_chr(tag)+'?' + tag_name = '?'+chr(tag)+'?' current_map = self.tag_to_attr_map[tag] - print(f'WARNING: tag {codepoint_to_chr(tag)} unknown') + print(f'WARNING: tag {chr(tag)} unknown') buf.write(encode(tag_name)) elif flags & FLAG_CLOSING: if depth == 0: diff --git a/src/calibre/ebooks/lit/writer.py b/src/calibre/ebooks/lit/writer.py index b8b0869198..d5973c392a 100644 --- a/src/calibre/ebooks/lit/writer.py +++ b/src/calibre/ebooks/lit/writer.py @@ -26,7 +26,7 @@ from calibre.ebooks.lit.reader import DirectoryEntry from calibre.ebooks.oeb.base import CSS_MIME, OEB_DOCS, OEB_STYLES, OPF_MIME, XHTML_MIME, XML, XML_NS, prefixname, urlnormalize from calibre.ebooks.oeb.stylizer import Stylizer from calibre_extensions import msdes -from polyglot.builtins import codepoint_to_chr, native_string_type, string_or_bytes +from polyglot.builtins import native_string_type, string_or_bytes from polyglot.urllib import unquote, urldefrag __all__ = ['LitWriter'] @@ -162,7 +162,7 @@ class ReBinary: for value in values: if isinstance(value, numbers.Integral): try: - value = codepoint_to_chr(value) + value = chr(value) except OverflowError: self.logger.warn('Unicode overflow for integer:', value) value = '?' @@ -215,9 +215,9 @@ class ReBinary: path, frag = urldefrag(value) if self.item: path = self.item.abshref(path) - prefix = codepoint_to_chr(3) + prefix = chr(3) if path in self.manifest.hrefs: - prefix = codepoint_to_chr(2) + prefix = chr(2) value = self.manifest.hrefs[path].id if frag: value = '#'.join((value, frag)) @@ -280,9 +280,9 @@ class ReBinary: self.logger.warn(f'More than six anchors in file {self.item.href!r}. ' 'Some links may not work properly.') data = io.BytesIO() - data.write(codepoint_to_chr(len(self.anchors)).encode('utf-8')) + data.write(chr(len(self.anchors)).encode('utf-8')) for anchor, offset in self.anchors: - data.write(codepoint_to_chr(len(anchor)).encode('utf-8')) + data.write(chr(len(anchor)).encode('utf-8')) if isinstance(anchor, str): anchor = anchor.encode('utf-8') data.write(anchor) @@ -521,9 +521,9 @@ class LitWriter: item.offset = offset \ if state in ('linear', 'nonlinear') else 0 data.write(pack('