88
99import six
1010from six .moves import range
11- from six .moves .urllib import parse
1211from six .moves import urllib
1312from six import StringIO
1413
@@ -57,7 +56,7 @@ def file_uri(path, split_frag=False): # type: (str, bool) -> str
5756 return "file://%s%s" % (urlpath , frag )
5857
5958def uri_file_path (url ): # type: (str) -> str
60- split = parse .urlsplit (url )
59+ split = urllib . parse .urlsplit (url )
6160 if split .scheme == "file" :
6261 return urllib .request .url2pathname (
6362 str (split .path )) + ("#" + urllib .parse .unquote (str (split .fragment ))
@@ -129,7 +128,7 @@ def fetch_text(self, url):
129128 if url in self .cache :
130129 return self .cache [url ]
131130
132- split = parse .urlsplit (url )
131+ split = urllib . parse .urlsplit (url )
133132 scheme , path = split .scheme , split .path
134133
135134 if scheme in [u'http' , u'https' ] and self .session is not None :
@@ -159,7 +158,7 @@ def check_exists(self, url): # type: (Text) -> bool
159158 if url in self .cache :
160159 return True
161160
162- split = parse .urlsplit (url )
161+ split = urllib . parse .urlsplit (url )
163162 scheme , path = split .scheme , split .path
164163
165164 if scheme in [u'http' , u'https' ] and self .session is not None :
@@ -175,7 +174,7 @@ def check_exists(self, url): # type: (Text) -> bool
175174 raise ValueError ('Unsupported scheme in url: %s' % url )
176175
177176 def urljoin (self , base_url , url ): # type: (Text, Text) -> Text
178- return parse .urljoin (base_url , url )
177+ return urllib . parse .urljoin (base_url , url )
179178
180179class Loader (object ):
181180 def __init__ (self ,
@@ -190,7 +189,7 @@ def __init__(self,
190189 ):
191190 # type: (...) -> None
192191
193- normalize = lambda url : parse .urlsplit (url ).geturl ()
192+ normalize = lambda url : urllib . parse .urlsplit (url ).geturl ()
194193 if idx is not None :
195194 self .idx = idx
196195 else :
@@ -276,20 +275,20 @@ def expand_url(self,
276275 if prefix in self .vocab :
277276 url = self .vocab [prefix ] + url [len (prefix ) + 1 :]
278277
279- split = parse .urlsplit (url )
278+ split = urllib . parse .urlsplit (url )
280279
281280 if (bool (split .scheme ) or url .startswith (u"$(" )
282281 or url .startswith (u"${" )):
283282 pass
284283 elif scoped_id and not bool (split .fragment ):
285- splitbase = parse .urlsplit (base_url )
284+ splitbase = urllib . parse .urlsplit (base_url )
286285 frg = u""
287286 if bool (splitbase .fragment ):
288287 frg = splitbase .fragment + u"/" + split .path
289288 else :
290289 frg = split .path
291290 pt = splitbase .path if splitbase .path != '' else "/"
292- url = parse .urlunsplit (
291+ url = urllib . parse .urlunsplit (
293292 (splitbase .scheme , splitbase .netloc , pt , splitbase .query , frg ))
294293 elif scoped_ref is not None and not split .fragment :
295294 pass
@@ -496,7 +495,7 @@ def resolve_ref(self,
496495 doc_url = url
497496 else :
498497 # Load structured document
499- doc_url , frg = parse .urldefrag (url )
498+ doc_url , frg = urllib . parse .urldefrag (url )
500499 if doc_url in self .idx and (not mixin ):
501500 # If the base document is in the index, it was already loaded,
502501 # so if we didn't find the reference earlier then it must not
@@ -872,7 +871,7 @@ def fetch(self, url, inject_ids=True): # type: (Text, bool) -> Any
872871
873872 def validate_scoped (self , field , link , docid ):
874873 # type: (Text, Text, Text) -> Text
875- split = parse .urlsplit (docid )
874+ split = urllib . parse .urlsplit (docid )
876875 sp = split .fragment .split (u"/" )
877876 n = self .scoped_ref_fields [field ]
878877 while n > 0 and len (sp ) > 0 :
@@ -881,7 +880,7 @@ def validate_scoped(self, field, link, docid):
881880 tried = []
882881 while True :
883882 sp .append (link )
884- url = parse .urlunsplit ((
883+ url = urllib . parse .urlunsplit ((
885884 split .scheme , split .netloc , split .path , split .query ,
886885 u"/" .join (sp )))
887886 tried .append (url )
0 commit comments