-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.py
executable file
·32 lines (27 loc) · 942 Bytes
/
gen.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
#!/usr/bin/python
import sys, os.path
from parser.Service import Service
from generator.Generator import Generator
def main():
service = Service()
filename = sys.argv[1]
print "Converting %(filename)s" % locals()
tree = service.parse(filename)
# Generator("debug", tree.tree).write("out")
targets = (
# Name, Template, Outdir
('webpy', 'python-webpy', 'webpy'),
('html', 'html', 'webpy/static/docs/'),
('html', 'html', 'html'),
)
for target in targets:
type = target[0]
template = target[1]
outdir = target[2]
gen = Generator("CodeTemplator", tree.tree)
gen.setOption("template", sys.path[0] + "/templates/" + template)
gen.setOption("sourcedir", os.path.dirname(filename))
gen.setOption("type", type)
gen.write("out/" + outdir)
if __name__ == "__main__":
main()