7
7
"""
8
8
9
9
import contextlib
10
- import json
11
10
import re
12
11
from urllib import parse as urlparse
13
- from urllib .parse import unquote
14
- from urllib .request import urlopen
15
12
16
13
from .exceptions import JsonSchemaDefinitionException
17
14
@@ -29,6 +26,8 @@ def resolve_path(schema, fragment):
29
26
30
27
Path is unescaped according https://tools.ietf.org/html/rfc6901
31
28
"""
29
+ from urllib .parse import unquote
30
+
32
31
fragment = fragment .lstrip ('/' )
33
32
parts = unquote (fragment ).split ('/' ) if fragment else []
34
33
for part in parts :
@@ -55,6 +54,9 @@ def resolve_remote(uri, handlers):
55
54
urllib library is used to fetch requests from the remote ``uri``
56
55
if handlers does notdefine otherwise.
57
56
"""
57
+ import json
58
+ from urllib .request import urlopen
59
+
58
60
scheme = urlparse .urlsplit (uri ).scheme
59
61
if scheme in handlers :
60
62
result = handlers [scheme ](uri )
@@ -149,6 +151,8 @@ def get_scope_name(self):
149
151
"""
150
152
Get current scope and return it as a valid function name.
151
153
"""
154
+ from urllib .parse import unquote
155
+
152
156
name = 'validate_' + unquote (self .resolution_scope ).replace ('~1' , '_' ).replace ('~0' , '_' ).replace ('"' , '' )
153
157
name = re .sub (r'($[^a-zA-Z]|[^a-zA-Z0-9])' , '_' , name )
154
158
name = name .lower ().rstrip ('_' )
0 commit comments