-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.py
More file actions
33 lines (27 loc) · 808 Bytes
/
update.py
File metadata and controls
33 lines (27 loc) · 808 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
#!/usr/bin/env python
# encoding: utf-8
"""
update.py
Created by Darcy Liu on 2013-06-07.
Copyright (c) 2013 OnlineJudge. All rights reserved.
"""
import sys
import os
import codecs
import json
import jinja2
skip_files = ['.git','template','docs']
def main():
with codecs.open('index.html', 'w', encoding='utf8') as outfile:
problems = []
for name in os.listdir('.'):
if os.path.isdir(name) and name not in skip_files:
path = os.path.join('.',name,'problem.json')
problem = codecs.open(path, encoding='utf8').read()
problem = json.loads(problem)
print problem['id'],problem['title']
problems.append(problem)
template = jinja2.Template(open('base.html').read())
outfile.write(template.render(locals()))
if __name__ == '__main__':
main()