Moved book generation code into PDF directory

Start of a reorganization of files to make book more browable and to
reduce the size of links to chapters.
This commit is contained in:
Roger Labbe
2015-01-27 09:06:21 -08:00
parent a2dd5a0276
commit f135d2e213
16 changed files with 10858 additions and 18 deletions

26
pdf/nbmerge.py Normal file
View File

@@ -0,0 +1,26 @@
"""
usage:
python nbmerge.py A.ipynb B.ipynb C.ipynb > merged.ipynb
"""
import io
import os
import sys
from IPython.nbformat import current
def merge_notebooks(filenames):
merged = None
for fname in filenames:
with io.open(fname, 'r', encoding='utf-8') as f:
nb = current.read(f, 'json')
if merged is None:
merged = nb
else:
merged.worksheets[0].cells.extend(nb.worksheets[0].cells)
merged.metadata.name += "_merged"
print current.writes(merged, 'json')
if __name__ == '__main__':
merge_notebooks(sys.argv[1:])