X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=print_all.py;h=e03ac4e132e1725c3c4346e7144c7c5f09339824;hb=688d1400d0e05a4ff2f10db88e89f149f39fee4e;hp=19d5a942760a079216288b731198a450ce550542;hpb=8038c52473c74084974d2fa6116bacf8bbee774e;p=xsetbg.git diff --git a/print_all.py b/print_all.py index 19d5a94..e03ac4e 100755 --- a/print_all.py +++ b/print_all.py @@ -1,28 +1,20 @@ -#! /usr/local/bin/python -O +#! /usr/bin/env python """Print shown files sorted by date This file is a part of XSetBg. """ -__version__ = "$Revision$"[11:-2] -__revision__ = "$Id$"[5:-2] -__date__ = "$Date$"[7:-2] - -__author__ = "Oleg BroytMann " -__copyright__ = "Copyright (C) 2006 PhiloSoft Design" +__author__ = "Oleg Broytman " +__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)