Skip to content

Commit 46fdbc4

Browse files
committed
actually follow the migration guide this time...
1 parent c336c51 commit 46fdbc4

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src_py/pkgdata.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,24 @@ def getResource(identifier, pkgname=__name__):
2222
import os
2323

2424
try:
25-
from importlib import resources
25+
import importlib_resources
2626

2727
def resource_exists(_package_or_requirement, _resource_name):
28-
return resources.is_resource(_package_or_requirement, _resource_name)
28+
return (
29+
importlib_resources.files(_package_or_requirement)
30+
.joinpath(_resource_name)
31+
.is_file()
32+
)
33+
34+
def resource_stream(_package_or_requirement, _resource_name):
35+
ref = (
36+
importlib_resources.files(_package_or_requirement)
37+
.joinpath(_resource_name)
38+
.is_file()
39+
)
40+
with ref.open('rb') as fp:
41+
return fp.read()
2942

30-
def resource_stream(_package_of_requirement, _resource_name):
31-
return resources.read_binary(_package_of_requirement, _resource_name)
3243

3344
except ImportError:
3445

0 commit comments

Comments
 (0)