From d9f2f4316537aea2cf87b2f77bf7d78eb54978a4 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 11 Aug 2010 20:08:41 +0000 Subject: [PATCH] Store icon's URIs. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@264 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- Robots/bkmk_rforking.py | 3 ++- Robots/bkmk_rsimple.py | 6 ++++-- Storage/bkmk_stflad.py | 6 ++++-- Writers/bkmk_whtml.py | 3 ++- bkmk_objects.py | 3 ++- check_url.py | 3 ++- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Robots/bkmk_rforking.py b/Robots/bkmk_rforking.py index 4c4c098..f0e9354 100644 --- a/Robots/bkmk_rforking.py +++ b/Robots/bkmk_rforking.py @@ -55,7 +55,8 @@ class robot_forking(Robot): new_b = pickle.loads(subp_pipe.read_record()) for attr in ("error", "no_error", "moved", "size", "md5", "real_title", - "last_tested", "last_modified", "test_time", "icon"): + "last_tested", "last_modified", "test_time", + "icon", "icon_href"): if hasattr(new_b, attr): setattr(bookmark, attr, getattr(new_b, attr)) else: diff --git a/Robots/bkmk_rsimple.py b/Robots/bkmk_rsimple.py index 42975d2..ba30294 100644 --- a/Robots/bkmk_rsimple.py +++ b/Robots/bkmk_rsimple.py @@ -202,6 +202,7 @@ class robot_simple(Robot): self.log(" looking for icon at: %s" % icon) if icon in icons: if icons[icon]: + bookmark.icon_href = icon content_type, bookmark.icon = icons[icon] self.log(" cached icon: %s" % content_type) else: @@ -230,9 +231,10 @@ class robot_simple(Robot): content_type = headers["Content-Type"] if content_type.startswith("image/"): icon_file = open(fname, "rb") - icon = icon_file.read() + icon_data = icon_file.read() icon_file.close() - bookmark.icon = "data:%s;base64,%s" % (content_type, b64encode(icon)) + bookmark.icon_href = icon + bookmark.icon = "data:%s;base64,%s" % (content_type, b64encode(icon_data)) self.log(" got icon : %s" % content_type) icons[icon] = (content_type, bookmark.icon) else: diff --git a/Storage/bkmk_stflad.py b/Storage/bkmk_stflad.py index 6611d97..9bd8751 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 Broytman, Feb 2000 - Sep 2007. Copyright (C) 2000-2007 PhiloSoft Design + Written by Broytman. Copyright (C) 2000-2010 PhiloSoft Design """ @@ -45,10 +45,12 @@ LastVisit: %s LastModified: %s Keyword: %s Comment: %s +IconURI: %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.icon or '', b.charset or '')) + b.keyword, b.comment.replace('\n', "\\n"), + b.icon_href or '', b.icon or '', b.charset or '')) def ruler(self, r, level): diff --git a/Writers/bkmk_whtml.py b/Writers/bkmk_whtml.py index 3597060..b4c4dab 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 Broytman. Copyright (C) 2000-2007 PhiloSoft Design + Written by Broytman. Copyright (C) 2000-2010 PhiloSoft Design """ from bkmk_objects import Writer, BKMK_FORMAT, quote_title @@ -42,6 +42,7 @@ class writer_html(Writer): self.outfile.write(ind_s*(level+1) + '
%s\n' % quote_title(b.name)) diff --git a/bkmk_objects.py b/bkmk_objects.py index 121f908..a9567e2 100644 --- a/bkmk_objects.py +++ b/bkmk_objects.py @@ -44,13 +44,14 @@ class Bookmark: isBookmark = 1 def __init__(self, href, add_date, last_visit=None, last_modified=None, - keyword=None, comment='', icon=None, charset=None): + keyword=None, comment='', icon_href=None, 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_href = icon_href self.icon = icon self.charset = charset diff --git a/check_url.py b/check_url.py index ebf9a20..123f6a9 100755 --- a/check_url.py +++ b/check_url.py @@ -51,8 +51,9 @@ def run(): URL: %s Title: %s LastModified: %s +IconURI: %s Icon: %s -""" % (bookmark.href, getattr(bookmark, 'real_title', ''), strftime(bookmark.last_modified), bookmark.icon) +""" % (bookmark.href, getattr(bookmark, 'real_title', ''), strftime(bookmark.last_modified), bookmark.icon_href, bookmark.icon) robot.stop() log.close() -- 2.39.5