From: Oleg Broytman Date: Thu, 19 Oct 2006 18:57:07 +0000 (+0000) Subject: Count shown files; display the date of oldest file. X-Git-Tag: v4.0.0~53 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=c4015ab84f9ceae1eb814fd3ea4cda580af48771;p=xsetbg.git Count shown files; display the date of oldest file. git-svn-id: file:///home/phd/archive/SVN/xsetbg/trunk@15 143022c7-580b-0410-bae3-87f2bf5d3141 --- diff --git a/find_oldest.py b/find_oldest.py new file mode 100755 index 0000000..df79432 --- /dev/null +++ b/find_oldest.py @@ -0,0 +1,35 @@ +#! /usr/local/bin/python -O +"""Count shown files; display the date of oldest file + +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" +__license__ = "GNU GPL" + +import os, shelve +from time import localtime, asctime + +xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg") +os.chdir(xsetbg_dir) + +global_db_name = "xsetbg.db" + +count = 0 +oldest = None + +global_db = shelve.open(global_db_name, flag='r') +for key in global_db.keys(): + count += 1 + if key.startswith('/') and ((oldest is None) or (global_db[key] < oldest)): + oldest = global_db[key] +global_db.close() + +print count, "files" +print "Oldest:", asctime(localtime(oldest))