##// END OF EJS Templates
resourceutil: start using importlib.resources.files() when possible...
av6 -
r50838:330d8821 stable
parent child Browse files
Show More
@@ -59,6 +59,9 b' try:'
59 59 from importlib import resources # pytype: disable=import-error
60 60
61 61 # Force loading of the resources module
62 if pycompat.safehasattr(resources, 'files'):
63 resources.files # pytype: disable=module-attr
64 else:
62 65 resources.open_binary # pytype: disable=module-attr
63 66
64 67 # py2exe raises an AssertionError if uses importlib.resources
@@ -92,6 +95,15 b' else:'
92 95 from .. import encoding
93 96
94 97 def open_resource(package, name):
98 if pycompat.safehasattr(resources, 'files'):
99 return (
100 resources.files( # pytype: disable=module-attr
101 pycompat.sysstr(package)
102 )
103 .joinpath(pycompat.sysstr(name))
104 .open('rb')
105 )
106 else:
95 107 return resources.open_binary( # pytype: disable=module-attr
96 108 pycompat.sysstr(package), pycompat.sysstr(name)
97 109 )
General Comments 0
You need to be logged in to leave comments. Login now