Note
This documentation is for a development version of IPython. There may be significant differences from the latest stable release.
The official API for working with notebooks in the current format version.
Bases: exceptions.ValueError
Convert a notebook node object to a specific version. Assumes that all the versions starting from 1 to the latest major X are implemented. In other words, there should never be a case where v1 v2 v3 v5 exist without a v4. Also assumes that all conversions can be made in one step increments between major versions and ignores minor revisions.
| Parameters: | nb : NotebookNode to_version : int
|
|---|
Create a new author.
Create a new code cell with input and output
Create a new section cell with a given integer level.
Create a new metadata node.
Create a notebook by name, id and a list of worksheets.
Create a new output, to go in the cell.outputs list of a code cell.
Create a new text cell.
Create a worksheet by name with with a list of cells.
Parse a notebook filename.
This function takes a notebook filename and returns the notebook format (json/py) and the notebook name. This logic can be summarized as follows:
| Parameters: | fname : unicode
|
|---|---|
| Returns: | (fname, name, format) : (unicode, unicode, unicode)
|
Parse a string into a (nbformat, string) tuple.
Read a notebook from a file and return the NotebookNode object.
This function properly handles notebooks of any version. The notebook returned will always be in the current version’s format.
| Parameters: | fp : file
|
|---|---|
| Returns: | nb : NotebookNode
|
Read a notebook from a string and return the NotebookNode object.
This function properly handles notebooks of any version. The notebook returned will always be in the current version’s format.
| Parameters: | s : unicode
|
|---|---|
| Returns: | nb : NotebookNode
|
DEPRECATED, use reads
DEPRECATED: use nbconvert
Checks whether the given notebook JSON conforms to the current notebook format schema.
Raises ValidationError if not valid.
Write a notebook to a file in a given format in the current nbformat version.
This function always writes the notebook in the current nbformat version.
| Parameters: | nb : NotebookNode
fp : file
|
|---|
Write a notebook to a string in a given format in the current nbformat version.
This function always writes the notebook in the current nbformat version.
| Parameters: | nb : NotebookNode
version : int
|
|---|---|
| Returns: | s : unicode
|
DEPRECATED, use writes
DEPRECATED: use nbconvert