2 This allows the user to create a file "timestamps" in their datadir,
3 that will override the timestamp of any given blog entry. Each line
4 in this file should be of the form "YYYY-MM-DD-hh-mm file-name".
5 Then for any entry that one of these lines exist the system will use
6 that timestamp instead of the actual files modification time.
8 Note: the filename is relative to your data-dir.
9 Example of a line for the file /var/data-dir/school/abc.txt
10 where the datadir is "/var/data-dir/" and the date is Aug 9, 2004.
12 2004-08-09-00-00 school/abc.txt
14 Hacked on by Michael Olson <http://www.mwolson.org/>.
16 __author__
= 'Nathan Kent Bullock'
17 __homepage__
= 'http://bullock.moo.com/nathan/'
18 __email__
= 'nathan_kent_bullock -at- yahoo.ca'
21 from Pyblosxom
import tools
22 import os
, re
, time
, sys
24 FILETIME
= re
.compile('^([0-9]{4})-([0-1][0-9])-([0-3][0-9])(-([0-2][0-9])-([0-5][0-9]))? +(.*)$')
28 def get_all_timestamps(datadir
):
29 f
= open(datadir
+ "/timestamps")
34 m
= FILETIME
.search(str.strip())
36 year
= int(m
.group(1))
41 minute
= int(m
.group(6))
45 mtime
= time
.mktime((year
,mo
,day
,hr
,minute
,0,0,0,-1))
47 t
.append( (datadir
+ "/" + m
.group(7) + ".txt", mtime
) )
52 def cb_filestat(args
):
55 filename
= args
["filename"]
56 stattuple
= args
["mtime"]
58 for fname
,mtime
in all_timestamps
:
60 args
["mtime"] = tuple(list(stattuple
[:8]) + [mtime
] + list(stattuple
[9:]))
67 all_timestamps
= get_all_timestamps(args
["request"].getConfiguration()['datadir'])