File tree 1 file changed +15
-4
lines changed 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,24 @@ def getResource(identifier, pkgname=__name__):
22
22
import os
23
23
24
24
try :
25
- from importlib import resources
25
+ import importlib_resources
26
26
27
27
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 ()
29
42
30
- def resource_stream (_package_of_requirement , _resource_name ):
31
- return resources .read_binary (_package_of_requirement , _resource_name )
32
43
33
44
except ImportError :
34
45
You can’t perform that action at this time.
0 commit comments