-#! /usr/local/bin/python -O
-"""
- Sort bookmarks DB according to a rule:
+#! /usr/bin/env python
+"""Sort bookmarks DB according to a rule:
-a - by AddDate
-v - by LastVisit
-m - by LastModified
default is -m
-r - reverse the sort order
- Written by BroytMann, Apr 2000. Copyright (C) 2000 PhiloSoft Design
+This file is a part of Bookmarks database and Internet robot.
+
"""
+__author__ = "Oleg Broytman <phd@phdru.name>"
+__copyright__ = "Copyright (C) 2000-2017 PhiloSoft Design"
+__license__ = "GNU GPL"
import sys
-class SortBy:
+class SortBy(object):
def __init__(self, sort_by):
self.sort_by = sort_by
def __call__(self, o1, o2):
try:
attr1 = int(getattr(o1, self.sort_by))
- except (TypeError, AttributeError):
+ except (AttributeError, TypeError, ValueError):
return 1
try:
attr2 = int(getattr(o2, self.sort_by))
- except (TypeError, AttributeError):
+ except (AttributeError, TypeError, ValueError):
return -1
return cmp(attr1, attr2)
root_folder = storage.load()
if report_stats:
- print "Ok"
+ print("Ok")
sys.stdout.write("Sorting (by %s): " % sort_by)
sys.stdout.flush()
output_filename = output_filename + "-reverse"
if report_stats:
- print "done"
+ print("done")
sys.stdout.write("Writing %s: " % output_filename)
sys.stdout.flush()
outfile.close()
if report_stats:
- print "Ok"
+ print("Ok")
if __name__ == '__main__':