From 5a3a639d28368406ca2e02584ee7924cb0ae8089 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 4 Aug 2004 13:09:11 +0000 Subject: [PATCH] Implemented keywords in Mozilla bookmarks. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@33 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- Storage/bkmk_stflad.py | 7 ++++--- Writers/bkmk_wflad.py | 5 +++-- Writers/bkmk_whtml.py | 6 ++++-- bkmk_objects.py | 5 +++-- bkmk_parser.py | 19 +++++++++++-------- doc/ANNOUNCE | 9 +++++---- 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Storage/bkmk_stflad.py b/Storage/bkmk_stflad.py index 3c89a3e..3c017fa 100644 --- a/Storage/bkmk_stflad.py +++ b/Storage/bkmk_stflad.py @@ -2,7 +2,7 @@ Bookmarks storage module - FLAD (Flat ASCII Database) special version for compatibility with old (version 1) bkmk2db - Written by BroytMann, Feb 2000 - Mar 2000. Copyright (C) 2000 PhiloSoft Design + Written by BroytMann, Feb 2000 - Aug 2004. Copyright (C) 2000-2004 PhiloSoft Design """ @@ -43,8 +43,9 @@ URL: %s AddDate: %s LastVisit: %s LastModified: %s +Keyword: %s Comment: %s -""" % (level+1, b.name, b.href, b.add_date, b.last_visit, b.last_modified, b.comment)) +""" % (level+1, b.name, b.href, b.add_date, b.last_visit, b.last_modified, b.keyword, b.comment)) def ruler(self, r, level): @@ -103,7 +104,7 @@ Comment: %s got_folder = record.has_key("Folder") # Test here to save got_folder for next loop if record.has_key("URL"): - bookmark = Bookmark(record["URL"], record["AddDate"], record["LastVisit"], record["LastModified"], record["Comment"]) + bookmark = Bookmark(record["URL"], record["AddDate"], record["LastVisit"], record["LastModified"], record["Keyword"], record["Comment"]) bookmark.name = record["Title"] self.current_folder.append(bookmark) diff --git a/Writers/bkmk_wflad.py b/Writers/bkmk_wflad.py index dc46a83..7619eb3 100644 --- a/Writers/bkmk_wflad.py +++ b/Writers/bkmk_wflad.py @@ -1,7 +1,7 @@ """ Dump bookmarks db to a more readable FLAD after check_urls - Written by BroytMann, Apr 2000 - Jun 2002. Copyright (C) 2000-2002 PhiloSoft Design + Written by BroytMann, Apr 2000 - Aug 2004. Copyright (C) 2000-2004 PhiloSoft Design """ @@ -41,7 +41,8 @@ URL: %s AddDate: %s LastVisit: %s LastModified: %s -Comment: %s""" % (level+1, b.name, b.href, strftime(b.add_date), strftime(b.last_visit), strftime(b.last_modified), b.comment)) +Keyword: %s +Comment: %s""" % (level+1, b.name, b.href, strftime(b.add_date), strftime(b.last_visit), strftime(b.last_modified), b.keyword, b.comment)) for attr_name, attr_out in (("error", "Error"), ("no_error", "NoError"), ("moved", "Moved"), ("size", "Size"), ("md5", "Md5"), diff --git a/Writers/bkmk_whtml.py b/Writers/bkmk_whtml.py index 918101d..8b172fc 100644 --- a/Writers/bkmk_whtml.py +++ b/Writers/bkmk_whtml.py @@ -1,7 +1,7 @@ """ Convert a bkmk database back to bookmarks.html - Written by BroytMann. Copyright (C) 2000-2003 PhiloSoft Design + Written by BroytMann. Copyright (C) 2000-2004 PhiloSoft Design """ @@ -41,7 +41,9 @@ class writer_html(Writer): self.outfile.write(ind_s*level + "

\n") def bookmark(self, b, level): - self.outfile.write(ind_s*(level+1) + '

%s\n' % (b.href, b.add_date, b.last_visit, b.last_modified, b.name)) + self.outfile.write(ind_s*(level+1) + '
%s\n' % b.name) if b.comment: self.outfile.write('
%s\n' % dump_comment(b.comment)) def ruler(self, r, level): diff --git a/bkmk_objects.py b/bkmk_objects.py index 04fe535..231fb2f 100644 --- a/bkmk_objects.py +++ b/bkmk_objects.py @@ -1,7 +1,7 @@ """ Objects to represent bookmarks.html structure - Written by BroytMann, Mar 2000 - Jul 2003. Copyright (C) 2000-2003 PhiloSoft Design + Written by BroytMann, Mar 2000 - Aug 2004. Copyright (C) 2000-2004 PhiloSoft Design """ @@ -43,12 +43,13 @@ class Bookmark: isBookmark = 1 def __init__(self, href, add_date, last_visit=None, last_modified=None, - comment = ''): + keyword=None, comment = ''): self.comment = comment self.href = href self.add_date = add_date self.last_visit = last_visit self.last_modified = last_modified + self.keyword = keyword class Ruler: diff --git a/bkmk_parser.py b/bkmk_parser.py index 327e0c4..be39a32 100755 --- a/bkmk_parser.py +++ b/bkmk_parser.py @@ -1,7 +1,7 @@ """ Parser for Netscape Navigator's and Mozilla's bookmarks.html - Written by BroytMann. Copyright (C) 1997-2003 PhiloSoft Design + Written by BroytMann. Copyright (C) 1997-2004 PhiloSoft Design """ @@ -98,7 +98,7 @@ class BkmkParser(HTMLParser): self.root_folder.name = accumulator - # Start next folder + # Start a folder def start_h3(self, attrs): for attrname, value in attrs: value = value.strip() @@ -121,24 +121,27 @@ class BkmkParser(HTMLParser): self.current_folder.name = accumulator - # Start bookmark + # Start a bookmark def start_a(self, attrs): last_visit = None last_modified = None + keyword = None for attrname, value in attrs: value = value.strip() - if attrname == 'href': + if attrname == "href": href = value - if attrname == 'add_date': + elif attrname == "add_date": add_date = value - if attrname == 'last_visit': + elif attrname == "last_visit": last_visit = value - if attrname == 'last_modified': + elif attrname == "last_modified": last_modified = value + elif attrname == "shortcuturl": + keyword = value debug("Bookmark points to: `%s'" % href) - bookmark = Bookmark(href, add_date, last_visit, last_modified) + bookmark = Bookmark(href, add_date, last_visit, last_modified, keyword) self.current_object = bookmark self.current_folder.append(bookmark) self.urls += 1 diff --git a/doc/ANNOUNCE b/doc/ANNOUNCE index 5160ef7..4759c44 100644 --- a/doc/ANNOUNCE +++ b/doc/ANNOUNCE @@ -9,8 +9,9 @@ extend Navigator's "What's new" feature (Navigator 4 calls it "Update bookmarks"). -WHAT'S NEW in version 3.4.0 - Updated to m_lib version 1.2. Extended support for Mozilla. +WHAT'S NEW in version 3.4.0 (2004-07-27) + Updated to m_lib version 1.2. Extended support for Mozilla; +keywords in bookmarks. WHAT'S NEW in version 3.3.2 @@ -32,10 +33,10 @@ managers, writers (DB dumpers/exporters) and robots. WHERE TO GET - Master site: http://phd.pp.ru/Software/Python/#bookmarks_db + Master site: http://phd.pp.ru/Software/Python/#bookmarks_db Faster mirrors: http://phd.by.ru/Software/Python/#bookmarks_db - http://phd2.chat.ru/Software/Python/#bookmarks_db + http://phd2.chat.ru/Software/Python/#bookmarks_db AUTHOR -- 2.39.5