From 5291c9e91503d288a4a50a30345d1d33ced56f32 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 21 Sep 2007 14:44:49 +0000 Subject: [PATCH] Store icon and charset in bookmark's attributes. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@69 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- Storage/bkmk_stflad.py | 6 ++++-- Writers/bkmk_wflad.py | 5 +++-- Writers/bkmk_whtml.py | 7 ++++--- bkmk_objects.py | 8 +++++--- bkmk_parser.py | 9 ++++++++- doc/TODO | 2 +- 6 files changed, 25 insertions(+), 12 deletions(-) mode change 100755 => 100644 bkmk_parser.py diff --git a/Storage/bkmk_stflad.py b/Storage/bkmk_stflad.py index 2545f6d..b257622 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 2005. Copyright (C) 2000-2005 PhiloSoft Design + Written by BroytMann, Feb 2000 - Sep 2007. Copyright (C) 2000-2007 PhiloSoft Design """ @@ -45,8 +45,10 @@ LastVisit: %s LastModified: %s Keyword: %s Comment: %s +Icon: %s +Charset: %s """ % (level+1, b.name, b.href, b.add_date, b.last_visit, b.last_modified, - b.keyword, b.comment.replace('\n', "\\n"))) + b.keyword, b.comment.replace('\n', "\\n"), b.icon or '', b.charset or '')) def ruler(self, r, level): diff --git a/Writers/bkmk_wflad.py b/Writers/bkmk_wflad.py index 2d26158..0ba7075 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 - Aug 2004. Copyright (C) 2000-2004 PhiloSoft Design + Written by BroytMann, Apr 2000 - Sep 2007. Copyright (C) 2000-2007 PhiloSoft Design """ @@ -47,7 +47,8 @@ Comment: %s""" % (level+1, b.name, b.href, strftime(b.add_date), strftime(b.last for attr_name, attr_out in (("error", "Error"), ("no_error", "NoError"), ("moved", "Moved"), ("size", "Size"), ("md5", "Md5"), - ("real_title", "RealTitle"), ("test_time", "TestTime")): + ("real_title", "RealTitle"), ("test_time", "TestTime"), + ("icon", "Icon"), ("charset", "Charset")): if hasattr(b, attr_name): self.outfile.write("\n%s: %s" % (attr_out, getattr(b, attr_name))) diff --git a/Writers/bkmk_whtml.py b/Writers/bkmk_whtml.py index eba9247..f2986fd 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-2004 PhiloSoft Design + Written by BroytMann. Copyright (C) 2000-2007 PhiloSoft Design """ @@ -35,8 +35,7 @@ class writer_html(Writer): def start_folder(self, f, level): self.outfile.write(ind_s*level + '

%s

\n' % f.name) self._folder(f, level) @@ -46,6 +45,8 @@ class writer_html(Writer): def bookmark(self, b, level): self.outfile.write(ind_s*(level+1) + '
%s\n' % b.name) if b.comment: self.outfile.write('
%s\n' % dump_comment(b.comment)) diff --git a/bkmk_objects.py b/bkmk_objects.py index fabf0ed..88abdf5 100644 --- a/bkmk_objects.py +++ b/bkmk_objects.py @@ -11,7 +11,7 @@ class Folder(UserList): isFolder = 1 isBookmark = 0 - def __init__(self, add_date = None, comment = '', last_modified=None): + def __init__(self, add_date=None, comment='', last_modified=None): UserList.__init__(self) self.comment = comment self.add_date = add_date @@ -43,13 +43,15 @@ class Bookmark: isBookmark = 1 def __init__(self, href, add_date, last_visit=None, last_modified=None, - keyword=None, comment = ''): - self.comment = comment + keyword=None, comment='', icon=None, charset=None): self.href = href self.add_date = add_date self.last_visit = last_visit self.last_modified = last_modified self.keyword = keyword + self.comment = comment + self.icon = icon + self.charset = charset class Ruler: diff --git a/bkmk_parser.py b/bkmk_parser.py old mode 100755 new mode 100644 index 02cce68..41df9ef --- a/bkmk_parser.py +++ b/bkmk_parser.py @@ -138,6 +138,8 @@ class BkmkParser(HTMLParser): last_visit = None last_modified = None keyword = None + icon = None + charset = None for attrname, value in attrs: value = value.strip() @@ -151,9 +153,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 diff --git a/doc/TODO b/doc/TODO index 3d1e7e6..c041a66 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,4 +1,4 @@ -Store icon, charset in bookmark's attributes. +Store icon and charset in bookmark's attributes. ICON="data:image/x-icon;base64,AAABAAIAEBAQAAAAAAAoAQAAJgAAACAgEAAAAAAA6AIAAE4BAAAoAAAAEAAAACAAAAABAAQAAAAAAMAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAACZAJmZAAAAAAmQCZAAAAAACZAJkAAAAAAJkAmQAAAAAAmQCZAAAAAACZAJkAAAAAAAmZmQAAAAAACZmZAAAAAACZAJkAAAAAAJkAmQAAAAAAmQCZAAAAAACZAJkAAAAAAJkAmQAAAAAACZmZkAAAAAAAAAAAAA//////MP///5n///+Z////mf///5n///+Z////wf///8H///+Z////mf///5n///+Z////mf///8D////////ygAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAmZkAAJmZmZkAAAAAAAAAAJmZkACZmZmZAAAAAAAAAAAAmZkAAJmZAAAAAAAAAAAAAJmZAACZmQAAAAAAAAAAAACZmQAAmZkAAAAAAAAAAAAAmZkAAJmZAAAAAAAAAAAAAJmZAACZmQAAAAAAAAAAAACZmQAAmZkAAAAAAAAAAAAAmZkAAJmZAAAAAAAAAAAAAJmZAACZmQAAAAAAAAAAAACZmQAAmZkAAAAAAAAAAAAACZmQAJmZAAAAAAAAAAAAAAmZmZmZmQAAAAAAAAAAAAAAmZmZmZkAAAAAAAAAAAAAAJmZmZmZAAAAAAAAAAAAAAmZmZmZmQAAAAAAAAAAAAAJmZAAmZkAAAAAAAAAAAAAmZkAAJmZAAAAAAAAAAAAAJmZAACZmQAAAAAAAAAAAACZmQAAmZkAAAAAAAAAAAAAmZkAAJmZAAAAAAAAAAAAAJmZAACZmQAAAAAAAAAAAACZmQAAmZkAAAAAAAAAAAAAmZkAAJmZAAAAAAAAAAAAAJmZAACZmQAAAAAAAAAAAAAJmZAAmZkAAAAAAAAAAAAACZmZmZmZmQAAAAAAAAAAAACZmZmZmZkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8PAP//BwD//8PD///Dw///w8P//8PD///Dw///w8P//8PD///Dw///w8P//+HD///gA///8AP///AD///gA///4cP//8PD///Dw///w8P//8PD///Dw///w8P//8PD///Dw///4cP//+AA///wAP///////////w==" LAST_CHARSET="windows-1251" -- 2.39.5