]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/bkmk_rurllib.py
Style: Fix flake8 F401 module imported but unused
[bookmarks_db.git] / Robots / bkmk_rurllib.py
index 0045f2d9f428dae8a428bbdb021f65ff9c627483..55e0037e8999e261010d095af4eb1a9b61ad9852 100644 (file)
@@ -11,8 +11,9 @@ __license__ = "GNU GPL"
 __all__ = ['robot_urllib']
 
 
-import sys, os
-import time, urllib
+import sys
+import urllib
+
 from Robots.bkmk_robot_base import robot_base, get_error
 
 
@@ -43,7 +44,8 @@ class MyURLopener(urllib.URLopener):
 
     # Error 401 -- authentication required
     def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):
-        raise IOError(('http error', errcode, "Authentication required ", headers))
+        raise IOError(
+            ('http error', errcode, "Authentication required ", headers))
 
     def http_error_default(self, url, fp, errcode, errmsg, headers):
         if fp:
@@ -55,10 +57,13 @@ class MyURLopener(urllib.URLopener):
 urllib._urlopener = MyURLopener()
 
 # Fake headers to pretend this is a real browser
-_user_agent = "Mozilla/5.0 (X11; U; Linux 2.6 i686; en) Gecko/20001221 Firefox/2.0.0"
+_user_agent = "Mozilla/5.0 (X11; U; Linux 2.6 i686; en)"
+" Gecko/20001221 Firefox/2.0.0"
 urllib._urlopener.addheaders[0] = ('User-Agent', _user_agent)
 _x_user_agent = "bookmarks_db (Python %d.%d.%d; urllib/%s)" % (
-   sys.version_info[0], sys.version_info[1], sys.version_info[2], urllib.__version__)
+   sys.version_info[0], sys.version_info[1],
+   sys.version_info[2], urllib.__version__
+)
 urllib._urlopener.addheader('X-User-Agent', _x_user_agent)
 urllib._urlopener.addheader('Referer', '')
 
@@ -94,7 +99,8 @@ class robot_urllib(robot_base):
                 fname, headers = urllib.urlretrieve(url)
             finally:
                 if accept_charset and bookmark.charset:
-                    del urllib._urlopener.addheaders[-1]  # Remove Accept-Charset
+                    # Remove Accept-Charset
+                    del urllib._urlopener.addheaders[-1]
 
             infile = open(fname, 'rb')
             content = infile.read()
@@ -108,7 +114,8 @@ class robot_urllib(robot_base):
         except IOError as e:
             if (e[0] == "http error") and (e[1] == -1):
                 error = None
-                bookmark.no_error = "The server did not return any header - it is not an error, actually"
+                bookmark.no_error = "The server did not return any header - "
+                "it is not an error, actually"
                 self.log('   no headers: %s' % bookmark.no_error)
             else:
                 error = get_error(e)