X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=dump_db.py;h=470ff0a06c9120de7ad72667ac0bc18017ba9a22;hb=080d6169f03836330b355e5304e51122d7956c11;hp=9c4954d31370826356bb8b72d0a37b800d659caa;hpb=9f11c26113add5270ade4da28c7a2adb84194b1b;p=xsetbg.git diff --git a/dump_db.py b/dump_db.py index 9c4954d..470ff0a 100755 --- a/dump_db.py +++ b/dump_db.py @@ -1,24 +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-2012 PhiloSoft Design" -__license__ = "GNU GPL" +import sys +from m_lib.defenc import default_encoding +from xsetbg_db import xsetbg_db -import os, shelve -from operator import itemgetter +if not xsetbg_db: + sys.exit("Error: no database found") -xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg") -os.chdir(xsetbg_dir) - -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 value, key -global_db.close() +for row in xsetbg_db.select(orderBy='-last_shown'): + print(row.id, row.last_shown, row.full_name.encode(default_encoding))