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