]> git.phdru.name Git - xsetbg.git/commitdiff
Dump and reload database.
authorOleg Broytman <phd@phdru.name>
Thu, 14 Jun 2007 13:23:02 +0000 (13:23 +0000)
committerOleg Broytman <phd@phdru.name>
Thu, 14 Jun 2007 13:23:02 +0000 (13:23 +0000)
git-svn-id: file:///home/phd/archive/SVN/xsetbg/trunk@20 143022c7-580b-0410-bae3-87f2bf5d3141

dump_db.py [new file with mode: 0755]
reload_db.py [new file with mode: 0755]

diff --git a/dump_db.py b/dump_db.py
new file mode 100755 (executable)
index 0000000..fd0d2a7
--- /dev/null
@@ -0,0 +1,28 @@
+#! /usr/bin/env python
+"""Dump the DB sorted by date
+
+This file is a part of XSetBg.
+
+"""
+
+__version__ = "$Revision: 17 $"[11:-2]
+__revision__ = "$Id: print_all.py 17 2007-06-14 10:37:08Z phd $"[5:-2]
+__date__ = "$Date: 2007-06-14 14:37:08 +0400 (Thu, 14 Jun 2007) $"[7:-2]
+
+__author__ = "Oleg BroytMann <phd@phd.pp.ru>"
+__copyright__ = "Copyright (C) 2006, 2007 PhiloSoft Design"
+__license__ = "GNU GPL"
+
+import os, shelve
+from operator import itemgetter
+
+xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
+os.chdir(xsetbg_dir)
+
+global_db_name = "xsetbg.db"
+
+global_db = shelve.open(global_db_name, flag='r')
+for key, value in sorted(global_db.items(), key=itemgetter(1), reverse=1):
+   if key.startswith('/'):
+      print value, key
+global_db.close()
diff --git a/reload_db.py b/reload_db.py
new file mode 100755 (executable)
index 0000000..4c38208
--- /dev/null
@@ -0,0 +1,29 @@
+#! /usr/bin/env python
+"""Reload a dump into DB
+
+This file is a part of XSetBg.
+
+"""
+
+__version__ = "$Revision: 17 $"[11:-2]
+__revision__ = "$Id: print_all.py 17 2007-06-14 10:37:08Z phd $"[5:-2]
+__date__ = "$Date: 2007-06-14 14:37:08 +0400 (Thu, 14 Jun 2007) $"[7:-2]
+
+__author__ = "Oleg BroytMann <phd@phd.pp.ru>"
+__copyright__ = "Copyright (C) 2007 PhiloSoft Design"
+__license__ = "GNU GPL"
+
+import sys, os, shelve
+
+xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
+os.chdir(xsetbg_dir)
+
+global_db_name = "xsetbg.db"
+dump_file = open(sys.argv[1], 'rU')
+
+global_db = shelve.open(global_db_name, flag='n')
+for line in dump_file:
+   timestamp, filename = line.strip().split(None, 1)
+   global_db[filename] = float(timestamp)
+global_db.close()
+dump_file.close()