API Documentation
Exported interface, when nbtoolbelt is imported as library
Copyright (c) 2017-2020 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- nbtoolbelt.__version__
Version number, as string
- nbtoolbelt.version_info
Version as tuple
- nbtoolbelt.package_name
Name of the
nbtoolbeltpackage
- nbtoolbelt.CELL_STATISTICS
Tuple with the keys used in the dictionary returned by
nb_cell_stats()
- nbtoolbelt.nb_cell_stats(nb: NotebookNode, args: Optional[Namespace] = None) Dict[str, Dict[str, int]][source]
Count occurrences of various elements in notebook cells.
If
argsis notNone, then the following boolean arguments are used (if present; absent is interpreted asFalse):sources
metadata
tags
code
streams
errors
If
argsisNone, then all statistics are gathered.- Parameters:
nb – notebook to inspect
args – namespace with arguments; if None, count everything
- Returns:
dictionary of dictionaries with counts per section; each section has its own key; see CELL_STATISTICS
- nbtoolbelt.nb_extra_fields(nb: NotebookNode) Dict[str, int][source]
Extract extra global fields in notebook.
- Parameters:
nb – notebook to inspect
- Returns:
list of extra fields (not set, because that is not JSON serializable)
- nbtoolbelt.nb_metadata(nb: NotebookNode) Dict[str, Any][source]
Summarize notebook global metadata.
- Parameters:
nb – notebook to inspect
- Returns:
dictionary with format, kernel, and language info
- nbtoolbelt.nb_other_metadata(nb: NotebookNode) Dict[str, int][source]
Extract other global metadata fields in notebook.
- Parameters:
nb – notebook to inspect
- Returns:
set of global metadata fields other than required
- nbtoolbelt.print_dict(d: Dict[str, Any], header: Optional[str] = None, width: int = 10) None[source]
Print dictionary d with section header.
- Parameters:
d – dictionary to print
header – header of the table
width – width of the left column
- nbtoolbelt.print_set(s: Set[str], header: Optional[str] = None, width: int = 10) None[source]
Print set s with section header.
- Parameters:
s – set to print
header – header of the table
width – width of the left column
- nbtoolbelt.run_nb(nb: NotebookNode, args: Namespace) None[source]
Run notebook.
Note
Modifies:
nb- Parameters:
nb – notebook to run
args – arguments (options)
- nbtoolbelt.__version__ = '2024.7.2'
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- nbtoolbelt.package_name = 'nbtoolbelt'
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- nbtoolbelt.CELL_STATISTICS = ('cell_types', 'sources', 'cell_metadata', 'cell_attachments', 'code_execution', 'code_outputs', 'cell_extra')
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.