1 """Dump bookmarks db to a more readable FLat Ascii Database
3 This file is a part of Bookmarks database and Internet robot.
6 __author__ = "Oleg Broytman <phd@phdru.name>"
7 __copyright__ = "Copyright (C) 2000-2023 PhiloSoft Design"
8 __license__ = "GNU GPL"
10 __all__ = ['writer_flad']
14 from bkmk_objects import Writer
15 from compat import unicode
20 return time.strftime("%a %d %b %Y %T", time.localtime(int(s)))
21 except (TypeError, ValueError): # s is None or is already formatted
25 class writer_flad(Writer):
26 filename = "bookmarks_db.flad"
28 def __init__(self, outfile, prune=None):
29 Writer.__init__(self, outfile, prune)
32 def start_folder(self, f, level):
33 self.outfile.write("""
40 level, f.name, strftime(f.add_date), f.comment,
41 strftime(f.last_modified))
44 def bookmark(self, b, level):
45 self.outfile.write("""
54 level+1, b.name, b.href, strftime(b.add_date),
55 strftime(b.last_visit), strftime(b.last_modified),
59 for attr_name, attr_out in (
60 ("error", "Error"), ("no_error", "NoError"),
61 ("moved", "Moved"), ("size", "Size"), ("md5", "Md5"),
62 ("real_title", "RealTitle"), ("test_time", "TestTime"),
63 ("icon_href", "IconURI"), ("icon", "Icon"), ("charset", "Charset"),
65 if hasattr(b, attr_name):
66 value = getattr(b, attr_name)
67 #if isinstance(value, unicode):
68 # value = value.encode('utf-8')
69 self.outfile.write("\n%s: %s" % (attr_out, value))
71 if hasattr(b, "last_tested"):
72 self.outfile.write("\nLastTested: %s" % strftime(b.last_tested))
74 self.outfile.write("\n")
76 def ruler(self, r, level):
77 self.outfile.write("\nLevel: %s\nRuler: YES\n" % (level+1))