Skip to content

Commit

Permalink
fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Aug 21, 2022
1 parent f74fafe commit cf1aa61
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 72 deletions.
151 changes: 83 additions & 68 deletions execnb/_modidx.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,88 @@
# Autogenerated by nbdev

d = { 'settings': { 'allowed_cell_metadata_keys': '',
'allowed_metadata_keys': '',
'audience': 'Developers',
'author': 'Jeremy Howard',
'author_email': '[email protected]',
'black_formatting': 'False',
'branch': 'master',
'clean_ids': 'True',
'console_scripts': 'exec_nb=execnb.shell:exec_nb',
'copyright': 'Put your copyright info here',
'custom_quarto_yml': 'False',
'custom_sidebar': 'False',
'description': 'A description of your project',
'dev_requirements': 'matplotlib Pillow',
d = { 'settings': { 'branch': 'master',
'doc_baseurl': '/execnb/',
'doc_host': 'https://fastai.github.io',
'doc_path': '_docs',
'git_url': 'https://github.com/fastai/execnb/tree/master/',
'host': 'github',
'jupyter_hooks': 'True',
'keywords': 'some keywords',
'language': 'English',
'lib_name': 'execnb',
'lib_path': 'execnb',
'license': 'apache2',
'min_python': '3.7',
'nbs_path': 'nbs',
'readme_nb': 'index.ipynb',
'recursive': 'False',
'requirements': 'fastcore>=1.5.5 ipython',
'status': '2',
'title': 'execnb',
'tst_flags': 'notest',
'user': 'fastai',
'version': '0.1.2'},
'syms': { 'execnb.fastshell': { 'execnb.fastshell.FastInteractiveShell': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell',
'execnb.fastshell.FastInteractiveShell.ask_exit': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.ask_exit',
'execnb.fastshell.FastInteractiveShell.data_pub': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.data_pub',
'execnb.fastshell.FastInteractiveShell.get_parent': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.get_parent',
'execnb.fastshell.FastInteractiveShell.init_data_pub': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.init_data_pub',
'execnb.fastshell.FastInteractiveShell.init_environment': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.init_environment',
'execnb.fastshell.FastInteractiveShell.init_magics': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.init_magics',
'execnb.fastshell.FastInteractiveShell.init_virtualenv': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.init_virtualenv',
'execnb.fastshell.FastInteractiveShell.set_next_input': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.set_next_input',
'execnb.fastshell.FastInteractiveShell.set_parent': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.set_parent',
'execnb.fastshell.FastInteractiveShell.system_piped': 'https://fastai.github.io/execnb/fastshell.html#fastinteractiveshell.system_piped',
'execnb.fastshell.KernelMagics': 'https://fastai.github.io/execnb/fastshell.html#kernelmagics',
'execnb.fastshell.KernelMagics.autosave': 'https://fastai.github.io/execnb/fastshell.html#kernelmagics.autosave',
'execnb.fastshell.KernelMagics.clear': 'https://fastai.github.io/execnb/fastshell.html#kernelmagics.clear',
'execnb.fastshell.KernelMagics.edit': 'https://fastai.github.io/execnb/fastshell.html#kernelmagics.edit',
'execnb.fastshell.KernelMagics.less': 'https://fastai.github.io/execnb/fastshell.html#kernelmagics.less'},
'execnb.nbio': { 'execnb.nbio.NbCell': 'https://fastai.github.io/execnb/nbio.html#nbcell',
'execnb.nbio.NbCell.parsed_': 'https://fastai.github.io/execnb/nbio.html#nbcell.parsed_',
'execnb.nbio.NbCell.set_source': 'https://fastai.github.io/execnb/nbio.html#nbcell.set_source',
'execnb.nbio.dict2nb': 'https://fastai.github.io/execnb/nbio.html#dict2nb',
'execnb.nbio.mk_cell': 'https://fastai.github.io/execnb/nbio.html#mk_cell',
'execnb.nbio.nb2dict': 'https://fastai.github.io/execnb/nbio.html#nb2dict',
'execnb.nbio.nb2str': 'https://fastai.github.io/execnb/nbio.html#nb2str',
'execnb.nbio.new_nb': 'https://fastai.github.io/execnb/nbio.html#new_nb',
'execnb.nbio.read_nb': 'https://fastai.github.io/execnb/nbio.html#read_nb',
'execnb.nbio.write_nb': 'https://fastai.github.io/execnb/nbio.html#write_nb'},
'execnb.shell': { 'execnb.shell.CaptureShell': 'https://fastai.github.io/execnb/shell.html#captureshell',
'execnb.shell.CaptureShell.cell': 'https://fastai.github.io/execnb/shell.html#captureshell.cell',
'execnb.shell.CaptureShell.enable_gui': 'https://fastai.github.io/execnb/shell.html#captureshell.enable_gui',
'execnb.shell.CaptureShell.enable_matplotlib': 'https://fastai.github.io/execnb/shell.html#captureshell.enable_matplotlib',
'execnb.shell.CaptureShell.execute': 'https://fastai.github.io/execnb/shell.html#captureshell.execute',
'execnb.shell.CaptureShell.prettytb': 'https://fastai.github.io/execnb/shell.html#captureshell.prettytb',
'execnb.shell.CaptureShell.run': 'https://fastai.github.io/execnb/shell.html#captureshell.run',
'execnb.shell.CaptureShell.run_all': 'https://fastai.github.io/execnb/shell.html#captureshell.run_all',
'execnb.shell.CaptureShell.set_path': 'https://fastai.github.io/execnb/shell.html#captureshell.set_path',
'execnb.shell.exec_nb': 'https://fastai.github.io/execnb/shell.html#exec_nb'}}}
'lib_path': 'execnb'},
'syms': { 'execnb.fastshell': {},
'execnb.nbio': { 'execnb.nbio.NbCell': ( 'https://fastai.github.io/execnb/nbio.html#nbcell',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L19'),
'execnb.nbio.NbCell.__eq__': ( 'https://fastai.github.io/execnb/nbio.html#__eq__',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L39'),
'execnb.nbio.NbCell.__hash__': ( 'https://fastai.github.io/execnb/nbio.html#__hash__',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L38'),
'execnb.nbio.NbCell.__init__': ( 'https://fastai.github.io/execnb/nbio.html#__init__',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L20'),
'execnb.nbio.NbCell.parsed_': ( 'https://fastai.github.io/execnb/nbio.html#parsed_',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L29'),
'execnb.nbio.NbCell.set_source': ( 'https://fastai.github.io/execnb/nbio.html#set_source',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L25'),
'execnb.nbio._dict2obj': ( 'https://fastai.github.io/execnb/nbio.html#_dict2obj',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L42'),
'execnb.nbio._read_json': ( 'https://fastai.github.io/execnb/nbio.html#_read_json',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L15'),
'execnb.nbio.dict2nb': ( 'https://fastai.github.io/execnb/nbio.html#dict2nb',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L48'),
'execnb.nbio.mk_cell': ( 'https://fastai.github.io/execnb/nbio.html#mk_cell',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L67'),
'execnb.nbio.nb2dict': ( 'https://fastai.github.io/execnb/nbio.html#nb2dict',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L76'),
'execnb.nbio.nb2str': ( 'https://fastai.github.io/execnb/nbio.html#nb2str',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L84'),
'execnb.nbio.new_nb': ( 'https://fastai.github.io/execnb/nbio.html#new_nb',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L62'),
'execnb.nbio.read_nb': ( 'https://fastai.github.io/execnb/nbio.html#read_nb',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L55'),
'execnb.nbio.write_nb': ( 'https://fastai.github.io/execnb/nbio.html#write_nb',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/nbio.py#L90')},
'execnb.shell': { 'execnb.shell.CaptureShell': ( 'https://fastai.github.io/execnb/shell.html#captureshell',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L71'),
'execnb.shell.CaptureShell.__init__': ( 'https://fastai.github.io/execnb/shell.html#__init__',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L73'),
'execnb.shell.CaptureShell._add_exec': ( 'https://fastai.github.io/execnb/shell.html#_add_exec',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L109'),
'execnb.shell.CaptureShell._add_out': ( 'https://fastai.github.io/execnb/shell.html#_add_out',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L104'),
'execnb.shell.CaptureShell._result': ( 'https://fastai.github.io/execnb/shell.html#_result',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L113'),
'execnb.shell.CaptureShell._showtraceback': ( 'https://fastai.github.io/execnb/shell.html#_showtraceback',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L100'),
'execnb.shell.CaptureShell._stream': ( 'https://fastai.github.io/execnb/shell.html#_stream',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L117'),
'execnb.shell.CaptureShell.cell': ( 'https://fastai.github.io/execnb/shell.html#captureshell.cell',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L147'),
'execnb.shell.CaptureShell.enable_gui': ( 'https://fastai.github.io/execnb/shell.html#enable_gui',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L96'),
'execnb.shell.CaptureShell.enable_matplotlib': ( 'https://fastai.github.io/execnb/shell.html#enable_matplotlib',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L84'),
'execnb.shell.CaptureShell.execute': ( 'https://fastai.github.io/execnb/shell.html#captureshell.execute',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L179'),
'execnb.shell.CaptureShell.prettytb': ( 'https://fastai.github.io/execnb/shell.html#captureshell.prettytb',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L200'),
'execnb.shell.CaptureShell.run': ( 'https://fastai.github.io/execnb/shell.html#captureshell.run',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L129'),
'execnb.shell.CaptureShell.run_all': ( 'https://fastai.github.io/execnb/shell.html#captureshell.run_all',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L161'),
'execnb.shell.CaptureShell.set_path': ( 'https://fastai.github.io/execnb/shell.html#set_path',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L90'),
'execnb.shell._CaptureHook': ( 'https://fastai.github.io/execnb/shell.html#_capturehook',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L36'),
'execnb.shell._CaptureHook.__call__': ( 'https://fastai.github.io/execnb/shell.html#__call__',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L47'),
'execnb.shell._CaptureHook.quiet': ( 'https://fastai.github.io/execnb/shell.html#quiet',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L39'),
'execnb.shell._CapturePub': ( 'https://fastai.github.io/execnb/shell.html#_capturepub',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L52'),
'execnb.shell._CapturePub.publish': ( 'https://fastai.github.io/execnb/shell.html#publish',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L54'),
'execnb.shell._false': ( 'https://fastai.github.io/execnb/shell.html#_false',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L158'),
'execnb.shell._format_mimedata': ( 'https://fastai.github.io/execnb/shell.html#_format_mimedata',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L62'),
'execnb.shell._out_exc': ( 'https://fastai.github.io/execnb/shell.html#_out_exc',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L58'),
'execnb.shell._out_stream': ( 'https://fastai.github.io/execnb/shell.html#_out_stream',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L59'),
'execnb.shell.exec_nb': ( 'https://fastai.github.io/execnb/shell.html#exec_nb',
'https://github.com/fastai/execnb/tree/master//blob/master/execnb/shell.py#L212')}}}
6 changes: 5 additions & 1 deletion execnb/nbio.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ def nb2str(nb):
# %% ../nbs/01_nbio.ipynb 37
def write_nb(nb, path):
"Write `nb` to `path`"
with open(path, 'w', encoding='utf-8') as f: f.write(nb2str(nb))
new = nb2str(nb)
path = Path(path)
old = Path(path).read_text() if path.exists() else None
if new!=old:
with open(path, 'w', encoding='utf-8') as f: f.write(new)
9 changes: 6 additions & 3 deletions nbs/01_nbio.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,11 @@
"#|export\n",
"def write_nb(nb, path):\n",
" \"Write `nb` to `path`\"\n",
" with open(path, 'w', encoding='utf-8') as f: f.write(nb2str(nb))"
" new = nb2str(nb)\n",
" path = Path(path)\n",
" old = Path(path).read_text() if path.exists() else None\n",
" if new!=old:\n",
" with open(path, 'w', encoding='utf-8') as f: f.write(new)"
]
},
{
Expand Down Expand Up @@ -590,8 +594,7 @@
"outputs": [],
"source": [
"#|hide\n",
"from nbdev import nbdev_export\n",
"nbdev_export()"
"import nbdev; nbdev.nbdev_export()"
]
},
{
Expand Down

0 comments on commit cf1aa61

Please sign in to comment.