]> git.phdru.name Git - xsetbg.git/blobdiff - print_all.py
Convert print_all.py
[xsetbg.git] / print_all.py
index 6b17026c6a96c8ba082ceb7aa2a7867b7a9c2f95..e03ac4e132e1725c3c4346e7144c7c5f09339824 100755 (executable)
@@ -5,24 +5,16 @@ This file is a part of XSetBg.
 
 """
 
-__version__ = "$Revision$"[11:-2]
-__revision__ = "$Id$"[5:-2]
-__date__ = "$Date$"[7:-2]
-
-__author__ = "Oleg Broytman <phd@phd.pp.ru>"
-__copyright__ = "Copyright (C) 2006 PhiloSoft Design"
+__author__ = "Oleg Broytman <phd@phdru.name>"
+__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 key
-global_db.close()
+for row in xsetbg_db.select('last_shown IS NOT NULL', orderBy='-last_shown'):
+    print row.full_name.encode(default_encoding)