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 in one of the following forms.
9 "YYYY-MM-DD-hh-mm file-name"
10 "YYYY-MM-DD file-name"
12 Then for any entry that one of these lines exist the system will use
13 that timestamp instead of the actual files modification time.
15 Note: the filename is relative to your data-dir. An example follows
16 of a line for the file /var/data-dir/school/abc.txt, where the
17 top-level blog entries directory is "/var/data-dir/" and the date is
20 2004-08-09-00-00 school/abc.txt
26 * Michael Olson <http://www.mwolson.org/> made it optional to include
27 the hours and minutes.
33 __author__
= 'Nathan Kent Bullock'
34 __homepage__
= 'http://bullock.moo.com/nathan/'
35 __email__
= 'nathan_kent_bullock -at- yahoo.ca'
38 from Pyblosxom
import tools
39 import os
, re
, time
, sys
41 FILETIME
= re
.compile('^([0-9]{4})-([0-1][0-9])-([0-3][0-9])(-([0-2][0-9])-([0-5][0-9]))? +(.*)$')
45 def get_all_timestamps(datadir
):
46 f
= open(datadir
+ "/timestamps")
51 m
= FILETIME
.search(str.strip())
53 year
= int(m
.group(1))
58 minute
= int(m
.group(6))
62 mtime
= time
.mktime((year
,mo
,day
,hr
,minute
,0,0,0,-1))
64 t
.append( (datadir
+ "/" + m
.group(7), mtime
) )
69 def cb_filestat(args
):
72 filename
= args
["filename"]
73 stattuple
= args
["mtime"]
75 for fname
,mtime
in all_timestamps
:
77 args
["mtime"] = tuple(list(stattuple
[:8]) + [mtime
] + list(stattuple
[9:]))
84 all_timestamps
= get_all_timestamps(args
["request"].getConfiguration()['datadir'])