root / dotorg / v7 / html / beps / postprocess.py

Revision 10540, 0.8 kB (checked in by dave, 10 months ago)

postprocessing script that replaces date and last-modified with values from subversion.

generated .html files.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3import os
4import sys
5
6date = None
7revision = None
8
9if len(sys.argv) != 2:
10    sys.stderr.write( "Usage: postprocess.py input > output\n" )
11    sys.exit(-1)
12
13for x in os.popen( "svn info %s" % sys.argv[1] ):
14    tup = x.split(':')
15    if len(tup) < 2:
16        continue
17
18    key = tup[0].strip()
19    val = ":".join(tup[1:]).strip()
20    if key == "Last Changed Rev":
21        revision = val
22    elif key == "Last Changed Date":
23        date = val
24
25fp = open(sys.argv[1], 'r')
26for x in fp:
27    # only process up to the first blank line, which signals the end of the BEP headers.
28    if x == '':
29        break
30
31    if "$Revision$" in x:
32        x = x.replace( "$Revision$", revision )
33
34    if "$Date$" in x:
35        x = x.replace( "$Date$", date )
36
37    sys.stdout.write(x);
38
39sys.stdout.write('\n');
40for x in fp:
41    sys.stdout.write(x);
Note: See TracBrowser for help on using the browser.