X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=dump_db.py;h=ca3c6a74be70213190721f1940f564607e9eb79a;hb=d1e8443a665d4f5f23db32f5ee47d415a5424a04;hp=5cfe6c84076c6d6ba22c5d3a06e5fb4f2f646f42;hpb=8b74c08eda8ee4d62db000571a6df4ec4d59186a;p=xsetbg.git diff --git a/dump_db.py b/dump_db.py index 5cfe6c8..ca3c6a7 100755 --- a/dump_db.py +++ b/dump_db.py @@ -1,28 +1,20 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Dump the DB sorted by date This file is a part of XSetBg. """ -__version__ = "$Revision: 17 $"[11:-2] -__revision__ = "$Id: print_all.py 17 2007-06-14 10:37:08Z phd $"[5:-2] -__date__ = "$Date: 2007-06-14 14:37:08 +0400 (Thu, 14 Jun 2007) $"[7:-2] +import sys +from xsetbg_conf import xsetbg_conf +from xsetbg_db import xsetbg_db -__author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2006-2010 PhiloSoft Design" -__license__ = "GNU GPL" +if not xsetbg_db: + sys.exit("Error: no database found") -import os, shelve -from operator import itemgetter - -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() +fs_encoding = xsetbg_conf.get("images", "fs_encoding") +for row in xsetbg_db.select(orderBy='-last_shown'): + sys.stdout.buffer.write( + ('%d %s %s\n' % (row.id, row.last_shown, row.full_name + )).encode(fs_encoding) + )