2 """Check duplicate URLs in the bookmarks database
4 This file is a part of Bookmarks database and Internet robot.
7 __author__ = "Oleg Broytman <phd@phdru.name>"
8 __copyright__ = "Copyright (C) 2000-2012 PhiloSoft Design"
9 __license__ = "GNU GPL"
16 def report_dup(href, object_no):
17 s = "Duplicate URL: %s (first at rec. %d)" % (href, object_no)
20 log_file.write("%s\n" % s)
26 from getopt import getopt
27 optlist, args = getopt(sys.argv[1:], "sl:")
33 for _opt, _arg in optlist:
44 print "Broytman check_dups, Copyright (C) 2000-2007 PhiloSoft Design"
47 sys.stderr.write("check_urls: too many arguments\n")
48 sys.stderr.write("Usage: check_urls [-s] [-l logfile]\n")
52 log_file = open(log_filename, 'w')
54 from storage import storage
58 sys.stdout.write("Loading %s: " % storage.filename)
61 root_folder = storage.load()
62 from bkmk_objects import make_linear
63 make_linear(root_folder)
64 objects = len(root_folder.linear)
72 for object_no in range(objects):
73 object = root_folder.linear[object_no]
77 if dup_dict.has_key(href):
78 report_dup(href, dup_dict[href])
80 dup_dict[href] = object_no
88 print objects, "objects passed"
91 if __name__ == '__main__':