]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/bkmk_rsimple.py
Added __all__.
[bookmarks_db.git] / Robots / bkmk_rsimple.py
index 41fa2b33a607fe1db2e1a322520d47abd2cb6d46..871082fe4a0113eddab4435582443fc29db0d068 100644 (file)
@@ -1,9 +1,18 @@
-"""
-   Simple, strightforward robot
+"""Simple, strightforward robot
 
-   Written by Oleg Broytman. Copyright (C) 2000-2010 PhiloSoft Design.
+This file is a part of Bookmarks database and Internet robot.
 """
 
+__version__ = "$Revision$"[11:-2]
+__revision__ = "$Id$"[5:-2]
+__date__ = "$Date$"[7:-2]
+__author__ = "Oleg Broytman <phd@phdru.name>"
+__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
+__license__ = "GNU GPL"
+
+__all__ = ['robot_simple', 'get_error']
+
+
 import sys, os
 import time, urllib
 from base64 import b64encode
@@ -206,19 +215,23 @@ class robot_simple(Robot):
                      except:
                         etype, emsg, tb = sys.exc_info()
                         self.log("   no icon        : %s %s" % (etype, emsg))
-                        etype = None
-                        emsg = None
-                        tb = None
+                        etype = emsg = tb = None
                         icons[icon] = None
                      else:
                         content_type = headers["Content-Type"]
-                        if content_type.startswith("image/"):
+                        if content_type.startswith("application/") \
+                              or content_type.startswith("image/") \
+                              or content_type.startswith("text/plain"):
                            icon_file = open(icon_fname, "rb")
                            icon_data = icon_file.read()
                            icon_file.close()
                            bookmark.icon_href = icon
-                           bookmark.icon = "data:%s;base64,%s" % (content_type, b64encode(icon_data))
                            self.log("   got icon       : %s" % content_type)
+                           if content_type.startswith("application/") \
+                                 or content_type.startswith("text/plain"):
+                              self.log("       non-image content type, assume x-icon")
+                              content_type = 'image/x-icon'
+                           bookmark.icon = "data:%s;base64,%s" % (content_type, b64encode(icon_data))
                            icons[icon] = (content_type, bookmark.icon)
                         else:
                            self.log("   no icon        : bad content type '%s'" % content_type)
@@ -275,7 +288,6 @@ class robot_simple(Robot):
       # Tested
       return 1
 
-
    def finish_check_url(self, bookmark, fname=None):
       # Calculate these attributes even in case of an error
       if fname and os.path.exists(fname):