X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=print_all.py;h=e03ac4e132e1725c3c4346e7144c7c5f09339824;hb=72abad5af9e89331952a64578b8f24c146a6e767;hp=64bc3f4fcd4e2cba5e3b483b9a7670e2277211d6;hpb=9f11c26113add5270ade4da28c7a2adb84194b1b;p=xsetbg.git diff --git a/print_all.py b/print_all.py index 64bc3f4..e03ac4e 100755 --- a/print_all.py +++ b/print_all.py @@ -6,19 +6,15 @@ This file is a part of XSetBg. """ __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2006-2012 PhiloSoft Design" +__copyright__ = "Copyright (C) 2006-2015 PhiloSoft Design" __license__ = "GNU GPL" -import os, shelve -from operator import itemgetter +import sys +from m_lib.defenc import default_encoding +from xsetbg_db import xsetbg_db -xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg") -os.chdir(xsetbg_dir) +if not xsetbg_db: + sys.exit("Error: no database found") -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 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)