]> git.phdru.name Git - xsetbg.git/blob - find_oldest.py
Version 4.0.0
[xsetbg.git] / find_oldest.py
1 #! /usr/bin/env python
2 """Count shown files; display the date of oldest file
3
4 This file is a part of XSetBg.
5
6 """
7
8 __author__ = "Oleg Broytman <phd@phdru.name>"
9 __copyright__ = "Copyright (C) 2006-2012 PhiloSoft Design"
10 __license__ = "GNU GPL"
11
12 import os, shelve
13 from time import localtime, asctime
14
15 xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
16 os.chdir(xsetbg_dir)
17
18 global_db_name = "xsetbg.db"
19
20 count = 0
21 oldest = None
22
23 global_db = shelve.open(global_db_name, flag='r')
24 for key in global_db.keys():
25    count += 1
26    if key.startswith('/') and ((oldest is None) or (global_db[key] < oldest)):
27       oldest = global_db[key]
28 global_db.close()
29
30 print count, "files"
31 print "Oldest:", asctime(localtime(oldest))