]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/bkmk_rsimple.py
Split parse_html/__init__.py into __main__.py
[bookmarks_db.git] / Robots / bkmk_rsimple.py
index 871082fe4a0113eddab4435582443fc29db0d068..2c4df9e278f99b186daa869720f9437c81f7cefa 100644 (file)
@@ -1,13 +1,11 @@
 """Simple, strightforward robot
 
 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"
+__copyright__ = "Copyright (C) 2000-2014 PhiloSoft Design"
 __license__ = "GNU GPL"
 
 __all__ = ['robot_simple', 'get_error']
@@ -22,13 +20,15 @@ from m_lib.net.www.util import parse_time
 from m_lib.md5wrapper import md5wrapper
 
 from bkmk_objects import Robot
-from parse_html import parse_html
+from parse_html import parse_filename
 
 
 class RedirectException(Exception):
    reloc_dict = {
       301: "perm.",
-      302: "temp.",
+      302: "temp2.",
+      303: "temp3.",
+      307: "temp7.",
       "html": "html"
    }
    def __init__(self, errcode, newurl):
@@ -182,7 +182,7 @@ class robot_simple(Robot):
                else:
                   html = False
                if html:
-                  parser = parse_html(fname, charset, self.log)
+                  parser = parse_filename(fname, charset, self.log)
                   if parser:
                       bookmark.real_title = parser.title
                       icon = parser.icon
@@ -196,9 +196,9 @@ class robot_simple(Robot):
                      if icons[icon]:
                         bookmark.icon_href = icon
                         content_type, bookmark.icon = icons[icon]
-                        self.log("       cached icon: %s" % content_type)
+                        self.log("   cached icon: %s" % content_type)
                      else:
-                        self.log("       cached icon: no icon")
+                        self.log("   cached icon: no icon")
                   else:
                      try:
                         _icon = icon
@@ -207,7 +207,7 @@ class robot_simple(Robot):
                               icon_fname, headers = urllib.urlretrieve(_icon)
                            except RedirectException, e:
                               _icon = e.url
-                              self.log("       redirect to : %s" % _icon)
+                              self.log("   redirect to : %s" % _icon)
                            else:
                               break
                         else:
@@ -229,7 +229,7 @@ class robot_simple(Robot):
                            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")
+                              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)