Warning

This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: nbformat.v4.convert

Code for converting notebooks to and from v3.

10 Functions

IPython.nbformat.v4.convert.upgrade(nb, from_version=3, from_minor=0)

Convert a notebook to v4.

Parameters:

nb : NotebookNode

The Python representation of the notebook to convert.

from_version : int

The original version of the notebook to convert.

from_minor : int

The original minor version of the notebook to convert (only relevant for v >= 3).

IPython.nbformat.v4.convert.upgrade_cell(cell)

upgrade a cell from v3 to v4

heading cell -> markdown heading code cell:

  • remove language metadata
  • cell.input -> cell.source
  • cell.prompt_number -> cell.execution_count
  • update outputs
IPython.nbformat.v4.convert.downgrade_cell(cell)

downgrade a cell from v4 to v3

code cell:
  • set cell.language
  • cell.input <- cell.source
  • cell.prompt_number <- cell.execution_count
  • update outputs
markdown cell:
  • single-line heading -> heading cell
IPython.nbformat.v4.convert.to_mime_key(d)

convert dict with v3 aliases to plain mime-type keys

IPython.nbformat.v4.convert.from_mime_key(d)

convert dict with mime-type keys to v3 aliases

IPython.nbformat.v4.convert.upgrade_output(output)

upgrade a single code cell output from v3 to v4

  • pyout -> execute_result
  • pyerr -> error
  • output.type -> output.data.mime/type
  • mime-type keys
  • stream.stream -> stream.name
IPython.nbformat.v4.convert.downgrade_output(output)

downgrade a single code cell output to v3 from v4

  • pyout <- execute_result
  • pyerr <- error
  • output.data.mime/type -> output.type
  • un-mime-type keys
  • stream.stream <- stream.name
IPython.nbformat.v4.convert.upgrade_outputs(outputs)

upgrade outputs of a code cell from v3 to v4

IPython.nbformat.v4.convert.downgrade_outputs(outputs)

downgrade outputs of a code cell to v3 from v4

IPython.nbformat.v4.convert.downgrade(nb)

Convert a v4 notebook to v3.

Parameters:

nb : NotebookNode

The Python representation of the notebook to convert.