Don't interpret enddots, dots, and rule inside of links.
[muse-el.git] / contrib / pyblosxom / getstamps.py
blob4dc8197399b3981db92f863f506dca6eaf5b24f9
1 """
2 Run this file 'python getstamps.py' from your pyblosxom data-dir.
4 You may need to make some modification for your situation. This
5 assumes your blog entries use a .txt extension.
7 Hacked on by Michael Olson <http://www.mwolson.org/>.
8 """
9 __author__ = 'Nathan Kent Bullock'
10 __homepage__ = 'http://bullock.moo.com/nathan/'
11 __email__ = 'nathan_kent_bullock -at- yahoo.ca'
12 __version__ = '1.0'
14 import re, sys, os, types
16 OutFile=None
18 DateRegexp = re.compile (r'^#date\s+(.+)$')
20 def getdate(f):
21 for line in f:
22 matched = DateRegexp.search(line)
23 if matched:
24 return matched.group(1)
26 def recurse(so_far):
27 global OutFile
29 for filename in os.listdir(so_far):
30 filepath = so_far + "/" + filename
32 # just makes output prettier.
33 if filename == ".svn": continue
35 if os.path.isdir(filepath):
36 print "dir %s" % (filepath,)
37 recurse(filepath)
39 # You may need to modify the extension test
40 if os.path.isfile(filepath) and filepath != "timestamps":
41 thisfile = open(filepath,'r')
42 thisdate = getdate (thisfile)
43 if thisdate:
44 OutFile.write("%s %s\n" % (thisdate, filepath[2:] + ".txt"))
45 continue
47 if __name__ == "__main__":
48 OutFile = open("timestamps", "w+")
49 recurse(".")