X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;ds=sidebyside;f=Robots%2Fbkmk_rsimple.py;h=14a3f5804799365ebd0db637f8ecb04a3b593df9;hb=5ec101e58df6499cf2fe7ee38ead9e5a31cb59eb;hp=c0bf93055aa80e48f004eed10c804e89b34e6e63;hpb=44c9c00805ea0b158fa86b6774ad01306487266f;p=bookmarks_db.git diff --git a/Robots/bkmk_rsimple.py b/Robots/bkmk_rsimple.py index c0bf930..14a3f58 100644 --- a/Robots/bkmk_rsimple.py +++ b/Robots/bkmk_rsimple.py @@ -5,7 +5,7 @@ """ -import sys, os, string +import sys, os import time, urllib from base64 import b64encode from urlparse import urljoin @@ -48,7 +48,8 @@ urllib._urlopener = MyURLopener() # Fake headers to pretend this is a real browser _version = "Links (2.1; Linux 2.6 i686; 80x25)" urllib._urlopener.addheaders[0] = ('User-Agent', _version) -_version = "bookmarks_db (Python %d.%d.%d; urllib/%s)" % (sys.version_info[:3], urllib.__version__) +_version = "bookmarks_db (Python %d.%d.%d; urllib/%s)" % ( + sys.version_info[0], sys.version_info[1], sys.version_info[2], urllib.__version__) urllib._urlopener.addheader('X-User-Agent', _version) urllib._urlopener.addheader('Connection', 'close') @@ -60,14 +61,14 @@ urllib._urlopener.addheader('Referer', 'http://www.yahoo.com/') def get_error(msg): - if type(msg) == type(""): + if isinstance(msg, str): return msg else: s = [] for i in msg: - s.append("'%s'" % string.join(string.split(str(i), "\n"), "\\n")) - return "(%s)" % string.join(s) + s.append("'%s'" % str(i).replace('\n', "\\n")) + return "(%s)" % ' '.join(s) urllib_ftpwrapper = urllib.ftpwrapper @@ -77,7 +78,7 @@ class myftpwrapper(urllib_ftpwrapper): def __init__(self, user, passwd, host, port, dirs): urllib_ftpwrapper.__init__(self, user, passwd, host, port, dirs) global ftpcache_key - ftpcache_key = (user, host, port, string.join(dirs, '/')) + ftpcache_key = (user, host, port, tuple(dirs)) urllib.ftpwrapper = myftpwrapper @@ -178,7 +179,7 @@ class robot_simple(Robot): if not icon: icon = "/favicon.ico" icon = urljoin("%s://%s%s" % (url_type, url_host, url_path), icon) - if self.log: self.log(" looking for icon at : %s" % icon) + if self.log: self.log(" looking for icon at: %s" % icon) try: for i in range(8): try: