forked from clientIO/joint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-www.py
executable file
·35 lines (27 loc) · 945 Bytes
/
build-www.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
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
# Generate www.
import os
import shutil
TEMPLATES_DIR = 'www/templates/'
TARGET_DIR = 'www/'
template = 'template.tpl'
if __name__ == "__main__":
# copy demos to www
shutil.rmtree(TARGET_DIR + 'demos/');
shutil.rmtree(TARGET_DIR + 'lib/');
shutil.rmtree(TARGET_DIR + 'src/');
shutil.copytree('demos', TARGET_DIR + 'demos')
shutil.copytree('lib', TARGET_DIR + 'lib')
shutil.copytree('src', TARGET_DIR + 'src')
template = open(TEMPLATES_DIR + template)
templateContent = template.read()
template.close()
templates = os.listdir(TEMPLATES_DIR)
for tpl in templates:
if tpl == template: continue
tplFile = open(TEMPLATES_DIR + tpl)
tplContent = tplFile.read()
page = open(TARGET_DIR + os.path.splitext(tpl)[0] + '.html', 'w')
page.write(templateContent.replace('{CONTENT}', tplContent))
page.close()
tplFile.close()