1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
Description: Replace deprecated pkg_resources with importlib.resources
Author: Andreas Tille <tille@debian.org>
Bug-Debian: https://bugs.debian.org/1083788
Last-Update: 2026-01-17
--- a/logic/subuserlib/paths.py
+++ b/logic/subuserlib/paths.py
@@ -7,6 +7,11 @@ Module used for determining non-user-con
#external imports
import os
import inspect
+try:
+ import importlib.resources as importlib_resources
+except ImportError:
+ # For compatibility with older Python versions (< 3.7)
+ import importlib_resources
#internal imports
import subuserlib.executablePath as executablePath
@@ -36,9 +41,8 @@ def getSubuserDataFile(filename):
if os.path.exists(dataFile):
return dataFile
else:
- import pkg_resources
- dataFile = pkg_resources.resource_filename("subuserlib",os.path.join("data",filename))
- if not os.path.exists(dataFile):
+ ref = importlib_resources.files("subuserlib").joinpath("data", filename)
+ if not ref.is_file():
exit("Data file does not exist:"+str(dataFile))
else:
- return dataFile
+ return str(ref)
|