labapi.tree.collection.Notebooks#
- class labapi.tree.collection.Notebooks(notebooks: Sequence[NotebookInit], user: User)[source]#
Bases:
Mapping[IdOrNameIndex,Notebook|Sequence[Notebook]]A collection of LabArchives notebooks accessible to a user.
This class provides dictionary-like access to notebooks by their ID or name, and supports creating new notebooks. It manages a list of
Notebookobjects.- __init__(
- notebooks: Sequence[NotebookInit],
- user: User,
Initialize the notebook collection.
- Parameters:
notebooks – A sequence of
NotebookInitobjects containing initial data for the notebooks.user – The authenticated
Userassociated with these notebooks.
Methods
__init__(notebooks, user)Initialize the notebook collection.
Return
(name, notebook)pairs in collection order, preserving duplicates.all_keys()Return notebook names in collection order, preserving duplicates.
Return notebook objects in collection order, preserving duplicates.
create_notebook(name)Create a new notebook in LabArchives.
get(k[,d])items()Return a mapping-compatible view of
(name, notebook)pairs.keys()Return a mapping-compatible view of notebook names.
values()Return a mapping-compatible view of notebook objects.
- keys() KeysView[str][source]#
Return a mapping-compatible view of notebook names.
- Returns:
A keys view of notebook names.
- items() ItemsView[str, Notebook][source]#
Return a mapping-compatible view of
(name, notebook)pairs.- Returns:
An items view of
(name, notebook)pairs.
- values() ValuesView[Notebook][source]#
Return a mapping-compatible view of notebook objects.
- Returns:
A values view of notebook objects.
- all_items() Sequence[tuple[str, Notebook]][source]#
Return
(name, notebook)pairs in collection order, preserving duplicates.
- get(
- k[,
- d,]
- all_values() Sequence[Notebook][source]#
Return notebook objects in collection order, preserving duplicates.
- create_notebook(
- name: str,
Create a new notebook in LabArchives.
- Parameters:
name – The name of the new notebook.
- Returns:
The newly created
Notebookobject.- Raises:
RuntimeError – If the underlying client session has been closed.
AuthenticationError – If LabArchives rejects the request due to invalid or expired credentials.
ApiError – If LabArchives returns a non-success response, or if the API returns a notebook ID that already exists in the local collection.