]> git.phdru.name Git - xsetbg.git/blobdiff - dump_db.py
Convert print_all.py
[xsetbg.git] / dump_db.py
index 5cfe6c84076c6d6ba22c5d3a06e5fb4f2f646f42..2bdffedf9972887873326bbf132c573347a40770 100755 (executable)
@@ -5,24 +5,16 @@ 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 Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2006-2010 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2006-2015 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)
+import sys
+from m_lib.defenc import default_encoding
+from xsetbg_db import xsetbg_db
 
-global_db_name = "xsetbg.db"
+if not xsetbg_db:
+    sys.exit("Error: no database found")
 
-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()
+for row in xsetbg_db.select(orderBy='-last_shown'):
+    print row.id, row.last_shown, row.full_name.encode(default_encoding)