euporie.core.nbformat

A simple, fast, version of nbformat which avoids validation at start-up.

Implements fast versions of new_notebook and new_code_cell functions which do not perform validation, so do not require jsonschema to be imported.

Other functions are provided as shims which lazily import from the nbformat library, so they do not affect application start-up time.

Functions

find_spec(name[, package])

Return the spec for the specified module.

from_dict(d)

Convert a dictionary to a NotebookNode.

new_code_cell([source])

Create a new code cell, without validation.

new_markdown_cell([source])

Create a new markdown cell.

new_notebook(**kwargs)

Create a new notebook, without validation.

new_output(output_type[, data])

Create a new output.

new_raw_cell([source])

Create a new raw cell.

output_from_msg(msg)

Create a NotebookNode for an output from a kernel's IOPub message.

read(fp, as_version[, capture_validation_error])

Read a notebook from a file, without validation.

uuid4()

Generate a random UUID.

write(nb, fp, **kwargs)

Write a notebook to a file.

Classes

Mapping()

A Mapping is a generic container for associating key/value pairs.

NotebookNode

A dict-like node with attribute-access.

class euporie.core.nbformat.NotebookNode

Bases: dict

A dict-like node with attribute-access.

A reimplementation of nbformat.NotebookNode which does not trigger validation.

clear()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

classmethod fromkeys(iterable, value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items()

Return a set-like object providing a view on the dict’s items.

keys()

Return a set-like object providing a view on the dict’s keys.

pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update(*args: Any, **kwargs: Any) None

Update the notebook node from a dictionary.

values()

Return an object providing a view on the dict’s values.

euporie.core.nbformat.from_dict(d: Any) Any

Convert a dictionary to a NotebookNode.

euporie.core.nbformat.new_code_cell(source: str = '', **kwargs: Any) NotebookNode

Create a new code cell, without validation.

euporie.core.nbformat.new_markdown_cell(source: str = '', **kwargs: Any) NotebookNode

Create a new markdown cell.

euporie.core.nbformat.new_notebook(**kwargs: Any) NotebookNode

Create a new notebook, without validation.

euporie.core.nbformat.new_output(output_type: str, data: Any | None = None, **kwargs: Any) NotebookNode

Create a new output.

euporie.core.nbformat.new_raw_cell(source: str = '', **kwargs: Any) NotebookNode

Create a new raw cell.

euporie.core.nbformat.output_from_msg(msg: dict[str, Any]) NotebookNode

Create a NotebookNode for an output from a kernel’s IOPub message.

euporie.core.nbformat.read(fp: IO[str], as_version: int, capture_validation_error: dict | None = None, **kwargs: Any) NotebookNode

Read a notebook from a file, without validation.

euporie.core.nbformat.write(nb: NotebookNode, fp: IO[str] | str | Path, **kwargs: Any) None

Write a notebook to a file.