From da537628043304b72da5d686d041e57d630092d4 Mon Sep 17 00:00:00 2001 From: Joakim Soderlund Date: Sat, 4 Aug 2018 15:00:56 +0200 Subject: [PATCH] Use importlib resources --- fimfarchive/utils.py | 8 +++----- requirements.txt | 1 + setup.py | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fimfarchive/utils.py b/fimfarchive/utils.py index 633948c..e9d5e3b 100644 --- a/fimfarchive/utils.py +++ b/fimfarchive/utils.py @@ -26,8 +26,8 @@ import json import os import shutil from functools import partial +from importlib_resources import read_binary, read_text from typing import Any, Dict, Optional, Type, TypeVar, Union -from pkg_resources import resource_string from tqdm import tqdm @@ -172,9 +172,7 @@ class ResourceLoader: if binary is None: binary = self.binary - data = resource_string(self.package, name) - if binary: - return data + return read_binary(self.package, name) else: - return data.decode() + return read_text(self.package, name) diff --git a/requirements.txt b/requirements.txt index f4d3d6e..8850eed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ blinker boltons flake8 git+https://github.com/qvantel/jsonapi-client.git +importlib_resources jmespath mypy pytest diff --git a/setup.py b/setup.py index 2dbd1e6..3d63e3d 100755 --- a/setup.py +++ b/setup.py @@ -89,6 +89,7 @@ setup( 'bbcode', 'blinker', 'boltons', + 'importlib_resources', 'jmespath', 'jsonapi-client', 'requests',