forked from jrnold/lstbayes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlstbayes.py
36 lines (29 loc) · 1.24 KB
/
lstbayes.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
35
36
import json
import re
import sys
import datetime
import jinja2
def main():
pkgversion = datetime.date.today().strftime("%Y/%m/%d")
with open("stan-language-definitions/stan_lang.json", "r") as f:
data = json.load(f)
functions = sorted(k for k, v in data['functions'].items()
if not v['operator'])
distributions = sorted(v['sampling'] for k, v in data['functions'].items()
if v['sampling'])
keywords3 = sorted(functions + distributions)
env = jinja2.Environment(block_start_string = '<%',
block_end_string = '%>',
variable_start_string = '<<',
variable_end_string = '>>',
comment_start_string = '<!',
comment_end_string = '!>',
loader = jinja2.FileSystemLoader('.'))
template = env.get_template('lstbayes_template.dtx')
rendered = template.render({'keywords3': keywords3,
'version': data['version'],
'pkgversion': pkgversion})
with open('lstbayes.dtx', 'w') as f:
f.write(rendered)
if __name__ == '__main__':
main()