X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=dump_db.py;h=470ff0a06c9120de7ad72667ac0bc18017ba9a22;hb=080d6169f03836330b355e5304e51122d7956c11;hp=8c80932bb70172da338ae15a8f256c09e9cc3c15;hpb=76c9a423c497a1b7c2831087e02e6d8dbda5cb58;p=xsetbg.git diff --git a/dump_db.py b/dump_db.py index 8c80932..470ff0a 100755 --- a/dump_db.py +++ b/dump_db.py @@ -1,18 +1,16 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Dump the DB sorted by date This file is a part of XSetBg. """ -__author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2006-2014 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))