]> git.phdru.name Git - bookmarks_db.git/blobdiff - check_title.py
Version 3.3.1.
[bookmarks_db.git] / check_title.py
diff --git a/check_title.py b/check_title.py
new file mode 100755 (executable)
index 0000000..950c6e2
--- /dev/null
@@ -0,0 +1,75 @@
+#! /usr/local/bin/python -O
+"""
+   Check and show URLs in the bookmarks database where name <> real title
+
+   Written by BroytMann, Jul 2002 - Aug 2002. Copyright (C) 2002 PhiloSoft Design
+"""
+
+
+import sys
+
+
+def run():
+   from getopt import getopt
+   optlist, args = getopt(sys.argv[1:], "s")
+
+   report_stats = 1
+
+   for _opt, _arg in optlist:
+      if _opt == '-s':
+         report_stats = 0
+   try:
+      del _opt, _arg
+   except NameError:
+      pass
+
+   if report_stats:
+      print "BroytMann check_title, Copyright (C) 2002 PhiloSoft Design"
+
+   if args:
+      sys.stderr.write("check_title: too many arguments\n")
+      sys.stderr.write("Usage: check_title [-s]\n")
+      sys.exit(1)
+
+   from storage import storage
+   storage = storage()
+
+   if report_stats:
+      sys.stdout.write("Loading %s: " % storage.filename)
+      sys.stdout.flush()
+
+   root_folder = storage.load()
+   from bkmk_objects import make_linear
+   make_linear(root_folder)
+   objects = len(root_folder.linear)
+
+   if report_stats:
+      print "Ok"
+
+
+   for object_no in range(objects):
+      object = root_folder.linear[object_no]
+
+      if object.isBookmark:
+         if hasattr(object, "moved") or hasattr(object, "error"):
+            continue
+
+         if hasattr(object, "real_title"):
+            if object.name <> object.real_title:
+               print object.href
+               print object.name
+               print object.real_title
+               print
+         else:
+            print object.href
+            print object.name
+            print "NO REAL TITLE!!!"
+            print
+
+
+   if report_stats:
+      print objects, "objects passed"
+
+
+if __name__ == '__main__':
+   run()