From: YOKOTA Hiroshi Date: Mon, 6 Apr 2026 08:21:17 +0900 Subject: Use system dictionary data for pykakasi Upstream Calibre uses own path for pykakasi dictionary data. Forwarded: not-needed --- src/calibre/ebooks/unihandecode/jadecoder.py | 33 ---------------------------- 1 file changed, 33 deletions(-) diff --git a/src/calibre/ebooks/unihandecode/jadecoder.py b/src/calibre/ebooks/unihandecode/jadecoder.py index e731e58..48dcf30 100644 --- a/src/calibre/ebooks/unihandecode/jadecoder.py +++ b/src/calibre/ebooks/unihandecode/jadecoder.py @@ -14,7 +14,6 @@ This functionality is owned by Kakasi Japanese processing engine. Copyright (c) 2010 Hiroshi Miura """ -import pickle import re import warnings from importlib.resources import files @@ -29,38 +28,6 @@ from calibre.ebooks.unihandecode.unicodepoints import CODEPOINTS from calibre.ebooks.unihandecode.unidecoder import Unidecoder -# pykakasi uses paths for its dictionaries rather than using the -# Traversable API of importlib.resources so we have to hack around it, sigh. -# https://codeberg.org/miurahr/pykakasi/pulls/174 -def dictdata(dbfile: str): - t = files('pykakasi') - q = t.joinpath('data').joinpath(dbfile) - return q.read_bytes() - - -def jisyo_init(self, dictname): - self._dict = pickle.loads(dictdata(dictname)) - - -def itaiji_init(self): - if self._itaijidict is None: - with self._lock: - if self._itaijidict is None: - self._itaijidict = pickle.loads(dictdata(Configurations.jisyo_itaiji)) - - -def kanwa_init(self): - if self._jisyo_table is None: - with self._lock: - if self._jisyo_table is None: - self._jisyo_table = pickle.loads(dictdata(Configurations.jisyo_kanwa)) - - -Jisyo.__init__ = jisyo_init -Itaiji.__init__ = itaiji_init -Kanwa.__init__ = kanwa_init - - class Jadecoder(Unidecoder): def __init__(self): self.codepoints = CODEPOINTS.copy()