1 #! /usr/bin/env python3
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-2023 PhiloSoft Design"
13 __license__ = "GNU GPL"
19 def report_dup(href, object_no):
20 s = "Duplicate URL: %s (first at rec. %d)" % (href, object_no)
23 log_file.write("%s\n" % s)
29 from getopt import getopt
30 optlist, args = getopt(sys.argv[1:], "sl:")
36 for _opt, _arg in optlist:
47 print("Broytman check_dups, Copyright (C) 2000-2023 PhiloSoft Design")
50 sys.stderr.write("check_urls: too many arguments\n")
51 sys.stderr.write("Usage: check_urls [-s] [-l logfile]\n")
55 log_file = open(log_filename, 'wt')
57 from storage import storage
61 sys.stdout.write("Loading %s: " % storage.filename)
64 root_folder = storage.load()
65 from bkmk_objects import make_linear
66 make_linear(root_folder)
67 objects = len(root_folder.linear)
74 for object_no in range(objects):
75 object = root_folder.linear[object_no]
80 report_dup(href, dup_dict[href])
82 dup_dict[href] = object_no
89 print(objects, "objects passed")
92 if __name__ == '__main__':