Adding Tools to nbtoolbelt
nbtoolbelt is set up in a modular way,
so that it easy to add new tools.
The base class Tool is
defined in
toolbaseapp.py.
Every tool extends Tool,
and thereby inherits the common code
for argument parsing,
looping over all argmuments,
reading and writing of notebooks.
The tool only needs to override
the constructor
__init__()[it must callsuper()at the beginning],
and following hook methods:
config_tool_args_parsing()to configure the parser for tool-specific arguments [optional; no need to callsuper()]check_and_adjust_arguments()to check and adjust tool-specific arguments, e.g. to enforce consistence [optional; no need to callsuper()]print_tool_args()to print tool-specific arguments, called in verbose mode [optional; no need to callsuper()]process_nb()to process one notebook, returning produced notebooks [must NOT callsuper()]process_collected_data()to process data collected for all notebook [must callsuper()at the beginning]
For a simple example, see the head tool.
documentation: Notebook Heads
source file: nbheadapp.py