File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 2
2
from urllib .parse import urlsplit
3
3
import itertools
4
4
import json
5
- import pkgutil
6
5
import re
6
+ import sys
7
+
8
+ # The files() API was added in Python 3.9.
9
+ if sys .version_info >= (3 , 9 ): # pragma: no cover
10
+ import importlib .resources as resources
11
+ else : # pragma: no cover
12
+ import importlib_resources as resources
7
13
8
14
9
15
class URIDict (MutableMapping ):
@@ -51,8 +57,9 @@ def load_schema(name):
51
57
Load a schema from ./schemas/``name``.json and return it.
52
58
"""
53
59
54
- data = pkgutil .get_data ("jsonschema" , "schemas/{0}.json" .format (name ))
55
- return json .loads (data .decode ("utf-8" ))
60
+ path = resources .files (__package__ ).joinpath (f"schemas/{ name } .json" )
61
+ data = path .read_text (encoding = "utf-8" )
62
+ return json .loads (data )
56
63
57
64
58
65
def format_as_index (container , indices ):
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ python_requires = >=3.7
28
28
install_requires =
29
29
attrs>=17.4.0
30
30
importlib_metadata; python_version<'3.8'
31
+ importlib_resources; python_version<'3.9'
31
32
pyrsistent>=0.14.0,!=0.17.0,!=0.17.1,!=0.17.2
32
33
33
34
[options.extras_require]
You can’t perform that action at this time.
0 commit comments