forked from hupili/tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_site.py
More file actions
36 lines (32 loc) · 1.01 KB
/
Copy pathcreate_site.py
File metadata and controls
36 lines (32 loc) · 1.01 KB
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
# -*- coding: utf-8 -*-
#
# Render README.md of each tutorials
#
# Run this script at the tutorial root
import os
import shutil
import jinja2
import json
template = jinja2.Template(open('page.tpl.md').read())
def build_tutorial(info):
root = './' + info['auto']['path']
target = './webpage/' + info['meta']['bib_key']
try:
os.makedirs(target)
except:
# The file already exists
pass
#shutil.copy(root + '/README.md', target + 'README.md')
info['auto']['readme'] = open('%s/README.md' % (root), 'r').read()
result = template.render(info)
open('%s/%s.md' % (target, info['meta']['bib_key']), 'w').write(result)
if 'files' in info['meta']:
for file in info['meta']['files']:
src = '%s/%s' % (root, file['src'])
dst = '%s/%s' % (target, file['dst'])
shutil.copy(src, dst)
if __name__ == '__main__':
import pickle
all_info = pickle.loads(open('info.pickle', 'r').read())
for info in all_info:
build_tutorial(info)