2 """Run through the bookmarks database and set name to real title
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) 2002-2023 PhiloSoft Design"
13 __license__ = "GNU GPL"
17 from getopt import getopt
18 optlist, args = getopt(sys.argv[1:], "s")
22 for _opt, _arg in optlist:
31 print("Broytman set-real_title, Copyright (C)"
32 " 2003-2023 PhiloSoft Design")
34 sys.stderr.write("set-real_title: too many arguments\n")
35 sys.stderr.write("Usage: set-real_title [-s]\n")
38 from storage import storage
42 sys.stdout.write("Loading %s: " % storage.filename)
45 root_folder = storage.load()
46 from bkmk_objects import make_linear
47 make_linear(root_folder)
48 objects = len(root_folder.linear)
54 for object_no in range(objects):
55 object = root_folder.linear[object_no]
58 if not hasattr(object, "real_title"):
61 real_title = object.real_title
63 real_title = object.href
64 if object.name != real_title:
65 object.name = real_title
68 if changed and report_stats:
69 sys.stdout.write("Saving %s: " % storage.filename)
72 if not changed and report_stats:
73 sys.stdout.write("No need to save data\n")
77 storage.store(root_folder)
79 if changed and report_stats:
81 print(objects, "objects passed")
82 print(changed, "objects changed")
85 if __name__ == '__main__':