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
"""
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):
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)
"""
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
"""
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"),
"""
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
"""
self.outfile.write(ind_s*level + "</DL><p>\n")
def bookmark(self, b, level):
- self.outfile.write(ind_s*(level+1) + '<DT><A HREF="%s" ADD_DATE="%s" LAST_VISIT="%s" LAST_MODIFIED="%s">%s</A>\n' % (b.href, b.add_date, b.last_visit, b.last_modified, b.name))
+ self.outfile.write(ind_s*(level+1) + '<DT><A HREF="%s" ADD_DATE="%s" LAST_VISIT="%s" LAST_MODIFIED="%s"' % (b.href, b.add_date, b.last_visit, b.last_modified))
+ if b.keyword: self.outfile.write(' SHORTCUTURL="%s"' % b.keyword)
+ self.outfile.write('>%s</A>\n' % b.name)
if b.comment: self.outfile.write('<DD>%s\n' % dump_comment(b.comment))
def ruler(self, r, level):
"""
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
"""
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:
"""
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
"""
self.root_folder.name = accumulator
- # Start next folder
+ # Start a folder
def start_h3(self, attrs):
for attrname, value in attrs:
value = value.strip()
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
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
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