]> git.phdru.name Git - bookmarks_db.git/blobdiff - bkmk_parser.py
Moved parse_html.py and its submodules to a separate parse_html module.
[bookmarks_db.git] / bkmk_parser.py
old mode 100755 (executable)
new mode 100644 (file)
index 02cce68..3f2182c
@@ -1,7 +1,7 @@
 """
    Parser for Netscape Navigator's and Mozilla's bookmarks.html
 
-   Written by BroytMann. Copyright (C) 1997-2007 PhiloSoft Design
+   Written by Broytman. Copyright (C) 1997-2008 PhiloSoft Design
 """
 
 
@@ -45,7 +45,7 @@ class BkmkParser(HTMLParser):
    def handle_data(self, data):
       if data:
          if DEFAULT_CHARSET:
-            data = unicode(data, self.charset, "replace").encode(DEFAULT_CHARSET, "replace")
+            data = unicode(data, self.charset, "replace").encode(DEFAULT_CHARSET, "xmlcharrefreplace")
          self.accumulator += data
 
 
@@ -135,9 +135,12 @@ class BkmkParser(HTMLParser):
 
    # Start a bookmark
    def start_a(self, attrs):
+      add_date = None
       last_visit = None
       last_modified = None
       keyword = None
+      icon = None
+      charset = None
 
       for attrname, value in attrs:
          value = value.strip()
@@ -151,9 +154,14 @@ class BkmkParser(HTMLParser):
             last_modified = value
          elif attrname == "shortcuturl":
             keyword = value
+         elif attrname == "icon":
+            icon = value
+         elif attrname == "last_charset":
+            charset = value
 
       debug("Bookmark points to: `%s'" % href)
-      bookmark = Bookmark(href, add_date, last_visit, last_modified, keyword or '')
+      bookmark = Bookmark(href, add_date, last_visit, last_modified,
+         keyword or '', '', icon, charset)
       self.current_object = bookmark
       self.current_folder.append(bookmark)
       self.urls += 1