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-2017 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) 2003-2017 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)
55 for object_no in range(objects):
56 object = root_folder.linear[object_no]
59 if not hasattr(object, "real_title"):
62 real_title = object.real_title
64 real_title = object.href
65 if object.name != real_title:
66 object.name = real_title
70 if changed and report_stats:
71 sys.stdout.write("Saving %s: " % storage.filename)
74 if not changed and report_stats:
75 sys.stdout.write("No need to save data\n")
79 storage.store(root_folder)
81 if changed and report_stats:
83 print(objects, "objects passed")
84 print(changed, "objects changed")
87 if __name__ == '__main__':