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