]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/bkmk_robot_base.py
Fix(Py3): Fix import from `urllib`
[bookmarks_db.git] / Robots / bkmk_robot_base.py
index d6a87d31cd41682ee3d48549868442814a15cebe..d2175ace96bc3c9d084cc3b3e0394ffe0929791e 100644 (file)
@@ -15,7 +15,10 @@ from base64 import b64encode
 import sys
 import socket
 import time
-import urllib
+try:
+    from urllib.parse import splittype, splithost, splittag
+except ImportError:
+    from urllib import splittype, splithost, splittag
 from urlparse import urljoin
 
 from m_lib.md5wrapper import md5wrapper
@@ -62,10 +65,10 @@ class robot_base(Robot):
             self.start = int(time.time())
             bookmark.icon = None
 
-            url_type, url_rest = urllib.splittype(bookmark.href)
-            url_host, url_path = urllib.splithost(url_rest)
-            url_path, url_tag  = urllib.splittag(url_path)  # noqa: E221
-            #                            multiple spaces before operator
+            url_type, url_rest = splittype(bookmark.href)
+            url_host, url_path = splithost(url_rest)
+            url_path, url_tag  = splittag(url_path)  # noqa: E221
+            #                    multiple spaces before operator
 
             url = "%s://%s%s" % (url_type, url_host, url_path)
             error, redirect_code, redirect_to, headers, content = \
@@ -171,10 +174,10 @@ class robot_base(Robot):
                                 else:
                                     raise IOError("Too many redirects")
                             except:
-                                etype, emsg, tb = sys.exc_info()
+                                etype, emsg, _ = sys.exc_info()
                                 self.log("   no icon        : %s %s"
                                          % (etype, emsg))
-                                etype = emsg = tb = None
+                                etype = emsg = _ = None
                                 icons[icon_url] = None
                             else:
                                 content_type = icon_headers["Content-Type"]