# sys.meta_path.append(NotebookFinder())Notebooks
implements the Jupyter Notebook Module Finder. See Importing Jupyter Notebooks as Modules for more details.
%load_ext autoreload %autoreload 2
Jupter-Notebooks
from Jupyter Notebooks readthedocs.
Imports
Utility for finding notebook files
find_notebook
find_notebook (fullname:str, path:Optional[str]=None)
find a notebook, given its fully qualified name and an optional path
This turns “foo.bar” into “foo/bar.ipynb” and tries turning “Foo_Bar” into “Foo Bar” if Foo_Bar does not exist.
Notebook Loader
NotebookLoader
NotebookLoader (path:Optional[str]=None)
Module Loader for Jupyter Notebooks
Module Finder
NotebookFinder
NotebookFinder ()
Module finder that locates Jupyter Notebooks
How to Register the Hook
Displaying Notebooks
NotebookViewer
NotebookViewer (path:Optional[str]=None)
Example
# nbv = NotebookViewer(os.path.abspath(os.path.join("./_constants", "00_init.ipynb")))
# nbv.show_notebook()Aggregation Script
NotebookPrefixer
NotebookPrefixer (path:Optional[str]=None, name:Optional[str]=None, maximal:Optional[bool]=False)
NotebookPrefixer(
os.path.dirname(os.path.abspath(os.path.join('./_utils'))),
name='utils'
).next_nb_prefix()'02'
NotebookAggregator
NotebookAggregator (path:str, module:Optional[str]=None, output:Optional[str]=None, ignore:List[str]=<factory>, prefix:Union[bool,str,NoneType]=True, prefix_dir:Optional[str]=None)
A class to aggregate Jupyter notebooks.
| Type | Default | Details | |
|---|---|---|---|
| path | str | The path to the directory containing the notebooks. | |
| module | Optional | None | The name of the module, by default None |
| output | Optional | None | The path to the output notebook, by default None |
| ignore | List | A list of notebooks to ignore, by default [] | |
| prefix | Union | True | |
| prefix_dir | Optional | None |
nbagg = NotebookAggregator(
os.path.abspath(os.path.join('./_01_static')),
module='static',
ignore=['_00_init.ipynb']
)nbagg.aggregate()nbagg = NotebookAggregator(
os.path.abspath(os.path.join('./_02_utils')),
module='utils',
)
nbagg.aggregate()nbagg = NotebookAggregator(
os.path.abspath(os.path.join('./_03_types')),
module='types',
)
nbagg.aggregate()Jupyter-Notebook Logger
NotebookLogger
NotebookLogger (name:Optional[str]='NotebookLogger', level:Optional[int]=20, format:Optional[str]='%(asctime)s - %(levelname)s - %(message)s')