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.
8 Hacked on by Michael Olson <http://www.mwolson.org/>.
10 __author__
= 'Nathan Kent Bullock'
11 __homepage__
= 'http://bullock.moo.com/nathan/'
12 __email__
= 'nathan_kent_bullock -at- yahoo.ca'
15 import re
, sys
, os
, types
19 # The format of the date line in each blog entry
20 DateRegexp
= re
.compile (r
'^#date\s+(.+)$')
22 # The part of the filename of the blog entry to write to the
23 # timestamps file. Only the first grouping will be used.
24 FileNameRegexp
= re
.compile (r
'^(.+?)(\.muse)?$')
28 matched
= DateRegexp
.search(line
)
30 return matched
.group(1)
35 for filename
in os
.listdir(so_far
):
36 filepath
= so_far
+ "/" + filename
38 # just makes output prettier.
39 if filename
== ".svn": continue
40 if filename
== ".arch-ids": continue
41 if filename
== "{arch}": continue
43 if os
.path
.isdir(filepath
):
44 print "dir %s" % (filepath
,)
47 # You may need to modify the extension test
48 if os
.path
.isfile(filepath
) and filepath
!= "timestamps":
49 thisfile
= open(filepath
,'r')
50 thisdate
= getdate (thisfile
)
51 matched
= FileNameRegexp
.search(filepath
[2:])
52 if thisdate
and matched
:
53 thisname
= matched
.group(1) + ".txt"
54 OutFile
.write("%s %s\n" % (thisdate
, thisname
))
57 if __name__
== "__main__":
58 OutFile
= open("timestamps", "w+")