ExportModuleProc
ExportModuleProc ()
A processor which exports code to a module
ExportModuleProc ()
A processor which exports code to a module
Specify dest
where the module(s) will be exported to, and optionally a class to use to create the module (ModuleMaker, by default).
Exported cells are stored in a dict
called modules
, where the keys are the modules exported to. Those without an explicit module are stored in the '#'
key, which will be exported to default_exp
.
black_format (cell, force=False)
Format code with black
Type | Default | Details | |
---|---|---|---|
cell | A cell node | ||
force | bool | False | Turn black formatting on regardless of settings.ini |
create_modules (path, dest, procs=None, debug=False, mod_maker=<class'nbprocess.maker.ModuleMaker'>)
Create module(s) from notebook
Let’s check we can import a test file:
We’ll also check that our ‘everything’ file exports correctly:
create_modules(everything_fn, 'tmp')
g = exec_new('import tmp.everything; from tmp.everything import *')
_alls = L("a b d e m n o p q".split())
for s in _alls.map("{}_y"): assert s in g, s
for s in "c_y_nall _f_y_nall g_n h_n i_n j_n k_n l_n".split(): assert s not in g, s
for s in _alls.map("{}_y") + ["c_y_nall", "_f_y_nall"]: assert hasattr(g['tmp'].everything,s), s
That notebook should also export one extra function to tmp.some.thing
:
nb_export (nbname, lib_path=None)