-
Notifications
You must be signed in to change notification settings - Fork 17
/
convert.py
30 lines (22 loc) · 999 Bytes
/
convert.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
#!/usr/bin/env python3
import os
import logging
from nbpages import make_parser, run_parsed, make_html_index
args = make_parser().parse_args()
if args.template_file is None and os.path.exists('nb_html.tpl'):
args.template_file = 'nb_html.tpl'
if args.exclude is None and args.include is None:
# If there is an "exclude_notebooks" file, use that to find which ones to
# skip. Format is one pattern per line, "#" for comments.
# Note that this will be ignored if exclude or include is given at the command line.
to_exclude = []
if os.path.isfile('exclude_notebooks'):
with open('exclude_notebooks') as f:
for line in f:
if line.strip() != '':
to_exclude.append(line.split('#')[0].strip())
if to_exclude:
args.exclude = ','.join(to_exclude)
converted = run_parsed('.', output_type='HTML', args=args)
logging.getLogger('nbpages').info('Generating index.html')
make_html_index(converted, './index.tpl')