Warning

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

Module: html.services.notebooks.nbmanager

A base class notebook manager.

Authors:

  • Brian Granger
  • Zach Sailer

1 Class

class IPython.html.services.notebooks.nbmanager.NotebookManager(**kwargs)

Bases: IPython.config.configurable.LoggingConfigurable

check_and_sign(nb, name, path='')

Check for trusted cells, and sign the notebook.

Called as a part of saving notebooks.

Parameters:

nb : dict

The notebook structure

name : string

The filename of the notebook

path : string

The notebook’s directory

copy_notebook(from_name, to_name=None, path='')

Copy an existing notebook and return its new model.

If to_name not specified, increment from_name-Copy#.ipynb.

create_checkpoint(name, path='')

Create a checkpoint of the current state of a notebook

Returns a checkpoint_id for the new checkpoint.

create_notebook(model=None, path='')

Create a new notebook and return its model with no content.

delete_checkpoint(checkpoint_id, name, path='')

delete a checkpoint for a notebook

delete_notebook(name, path='')

Delete notebook by name and path.

get_dir_model(name, path='')

Get the directory model given a directory name and its API style path.

The keys in the model should be: * name * path * last_modified * created * type=’directory’

get_notebook(name, path='', content=True)

Get the notebook model with or without content.

increment_filename(basename, path='')

Increment a notebook filename without the .ipynb to make it unique.

Parameters:

basename : unicode

The name of a notebook without the .ipynb file extension.

path : unicode

The URL path of the notebooks directory

Returns:

name : unicode

A notebook name (with the .ipynb extension) that starts with basename and does not refer to any existing notebook.

is_hidden(path)

Does the API style path correspond to a hidden directory or file?

Parameters:

path : string

The path to check. This is an API path (/ separated, relative to base notebook-dir).

Returns:

exists : bool

Whether the path is hidden.

list_checkpoints(name, path='')

Return a list of checkpoints for a given notebook

list_dirs(path)

List the directory models for a given API style path.

list_notebooks(path='')

Return a list of notebook dicts without content.

This returns a list of dicts, each of the form:

dict(notebook_id=notebook,name=name)

This list of dicts should be sorted by name:

data = sorted(data, key=lambda item: item['name'])
mark_trusted_cells(nb, name, path='')

Mark cells as trusted if the notebook signature matches.

Called as a part of loading notebooks.

Parameters:

nb : dict

The notebook structure

name : string

The filename of the notebook

path : string

The notebook’s directory

notebook_exists(name, path='')

Returns a True if the notebook exists. Else, returns False.

Parameters:

name : string

The name of the notebook you are checking.

path : string

The relative path to the notebook (with ‘/’ as separator)

Returns:

bool

path_exists(path)

Does the API-style path (directory) actually exist?

Override this method in subclasses.

Parameters:

path : string

The path to check

Returns:

exists : bool

Whether the path does indeed exist.

restore_checkpoint(checkpoint_id, name, path='')

Restore a notebook from one of its checkpoints

save_notebook(model, name, path='')

Save the notebook and return the model with no content.

should_list(name)

Should this file/directory name be displayed in a listing?

trust_notebook(name, path='')

Explicitly trust a notebook

Parameters:

name : string

The filename of the notebook

path : string

The notebook’s directory

update_notebook(model, name, path='')

Update the notebook and return the model with no content.