]> git.phdru.name Git - xsetbg.git/blobdiff - dump_db.py
Convert dump_db.py and reload_db.py to use SQLObject
[xsetbg.git] / dump_db.py
index 8c80932bb70172da338ae15a8f256c09e9cc3c15..2bdffedf9972887873326bbf132c573347a40770 100755 (executable)
@@ -6,13 +6,15 @@ This file is a part of XSetBg.
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2006-2014 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2006-2015 PhiloSoft Design"
 __license__ = "GNU GPL"
 
-from operator import itemgetter
+import sys
+from m_lib.defenc import default_encoding
 from xsetbg_db import xsetbg_db
 
-for key, value in sorted(xsetbg_db.items(), key=itemgetter(1), reverse=1):
-   if key.startswith('/'):
-      print value, key
-xsetbg_db.close()
+if not xsetbg_db:
+    sys.exit("Error: no database found")
+
+for row in xsetbg_db.select(orderBy='-last_shown'):
+    print row.id, row.last_shown, row.full_name.encode(default_encoding)