nbless package

Module contents

Nbless: a Python package for programmatic Jupyter notebook workflows.

nbless.nbless(in_files: List[str], kernel: str = 'python3') → nbformat.notebooknode.NotebookNode[source]

Create an executed Jupyter notebook from markdown and code files.

Parameters
  • in_files – A list of names of markdown and code files.

  • kernel – The programming language used to run the notebook.

Returns

An executed nbformat.NotebookNode object.

nbless.nbuild(in_files: List[str]) → nbformat.notebooknode.NotebookNode[source]

Create an unexecuted Jupyter notebook from markdown and code files.

Parameters

in_files – A list of source file names.

Returns

An unexecuted nbformat.NotebookNode object.

nbless.nbexec(in_file: str, kernel: str = 'python3') → nbformat.notebooknode.NotebookNode[source]

Create an executed notebook without modifying the input notebook.

Parameters
  • in_file – The name of the Jupyter notebook file to be executed.

  • kernel – The programming language used to execute the notebook.

Returns

An executed nbformat.NotebookNode object.

nbless.nbconv(in_file: str, exporter: str = '', out_file: str = '') → Tuple[str, str][source]

Convert a notebook into various formats using nbformat exporters.

Parameters
  • in_file – The name of the input notebook file.

  • out_file – The name of the output file.

  • exporter – The exporter that determines the output file type.

Returns

A 2-tuple of the output file’s 1) name and 2) contents.

Note

The exporter type must be ‘asciidoc’, ‘pdf’, ‘html’, ‘latex’, ‘markdown’, ‘python’, ‘rst’, ‘script’, or ‘slides’. All formats except ‘HTML’ require pandoc. Exporting to pdf requires latex.

nbless.nbdeck(in_file: str) → nbformat.notebooknode.NotebookNode[source]

Set up a Jupyter notebook to be viewed as or converted into slides.

Sets slide_type to slide for markdown cells that start with headers. After running nbdeck, you can

  • view Jupyter notebooks on nbviewer or with the RISE extension

  • create an HTML slideshow with nbconv or jupyter nbconvert.

Parameters

in_file – The name of the input Jupyter notebook file.

Returns

An nbformat.NotebookNode object with edited slideshow metadata.

nbless.nbraze(in_file: str, extension: str = '') → Dict[str, str][source]

Create markdown and code files from a Jupyter notebook.

Parameters
  • in_file – The name of the input Jupyter notebook file.

  • extension – The extension for code files.

Returns

A dictionary of output filenames and contents.