|
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 | |
|---|
| 3 | import os |
|---|
| 4 | import sys |
|---|
| 5 | |
|---|
| 6 | date = None |
|---|
| 7 | revision = None |
|---|
| 8 | |
|---|
| 9 | if len(sys.argv) != 2: |
|---|
| 10 | sys.stderr.write( "Usage: postprocess.py input > output\n" ) |
|---|
| 11 | sys.exit(-1) |
|---|
| 12 | |
|---|
| 13 | for 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 | |
|---|
| 25 | fp = open(sys.argv[1], 'r') |
|---|
| 26 | for 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 | |
|---|
| 39 | sys.stdout.write('\n'); |
|---|
| 40 | for x in fp: |
|---|
| 41 | sys.stdout.write(x); |
|---|