From 4047f8b6e537158233f69d2257062b0038d122a0 Mon Sep 17 00:00:00 2001 From: Mike Gerber Date: Tue, 9 Jul 2024 21:01:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20loading=20ocrd-tool.json?= =?UTF-8?q?=20for=20Python=203.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 1 + src/dinglehopper/ocrd_cli.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 846d389..6741fa2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ multimethod >= 1.3 tqdm rapidfuzz >= 2.7.0 chardet +importlib_resources diff --git a/src/dinglehopper/ocrd_cli.py b/src/dinglehopper/ocrd_cli.py index 8eebdc0..401db6b 100644 --- a/src/dinglehopper/ocrd_cli.py +++ b/src/dinglehopper/ocrd_cli.py @@ -1,3 +1,4 @@ +import importlib_resources import json import os @@ -5,11 +6,14 @@ import click from ocrd import Processor from ocrd.decorators import ocrd_cli_options, ocrd_cli_wrap_processor from ocrd_utils import assert_file_grp_cardinality, getLogger, make_file_id -from pkg_resources import resource_string from .cli import process as cli_process -OCRD_TOOL = json.loads(resource_string(__name__, "ocrd-tool.json").decode("utf8")) +OCRD_TOOL = json.loads( + importlib_resources.files(__name__) + .joinpath("ocrd-tool.json") + .read_text(encoding="utf-8", errors="strict") +) @click.command()