forked from sonatype/maven-example-en
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.py
25 lines (20 loc) · 782 Bytes
/
template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import airspeed
import glob
import os
t = airspeed.Template(open("site/book-template.html", "r").read())
bookTitle = "Maven by Example"
bookId = "ss-book-mvnex"
path = 'target/site/reference'
for infile in glob.glob( os.path.join(path, '*.html') ):
if infile.endswith( 'search.html'):
print( " Ignoring search.html" )
else:
print "Reading File: " + infile
body = open(infile, "r").read()
title = body[ body.index( "<title>" ) + 7 : body.rindex("</title>") ]
body = body[ body.index( "<body>") + 6 : body.rindex("</body>") ]
if "index.html" in infile:
print ("Replacing bookTitle - replacing with ToC" )
title = "Table of Contents"
body = body.replace(bookTitle, title)
open(infile, "w").write( t.merge(locals()) );