]> git.phdru.name Git - bookmarks_db.git/blob - check_title.py
Version 3.3.1.
[bookmarks_db.git] / check_title.py
1 #! /usr/local/bin/python -O
2 """
3    Check and show URLs in the bookmarks database where name <> real title
4
5    Written by BroytMann, Jul 2002 - Aug 2002. Copyright (C) 2002 PhiloSoft Design
6 """
7
8
9 import sys
10
11
12 def run():
13    from getopt import getopt
14    optlist, args = getopt(sys.argv[1:], "s")
15
16    report_stats = 1
17
18    for _opt, _arg in optlist:
19       if _opt == '-s':
20          report_stats = 0
21    try:
22       del _opt, _arg
23    except NameError:
24       pass
25
26    if report_stats:
27       print "BroytMann check_title, Copyright (C) 2002 PhiloSoft Design"
28
29    if args:
30       sys.stderr.write("check_title: too many arguments\n")
31       sys.stderr.write("Usage: check_title [-s]\n")
32       sys.exit(1)
33
34    from storage import storage
35    storage = storage()
36
37    if report_stats:
38       sys.stdout.write("Loading %s: " % storage.filename)
39       sys.stdout.flush()
40
41    root_folder = storage.load()
42    from bkmk_objects import make_linear
43    make_linear(root_folder)
44    objects = len(root_folder.linear)
45
46    if report_stats:
47       print "Ok"
48
49
50    for object_no in range(objects):
51       object = root_folder.linear[object_no]
52
53       if object.isBookmark:
54          if hasattr(object, "moved") or hasattr(object, "error"):
55             continue
56
57          if hasattr(object, "real_title"):
58             if object.name <> object.real_title:
59                print object.href
60                print object.name
61                print object.real_title
62                print
63          else:
64             print object.href
65             print object.name
66             print "NO REAL TITLE!!!"
67             print
68
69
70    if report_stats:
71       print objects, "objects passed"
72
73
74 if __name__ == '__main__':
75    run()