forked from pre-commit/pre-commit.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_templates.py
More file actions
39 lines (27 loc) · 839 Bytes
/
make_templates.py
File metadata and controls
39 lines (27 loc) · 839 Bytes
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
35
36
37
38
39
from __future__ import absolute_import
from __future__ import unicode_literals
import io
import mako.lookup
import ordereddict
import simplejson
template_lookup = mako.lookup.TemplateLookup(
directories=['.'],
)
ALL_TEMPLATES = ('index', 'hooks')
def get_env():
all_hooks = simplejson.loads(
io.open('all-hooks.json').read(),
object_pairs_hook=ordereddict.OrderedDict,
)
return {'all_hooks': all_hooks}
def main():
env = get_env()
for template in ALL_TEMPLATES:
env['template_name'] = template
with io.open('{0}.html'.format(template), 'w') as html_file:
template_obj = template_lookup.get_template(
'{0}.mako'.format(template),
)
html_file.write(template_obj.render(**env))
if __name__ == '__main__':
exit(main())