2 Run 'python getstamps.py' from the directory that contains your
3 unpublished blog entries.
5 You may need to make some modification for your situation. This
6 assumes your blog entries use a .txt extension and that you generate
7 them from "source" files in a different directory (with an optional
14 * Michael Olson <http://www.mwolson.org/> adapted this for Emacs Muse
15 and added a few more exluded patterns for other version control
22 __author__
= 'Nathan Kent Bullock'
23 __homepage__
= 'http://bullock.moo.com/nathan/'
24 __email__
= 'nathan_kent_bullock -at- yahoo.ca'
27 import re
, sys
, os
, types
31 # The format of the date line in each blog entry
32 DateRegexp
= re
.compile (r
'^#date\s+(.+)$')
34 # The part of the filename of the blog entry to write to the
35 # timestamps file. Only the first grouping will be used.
36 FileNameRegexp
= re
.compile (r
'^(.+?)(\.muse)?$')
40 matched
= DateRegexp
.search(line
)
42 return matched
.group(1)
47 for filename
in os
.listdir(so_far
):
48 filepath
= so_far
+ "/" + filename
50 # just makes output prettier.
51 if filename
== ".svn": continue
52 if filename
== ".arch-ids": continue
53 if filename
== "{arch}": continue
54 if filename
== ".bzr": continue
55 if filename
== "_darcs": continue
57 if os
.path
.isdir(filepath
):
58 print "dir %s" % (filepath
,)
61 # You may need to modify the extension test
62 if os
.path
.isfile(filepath
) and filepath
!= "timestamps":
63 thisfile
= open(filepath
,'r')
64 thisdate
= getdate (thisfile
)
65 matched
= FileNameRegexp
.search(filepath
[2:])
66 if thisdate
and matched
:
67 thisname
= matched
.group(1) + ".txt"
68 OutFile
.write("%s %s\n" % (thisdate
, thisname
))
71 if __name__
== "__main__":
72 OutFile
= open("timestamps", "w+")