From 57d53f63b15db94bb391b8abf637ee7c3fb5c4ca Mon Sep 17 00:00:00 2001 From: Joakim Soderlund Date: Sun, 25 Sep 2022 13:15:34 +0200 Subject: [PATCH] Fix deprecation warning in resource loader --- fimfarchive/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fimfarchive/utils.py b/fimfarchive/utils.py index 852a9fc..4d0aa1f 100644 --- a/fimfarchive/utils.py +++ b/fimfarchive/utils.py @@ -27,7 +27,7 @@ import os import shutil from functools import partial from importlib import import_module -from importlib_resources import read_binary, read_text +from importlib_resources import files from pathlib import Path from typing import ( cast, Any, Callable, Dict, Iterator, @@ -295,7 +295,10 @@ class ResourceLoader: if binary is None: binary = self.binary + package = files(self.package) + resource = package.joinpath(name) + if binary: - return read_binary(self.package, name) + return resource.read_bytes() else: - return read_text(self.package, name) + return resource.read_text()