From a45f2066d18a643e15060a0963196bdc92f1744e Mon Sep 17 00:00:00 2001 From: Henri Wahl Date: Thu, 19 Dec 2024 16:40:14 +0100 Subject: [PATCH] importlib.resources --- Nagstamon/Config.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Nagstamon/Config.py b/Nagstamon/Config.py index da59e74a..66595e61 100644 --- a/Nagstamon/Config.py +++ b/Nagstamon/Config.py @@ -19,6 +19,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from argparse import ArgumentParser +from importlib import resources import os import platform import sys @@ -1063,12 +1064,10 @@ def __init__(self, **kwds): if os.path.exists(os.path.normcase(os.sep.join((executable_dir, "resources")))): RESOURCES = os.path.normcase(os.sep.join((executable_dir, "resources"))) else: - import pkg_resources - - RESOURCES = pkg_resources.resource_filename("Nagstamon", "resources") + RESOURCES = resources.files("Nagstamon").joinpath("resources") except Exception as err: - # get resources directory from current directory - only if not being set before by pkg_resources + # get resources directory from current directory - only if not being set before # try-excepts necessary for platforms like Windows .EXE paths_to_check = [os.path.normcase(os.path.join(os.getcwd(), "Nagstamon", "resources")), os.path.normcase(os.path.join(os.getcwd(), "resources"))]