2 """Check duplicate URLs in the bookmarks database
4 This file is a part of Bookmarks database and Internet robot.
7 from __future__ import print_function
11 __author__ = "Oleg Broytman <phd@phdru.name>"
12 __copyright__ = "Copyright (C) 2000-2017 PhiloSoft Design"
13 __license__ = "GNU GPL"
18 def report_dup(href, object_no):
19 s = "Duplicate URL: %s (first at rec. %d)" % (href, object_no)
22 log_file.write("%s\n" % s)
28 from getopt import getopt
29 optlist, args = getopt(sys.argv[1:], "sl:")
35 for _opt, _arg in optlist:
46 print("Broytman check_dups, Copyright (C) 2000-2017 PhiloSoft Design")
49 sys.stderr.write("check_urls: too many arguments\n")
50 sys.stderr.write("Usage: check_urls [-s] [-l logfile]\n")
54 log_file = open(log_filename, 'w')
56 from storage import storage
60 sys.stdout.write("Loading %s: " % storage.filename)
63 root_folder = storage.load()
64 from bkmk_objects import make_linear
65 make_linear(root_folder)
66 objects = len(root_folder.linear)
74 for object_no in range(objects):
75 object = root_folder.linear[object_no]
79 if dup_dict.has_key(href):
80 report_dup(href, dup_dict[href])
82 dup_dict[href] = object_no
90 print(objects, "objects passed")
93 if __name__ == '__main__':