X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=Robots%2Fbkmk_rurllib.py;h=067799c737271b5ceeb373eeb321bc12eaf1e7ec;hb=2b3829aef193cb1951989a8cf97a96dcbfc084a1;hp=20b74239b8fb55fc184b08e2cf686ce8ca150983;hpb=cb9c36b39ed72cd1fa272130d2bcf162a89c3013;p=bookmarks_db.git diff --git a/Robots/bkmk_rurllib.py b/Robots/bkmk_rurllib.py index 20b7423..067799c 100644 --- a/Robots/bkmk_rurllib.py +++ b/Robots/bkmk_rurllib.py @@ -11,9 +11,7 @@ __license__ = "GNU GPL" __all__ = ['robot_urllib'] -import os import sys -import time import urllib from Robots.bkmk_robot_base import robot_base, get_error @@ -29,9 +27,9 @@ class RedirectException(Exception): class MyURLopener(urllib.URLopener): # Error 301 -- relocated (permanently) def http_error_301(self, url, fp, errcode, errmsg, headers, data=None): - if headers.has_key('location'): + if 'location' in headers: newurl = headers['location'] - elif headers.has_key('uri'): + elif 'uri' in headers: newurl = headers['uri'] else: newurl = "Nowhere" @@ -43,6 +41,8 @@ class MyURLopener(urllib.URLopener): http_error_303 = http_error_301 # Error 307 -- relocated (temporarily) http_error_307 = http_error_301 + # Error 308 -- relocated (permanently) + http_error_308 = http_error_301 # Error 401 -- authentication required def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): @@ -51,7 +51,7 @@ class MyURLopener(urllib.URLopener): def http_error_default(self, url, fp, errcode, errmsg, headers): if fp: - void = fp.read() + fp.read() fp.close() raise IOError(('http error', errcode, errmsg, headers)) @@ -104,7 +104,7 @@ class robot_urllib(robot_base): # Remove Accept-Charset del urllib._urlopener.addheaders[-1] - infile = open(fname, 'rb') + infile = open(fname, 'rt') content = infile.read() infile.close() @@ -117,7 +117,7 @@ class robot_urllib(robot_base): 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" + "it is not an error, actually" self.log(' no headers: %s' % bookmark.no_error) else: error = get_error(e)