eric6/WebBrowser/SafeBrowsing/SafeBrowsingUrl.py

branch
without_py2_and_pyqt4
changeset 7192
a22eee00b052
parent 6942
2602857055c5
child 7229
53054eb5b15a
diff -r 960850ec284c -r a22eee00b052 eric6/WebBrowser/SafeBrowsing/SafeBrowsingUrl.py
--- a/eric6/WebBrowser/SafeBrowsing/SafeBrowsingUrl.py	Sat Aug 31 12:29:57 2019 +0200
+++ b/eric6/WebBrowser/SafeBrowsing/SafeBrowsingUrl.py	Sat Aug 31 12:58:11 2019 +0200
@@ -9,18 +9,12 @@
 
 from __future__ import unicode_literals
 
-try:
-    import urlparse     # Py2
-    import urllib       # Py2
-except ImportError:
-    import urllib.parse as urllib
-    from urllib import parse as urlparse
-
 import re
 import posixpath
 import socket
 import struct
 import hashlib
+import urllib.parse
 
 import Preferences
 
@@ -70,7 +64,7 @@
             @return unescaped URL string
             @rtype str
             """
-            uu = urllib.unquote(u)
+            uu = urllib.parse.unquote(u)
             if uu == u:
                 return uu
             else:
@@ -86,7 +80,7 @@
             @rtype str
             """
             safeChars = '!"$&\'()*+,-./:;<=>?@[\\]^_`{|}~'
-            return urllib.quote(s, safe=safeChars)
+            return urllib.parse.quote(s, safe=safeChars)
         
         url = self.__url.strip()
         url = url.replace('\n', '').replace('\r', '').replace('\t', '')
@@ -96,10 +90,10 @@
         if len(url.split('://')) <= 1:
             url = Preferences.getWebBrowser("DefaultScheme") + url
         url = quote(fullUnescape(url))
-        urlParts = urlparse.urlsplit(url)
+        urlParts = urllib.parse.parse.urlsplit(url)
         if not urlParts[0]:
             url = Preferences.getWebBrowser("DefaultScheme") + url
-            urlParts = urlparse.urlsplit(url)
+            urlParts = urllib.parse.parse.urlsplit(url)
         protocol = urlParts.scheme
         host = fullUnescape(urlParts.hostname)
         path = fullUnescape(urlParts.path)
@@ -184,10 +178,10 @@
                 curPath = curPath + pathParts[i] + '/'
                 yield curPath
         
-        protocol, addressStr = urllib.splittype(url)
-        host, path = urllib.splithost(addressStr)
-        user, host = urllib.splituser(host)
-        host, port = urllib.splitport(host)
+        protocol, addressStr = urllib.parse.splittype(url)
+        host, path = urllib.parse.splithost(addressStr)
+        user, host = urllib.parse.splituser(host)
+        host, port = urllib.parse.splitport(host)
         host = host.strip('/')
         seenPermutations = set()
         for h in hostPermutations(host):

eric ide

mercurial