This file is a part of Bookmarks database and Internet robot.
"""
-__version__ = "$Revision$"[11:-2]
-__revision__ = "$Id$"[5:-2]
-__date__ = "$Date$"[7:-2]
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2000-2023 PhiloSoft Design"
__license__ = "GNU GPL"
__all__ = ['writer_flad']
import time
from bkmk_objects import Writer
+from compat import unicode
def strftime(s):
- try:
- return time.strftime("%a %d %b %Y %T", time.localtime(int(s)))
- except (TypeError, ValueError): # s is None or is already formatted
- return s
+ try:
+ return time.strftime("%a %d %b %Y %T", time.localtime(int(s)))
+ except (TypeError, ValueError): # s is None or is already formatted
+ return s
class writer_flad(Writer):
- filename = "bookmarks_db.flad"
+ filename = "bookmarks_db.flad"
- def __init__(self, outfile, prune=None):
- Writer.__init__(self, outfile, prune)
- self.first_object = 1
+ def __init__(self, outfile, prune=None):
+ Writer.__init__(self, outfile, prune)
+ self.first_object = 1
- def start_folder(self, f, level):
- self.outfile.write("""
+ def start_folder(self, f, level):
+ self.outfile.write("""
Level: %d
Folder: %s
AddDate: %s
Comment: %s
LastModified: %s
-""" % (level, f.name, strftime(f.add_date), f.comment, f.last_modified or ''))
+""" % (
+ level, f.name, strftime(f.add_date), f.comment,
+ strftime(f.last_modified))
+ )
- def bookmark(self, b, level):
- self.outfile.write("""
+ def bookmark(self, b, level):
+ self.outfile.write("""
Level: %d
Title: %s
URL: %s
LastVisit: %s
LastModified: %s
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"),
+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"),
("real_title", "RealTitle"), ("test_time", "TestTime"),
- ("icon_href", "IconURI"), ("icon", "Icon"), ("charset", "Charset")):
- if hasattr(b, attr_name):
- self.outfile.write("\n%s: %s" % (attr_out, getattr(b, attr_name)))
+ ("icon_href", "IconURI"), ("icon", "Icon"), ("charset", "Charset"),
+ ):
+ if hasattr(b, attr_name):
+ value = getattr(b, attr_name)
+ #if isinstance(value, unicode):
+ # value = value.encode('utf-8')
+ self.outfile.write("\n%s: %s" % (attr_out, value))
- if hasattr(b, "last_tested"):
- self.outfile.write("\n%s: %s" % ("LastTested", strftime(getattr(b, "last_tested"))))
+ if hasattr(b, "last_tested"):
+ self.outfile.write("\nLastTested: %s" % strftime(b.last_tested))
- self.outfile.write("\n")
+ self.outfile.write("\n")
- def ruler(self, r, level):
- self.outfile.write("\nLevel: %s\nRuler: YES\n" % (level+1))
+ def ruler(self, r, level):
+ self.outfile.write("\nLevel: %s\nRuler: YES\n" % (level+1))