]> git.phdru.name Git - bookmarks_db.git/blobdiff - convert_st.py
Version 3.3.1.
[bookmarks_db.git] / convert_st.py
diff --git a/convert_st.py b/convert_st.py
new file mode 100755 (executable)
index 0000000..bba98e9
--- /dev/null
@@ -0,0 +1,55 @@
+#! /usr/local/bin/python -O
+"""
+   Convert a bkmk database to a different storage.
+
+   Written by BroytMann, Apr 2000 - Aug 2002. Copyright (C) 2000-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 len(args) <> 1:
+      sys.stderr.write("convert_st: too many or too few arguments\n")
+      sys.stderr.write("Usage: convert_st [-s] new_storage\n")
+      sys.exit(1)
+
+   from storage import storage, import_storage
+   storage = storage()
+
+   new_storage = import_storage(args[0])
+   new_storage = new_storage()
+
+   if report_stats:
+      sys.stdout.write("Loading %s: " % storage.filename)
+      sys.stdout.flush()
+
+   root_folder = storage.load()
+
+   if report_stats:
+      print "Ok"
+      sys.stdout.write("Converting to %s: " % new_storage.filename)
+      sys.stdout.flush()
+
+   new_storage.store(root_folder)
+
+   if report_stats:
+      print "Ok"
+
+
+if __name__ == '__main__':
+   run()