Skip to content

Commit

Permalink
importlib.resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Henri Wahl committed Dec 19, 2024
1 parent 3ad5f45 commit a45f206
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Nagstamon/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))]
Expand Down

0 comments on commit a45f206

Please sign in to comment.