nbtoolbelt package
Submodules
nbtoolbelt.arguments module
Functions for command-line argument parsing
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.arguments.ExtendAction(option_strings, dest, **kwargs)[source]
Bases:
ActionExtend current list for option with parsed list.
Note
Assumption: Option is already present in namespace (from embedded config file read in
__init__()).
- class nbtoolbelt.arguments.LoadConfigFile(option_strings, dest, **kwargs)[source]
Bases:
ActionAction to take when parsing a configuration file option.
- class nbtoolbelt.arguments.LoadSourceFile(option_strings, dest, **kwargs)[source]
Bases:
ActionAction to take when parsing a source file option.
- class nbtoolbelt.arguments.NegatableAction(option_strings, dest, default=None, required=False, help=None)[source]
Bases:
ActionAdd the supplied positive options and negative versions as well. Inspired by
nbshow.
- class nbtoolbelt.arguments.TestAction(option_strings, dest, **kwargs)[source]
Bases:
Action,NamespaceAction to test the action mechanism, by printing the parameter values received in constructor and call methods.
- nbtoolbelt.arguments.join_csv(s: Iterable[str]) str[source]
Join strings in list to comma-separated values. Inverse of
split_csv.- Parameters:
s – list to join
- Returns:
joined csv string
nbtoolbelt.cleaning module
Functions for cleaning
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- nbtoolbelt.cleaning.clean_code_metadata(nb: NotebookNode, clean: List[str]) None[source]
Clean metadata of code cells, by * removing collapsed and scrolled flags on code cells * removing ExecuteTime data on code cells
Note
Modifies:
nb- Parameters:
nb – notebook to clean
clean – metadata keys to clean
- nbtoolbelt.cleaning.clean_code_output(nb: NotebookNode) None[source]
Clean all output cells and execution counts.
Note
Modifies:
nb- Parameters:
nb – notebook to clean
- nbtoolbelt.cleaning.clean_nb(nb: NotebookNode, args: Namespace) Dict[source]
Clean fields and optionally output from notebook.
If
argsis notNone, then the following arguments are used:clean_notebook_metadata_fields (collection)
clean_cell_metadata_fields (collection)
clean_tags (collection)
clean_empty_cells (boolean)
clean_outputs (boolean)
Note
Modifies:
nb- Parameters:
nb – notebook to clean
args – namespace with arguments (options)
- Returns:
dictionary with statistics for removed elements
nbtoolbelt.config module
Configuration file handling
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
Configuration files use JSON to make it easier to move the Jupyter configuration file mechanism in the future.
There is a top-level entry for global options with the package name as key. Each tool has a tool-specific entry with key ‘nb’ + tool name; e.g. ‘nbrun’.
The top-level configuration is loaded first; typically it has options that apply to multiple tools. Then the tool-specific configuration is loaded on top of that (using dict update).
TODO: First the embedded configuration file is loaded (these are defaults).
TODO: Then a configuration file in the home directory is loaded, if present.
Finally configuration files mentioned on the command line are loaded. These are processed during argument parsing.
- nbtoolbelt.config.config_path() Path[source]
Return path to embedded config file.
- Returns:
path to embedded config file
- nbtoolbelt.config.load_config(tool: str = 'nbtoolbelt', verbose: bool = False) Namespace[source]
Load configuration for tool.
Successively load configuration files (if present) in:
the package itself (see src/nbtoolbelt/data/CONFIG_FILE_NAME)
/etc/CONFIG_FILE_NAME
~/.CONFIG_FILE_NAME (a dot file in the home directory)
Note
Modifies:
ns- Parameters:
tool – tool for which to load a configuration file (default: top-level)
verbose – whether to print some diagnostic info
- Returns:
updated ns
- nbtoolbelt.config.load_config_file(tool: str = 'nbtoolbelt', ns: Optional[Namespace] = None, file_path: Union[str, Path] = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/nbtoolbelt/envs/latest/lib/python3.10/site-packages/nbtoolbelt/data/nbtoolbelt.json'), verbose: bool = False) Namespace[source]
Load configuration for tool from file and return update namespace. Silently ignores file if it does not exist.
Note
Modifies:
ns- Parameters:
tool – tool for which to load a configuration file
ns – namespace to load configuration into
file_path – file path to load configuration from
verbose – whether to print some diagnostic info
- Returns:
updated ns
nbtoolbelt.counting module
Functions for counting elements in Jupyter notebooks
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- nbtoolbelt.counting.CELL_STATISTICS = ('cell_types', 'sources', 'cell_metadata', 'cell_attachments', 'code_execution', 'code_outputs', 'cell_extra')
Fields used in the dictionary returned by
nb_cell_stats().
- nbtoolbelt.counting.PAIRING_TOKEN = ' : '
character sequence to combine key pairs
- nbtoolbelt.counting.clean_dict(d: Dict[str, Any]) Dict[str, Any][source]
Remove key-nan pairs and convert non-nan np types to native Python.
- Parameters:
d – dict to clean
- Returns:
cleaned dict
- nbtoolbelt.counting.count_source(source: str) Tuple[int, int, int][source]
Count number of non-blank lines, words, and non-whitespace characters.
- Parameters:
source – string to count
- Returns:
number of non-blank lines, words, and non-whitespace characters
- nbtoolbelt.counting.extract_aggregate(d: ~typing.Dict[str, ~typing.Dict[str, ~typing.Any]], attr: str = 'total', convert: ~typing.Callable[[~typing.Any], ~typing.Any] = <class 'int'>) Dict[str, Any][source]
Extract converted values for given attribute from nested dictionary.
- nbtoolbelt.counting.flatten_mapping(mapping: Mapping[str, Any]) Dict[str, Any][source]
Return recursively flattened mapping as dict.
- Parameters:
mapping – object to flatten
- Returns:
flattened mapping
- nbtoolbelt.counting.is_key_pair(key: str) bool[source]
Return whether key is paired, that is, result of
pair_key.- Parameters:
key – key to test
- Returns:
whether key is result of
pair_key()
- nbtoolbelt.counting.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.counting.nb_code_execution_stats(nb: NotebookNode) Dict[source]
Count number of (executed) code cells and errors in notebook.
- Parameters:
nb – notebook to inspect
- Returns:
dictionary with ‘code cells’: number of code cells, ‘executed’: number of executed cells, ‘with errors’: number of execution errors
- nbtoolbelt.counting.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.counting.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.counting.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.counting.pair_keys(key1: str, key2: str) str[source]
Pair two strings into one string, where key2 may also have been paired.
- Parameters:
key1 – first key
key2 – second key
- Returns:
paired key
nbtoolbelt.inline_attachments module
NbConvert Preprocessor to inline attachments
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
Parts of this code are reworked from the rendernb checklet for Momotor <momotor.org>.
- class nbtoolbelt.inline_attachments.InlineAttachmentsPreprocessor(**kwargs: Any)[source]
Bases:
PreprocessorTo embed cell attachments inside the cell’s source.
- ACCEPTABLE_TYPES = ('image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/bmp')
- preprocess_cell(cell: NotebookNode, resources: Dict[str, Any], index: int) Tuple[NotebookNode, Dict[str, Any]][source]
Take a Jupyter Notebook cell and inline all attachments as data.
Note
Modifies:
cell- Parameters:
cell – cell for which to inline attachments
resources – global resources
index – cell index in notebook
- Returns:
modified cell, updated resources
nbtoolbelt.nbcatapp module
Main for nbcat
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
nbtoolbelt.nbcleanapp module
Main for nbclean
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.nbcleanapp.CleanTool[source]
Bases:
ToolClean each notebook.
- check_and_adjust_arguments()[source]
Do tool-specific checks and adjustments of parsed arguments.
Hook method to be overridden in concrete tools.
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
nbtoolbelt.nbdumpapp module
Tool nbdump; dump cell sources of notebooks
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.nbdumpapp.DumpTool[source]
Bases:
ToolShow all source lines of each notebook.
- check_and_adjust_arguments() None[source]
Do tool-specific checks and adjustments of parsed arguments.
Hook method to be overridden in concrete tools.
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
nbtoolbelt.nbheadapp module
Tool nbhead; shows head of notebooks
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
This tool also illustrates how to extend class Tool, to define a new concrete tool.
- class nbtoolbelt.nbheadapp.HeadTool[source]
Bases:
ToolShow the first n (default 5) source lines of the first cell of each notebook. If n is negative, show the last n source lines of the last cell.
It overrides:
config_tool_args_parsing()to configure parser for tool-specific argumentsprint_tool_args()to print tool-specific arguments (used in verbose mode)process_nb()to process one notebook
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
nbtoolbelt.nbpunchapp module
Tool nbpunch
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.nbpunchapp.PunchTool[source]
Bases:
ToolPunch notebooks, optionally filling holes with material coming from other notebooks, writing the results to new notebooks.
- check_and_adjust_arguments()[source]
Do tool-specific checks and adjustments of parsed arguments.
Hook method to be overridden in concrete tools.
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
nbtoolbelt.nbrunapp module
Main for nbrun
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.nbrunapp.RunTool[source]
Bases:
ToolRun each notebook, with optional pre-/post-cleaning, and return results.
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
nbtoolbelt.nbsplitapp module
Main for nbsplit
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.nbsplitapp.SplitTool[source]
Bases:
ToolSplit each notebook.
- check_and_adjust_arguments() None[source]
Do tool-specific checks and adjustments of parsed arguments.
Hook method to be overridden in concrete tools.
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
- print_tool_args() None[source]
Print tool-specific arguments; used especially in verbose mode. Indent the lines by 2 spaces.
Hook method to be overridden in concrete tools.
- process_nb(nb: NotebookNode, nb_path: Path) Sequence[Tuple[NotebookNode, Path]][source]
Split notebook nb into markdown, code, and raw cells.
Note
Modifies:
nbSide effect: writes new notebook files
- Parameters:
nb – notebook to split
nb_path – path to
nb
- Returns:
sequence of resulting (notebook, notebook-path) pairs
nbtoolbelt.nbstatsapp module
Main for nbstats
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
Summarize Jupyter notebooks on the command line.
- class nbtoolbelt.nbstatsapp.StatsTool[source]
Bases:
ToolCollect and show a statistical summary of each notebook. Also compute some statistics over all notebooks.
- check_and_adjust_arguments()[source]
Do tool-specific checks and adjustments of parsed arguments.
Hook method to be overridden in concrete tools.
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
nbtoolbelt.nbvalidateapp module
Tool nbvalidate
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.nbvalidateapp.ValidateTool[source]
Bases:
ToolValidate each notebook, and report the validation results.
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
nbtoolbelt.nbviewapp module
Tool nbview
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.nbviewapp.ViewTool[source]
Bases:
ToolShow notebooks in the browser, with embedded MathJax and attachments rendered.
- check_and_adjust_arguments()[source]
Do tool-specific checks and adjustments of parsed arguments.
Hook method to be overridden in concrete tools.
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
- print_tool_args() None[source]
Print tool-specific arguments; used especially in verbose mode. Indent the lines by 2 spaces.
Hook method to be overridden in concrete tools.
nbtoolbelt.notebook_io module
Functions for notebook reading and writing
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- nbtoolbelt.notebook_io.cell_lines(cell: NotebookNode) List[str][source]
Return list of source lines for given cell.
- Parameters:
cell – cell whose source lines to return as list
- Returns:
list of source lines in cell
- nbtoolbelt.notebook_io.read_nb(nb_path: Path, args: Namespace) Union[None, NotebookNode][source]
Read notebook from given path, and return it. Uses
args.debug: in debug mode, a read error results in an exception, else it returnsNone.- Parameters:
nb_path – path to read from
args – to check debug mode
- Returns:
notebook read from
nb_pathor None if reading failed and notargs.debug
- nbtoolbelt.notebook_io.write_nb(nb: NotebookNode, nb_path: Path, args: Namespace) Union[None, bool][source]
Write given notebook to given path. Uses
args.debug: in debug mode, a write error results in an exception, else it returnsNone.- Parameters:
nb – notebook to be written
nb_path – path to write to
args – to check debug mode
- Returns:
nbtoolbelt.printing module
Functions for printing
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- nbtoolbelt.printing.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.processing module
Common processing definitions
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
nbtoolbelt.punching module
Functions for punching
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.punching.ChadsNotebookProcessor(nb: NotebookNode, args: Namespace, name: str)[source]
Bases:
PunchBaseProcessorCreate chads notebook.
self.nb_chads = result notebook under construction self.cell_chads = next cell under construction, with source as list of strings (to be compacted)
- class nbtoolbelt.punching.PunchBaseProcessor(nb: NotebookNode, args: Namespace, name: str)[source]
Bases:
objectBase class for
punchprocessors, using the Template Method pattern. The base class takes care of parsing the marking structure. The concrete subclasses provide semantics for marking structure.Template methods:
punch_nb(): main entry point; callspunch_line()and hook methods *pre_cell(), *post_cell(), and *post_nb()punch_line(): calls hook methods *punch_begin_marker_line(), *punch_end_marker_line(), *punch_inside_line(), and *punch_outside_line()
Concrete processors override the following hook methods:
__init__()to initialize; must callsuper()at beginpre_cell()punch_begin_marker_line()punch_end_marker_line()punch_inside_line()punch_outside_line()post_cell()post_nb()
A concrete class is typically instantiated and used to process a notebook in one go:
ConcretePunchProcessor(args, nb, name).punch_nb()
- handle_error(message: str, cell: NotebookNode, ignore: bool = True) None[source]
Handle error with marker.
- Parameters:
message – error message
cell – notebook cell with error
ignore – whether to ignore the marker line
- parse_line(line: str, cell_type: str) None[source]
Parse given line for given cell type, and decide whether it is a marker line. Set instance variable
markerto dictionary with transition, label, and description. Sets it toNoneif the line is not a marker line. Setsmarker['transition']toNoneif invalid marker line.Note
Modifies:
self.marker- Parameters:
line – marker line
cell_type – type of cell containing marker line
- class nbtoolbelt.punching.PunchedNotebookProcessor(nb: NotebookNode, args: Namespace, name: str)[source]
Bases:
PunchBaseProcessorCreate punched notebook.
self.nb_punched = result notebook under construction self.cell_punched = next cell under construction self.source_chad = chad being inserted in current hole
- class nbtoolbelt.punching.SourceChadsProcessor(nb: NotebookNode, args: Namespace, name: str)[source]
Bases:
PunchBaseProcessorCreate chads for later use as source. Result is delivered in
args.source_chads, which is a dictionary that maps hole labels to hole content as list of cells.self.source_chads = dictionary that maps label to list of cells self.cell_source_chads = next cell under construction, with source as list of strings (to be compacted)
nbtoolbelt.rendering module
Functions for rendering
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
Parts of this code are reworked from the rendernb checklet for Momotor <momotor.org>.
nbtoolbelt.running module
Functions for running
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
nbtoolbelt.toolbaseapp module
Base class for concrete tools
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
- class nbtoolbelt.toolbaseapp.Tool(name: str = 'nbbase', action: str = 'copy', description: str = 'Copy Jupyter notebooks.')[source]
Bases:
objectBase class for concrete tools. It is in itself a functional tool that copies notebooks.
These methods are template methods:
main()parse_args()process_file()
Concrete tools inherit from Tool and override these (hook) methods:
__init__()MUSTsuper()at begin, when overridingconfig_tool_args_parsing()optional; to configure parser for tool-specific argumentscheck_and_adjust_arguments()optionalprint_tool_args()optional; to print tool-specific arguments (called only in verbose mode)process_nb()compulsory; to process one notebook; MUST NOT CALLsuper()process_collected_data()optional; MUST CALLsuper()at begin, when overriding
About the instance variables:
- OUTPUT_HEADER = '::::::::::::::'
- check_and_adjust_arguments()[source]
Do tool-specific checks and adjustments of parsed arguments.
Hook method to be overridden in concrete tools.
- config_tool_args_parsing(group: _ArgumentGroup) None[source]
Add argument configurations that are tool specific to the given argument group.
Hook method to be overridden in concrete tools.
- Parameters:
group – argument group to add into
- main(cli_args: Optional[List[str]] = None) int[source]
Main entry point. Processes all files in
args.notebooks, returning an exit code (0 = success).Can set
self._exit_codeto signal abortion.- Parameters:
cli_args – list of command-line arguments (None when used as independent script)
- parse_args(arguments: List[str]) None[source]
Configure an argument parser and parse the command-line arguments, updating the namespace with the parsed arguments.
Note
Modifies:
self._args- Parameters:
arguments – list of arguments on command line
- parser_with_common_arguments() ArgumentParser[source]
Create argument parser and add common arguments to it.
- Returns:
the pre-configured parser
- print_tool_args() None[source]
Print tool-specific arguments; used especially in verbose mode. Indent the lines by 2 spaces.
Hook method to be overridden in concrete tools.
- process_collected_data() None[source]
Process outputs collected from all processed notebooks.
Hook method to be overridden in concrete tools. Overriding method must call
super()at begin.
- process_file(nb_path: Path) None[source]
Process one file, given by its path.
Note
Modifies:
self._aggregate- Parameters:
nb_path – path of file to process
- Returns:
exit code
- process_nb(nb: NotebookNode, nb_path: Path) Sequence[Tuple[NotebookNode, Path]][source]
Process notebook nb.
Can update
self._aggregate.Hook method to be overridden in concrete tools. Overriding method must NOT call
super().Note
Modifies:
nb,self._aggregate- Parameters:
nb – notebook to process
nb_path – path to
nb
- Returns:
sequence of resulting (notebook, notebook-path) pairs
nbtoolbelt.validating module
Functions for validating notebooks
Copyright (c) 2017 - Eindhoven University of Technology, The Netherlands
This software is made available under the terms of the MIT License.
Module contents
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