PK0K&D multi_rise/__init__.py"""This is a quick shortcut to combine Jupyter notebooks into a single rise presentation. It adds a cell in between each notebook to reset the environment so that the notebooks don't cause issues for each other.""" import argparse from pathlib import Path from .combine import combine_nbs __version__ = '0.1.1' def parse_index(fp): if isinstance(fp, Path): with fp.open() as f: nb_files = [fname.rstrip() for fname in f.readlines() if Path(fname.rstrip()).is_file()] return nb_files def main(argv=None): ap = argparse.ArgumentParser(description='Combine notebooks and make slides') ap.add_argument('--index', nargs='?', type=Path, default='index.txt') ap.add_argument('--output', nargs='?', type=Path, default='combined_nb.ipynb') args = ap.parse_args(argv) combine_nbs(nb_files=parse_index(args.index), output=args.output) PKhKmulti_rise/combine.py# -*- coding: utf-8 -*- import nbformat from nbformat.v4 import new_code_cell, new_markdown_cell, new_notebook def combine_nbs(nb_files=None, output=None): if "ipynb" not in output.suffix: output = output.with_suffix(".ipynb") if nb_files is None: nb_files = ['./Untitled.ipynb', './Untitled2.ipynb', './Untitled3.ipynb'] combined_nb = new_notebook() for file in nb_files: nb = nbformat.read(file, as_version=4) combined_nb.metadata.merge(nb.metadata) if 'no_reset' not in nb.cells[-1].metadata.get("tags", []): nb.cells.append( new_code_cell("%reset -f", metadata={ "slideshow": { "slide_type": 'slide' } })) nb.cells.append( new_markdown_cell("Execute for next speaker", metadata={ "slideshow": { "slide_type": '-' } })) for cell in nb.cells: cell.metadata.origin = file combined_nb.cells.append(cell) combined_nb.metadata.pop("celltoolbar") nbformat.write(combined_nb, str(output)) if __name__ == '__main__': from . import main main() PK!HWr)0+multi_rise-0.1.1.dist-info/entry_points.txtN+I/N.,()-)Ɍ/,NUU@pr3PK!H}0RR multi_rise-0.1.1.dist-info/WHEEL1 0 RZtMDtPI{w<wUnbaKM*A1ѭ g\Ic c~PK!H >YԨ#multi_rise-0.1.1.dist-info/METADATA}To0_qo )c{ QغxDsm&Ǻ9I>@N|w;ldOA[SYAda}yV[ V;Qт} 䆈X[C6!|=Nn хjئ2I~qDV+4u]G@Z  iC)7Կ C˟zέQhԐ#92Gg)M晙dT!*Z?PhY4H~2B^E](, Kr+L-ľE< 3d`iMCOƌraϫHdI6V#SЈ<\~h> P.'Vv HP٭S.(:N9( > 44 ˙H:kcG~Bz98;̓akaei&i%5 yOF1% BQ56$Zb3g^)]o)/PK!H+s1!multi_rise-0.1.1.dist-info/RECORD}r0}0tE(Q)\ IƩ+45JYĘcgJV=drRjkJlEM1WK3FS9F~ikmN=+k,9yF9i;@OɱP +҃&J /ʸHKZ~qі15216D4>F$ VlAB8;56BGpg-2"1`KⲦg6n!6}x벦:K2')ZYԨ#2 multi_rise-0.1.1.dist-info/METADATAPK!H+s1!multi_rise-0.1.1.dist-info/RECORDPK