latex: Remove footnote references in headers
[muse-el.git] / contrib / pyblosxom / hardcodedates.py
blob18a151766d66cb065783c28a574fc1b3f3ae483e
1 """
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
5 blog entry.
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
18 Aug 9, 2004.
20 2004-08-09-00-00 school/abc.txt
22 History:
24 1.3
26 * Michael Olson <http://www.mwolson.org/> made it optional to include
27 the hours and minutes.
29 1.2
31 * Original version
32 """
33 __author__ = 'Nathan Kent Bullock'
34 __homepage__ = 'http://bullock.moo.com/nathan/'
35 __email__ = 'nathan_kent_bullock -at- yahoo.ca'
36 __version__ = '1.3'
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]))? +(.*)$')
43 all_timestamps = None
45 def get_all_timestamps(datadir):
46 f = open(datadir + "/timestamps")
47 t = []
48 while True:
49 str = f.readline()
50 if str == "": break
51 m = FILETIME.search(str.strip())
52 if m:
53 year = int(m.group(1))
54 mo = int(m.group(2))
55 day = int(m.group(3))
56 if m.group(4):
57 hr = int(m.group(5))
58 minute = int(m.group(6))
59 else:
60 hr = 0
61 minute = 0
62 mtime = time.mktime((year,mo,day,hr,minute,0,0,0,-1))
64 t.append( (datadir + "/" + m.group(7), mtime) )
66 f.close()
67 return t
69 def cb_filestat(args):
70 global all_timestamps
72 filename = args["filename"]
73 stattuple = args["mtime"]
75 for fname,mtime in all_timestamps:
76 if fname == filename:
77 args["mtime"] = tuple(list(stattuple[:8]) + [mtime] + list(stattuple[9:]))
78 break
80 return args
82 def cb_start(args):
83 global all_timestamps
84 all_timestamps = get_all_timestamps(args["request"].getConfiguration()['datadir'])