The function you want is
`nbdime.diffing.notebooks.set_notebook_diff_targets`. It is not very
well exposed because its current implementation is a bit hackish: It
currently sets what to diff in a global (i.e. for the running
session). As such, it is a good candidate for a refactor, but for now
you should probably wrap it in a context manager to ensure it is reset
after calling it (snippet included below for convenience).
from contextlib import contextmanager
from nbdime.diffing.notebooks import set_notebook_diff_targets
@contextmanager
def diff_targets(sources=True, outputs=True, metadata=True):
set_notebook_diff_targets(sources=sources, outputs=outputs,
metadata=metadata)
try:
yield
finally:
set_notebook_diff_targets() # default options will reset
def only_diff_targets(sources=False, outputs=False, metadata=False):
return diff_targets(sources, outputs, metadata)
# Usage:
import nbdime
import nbformat
afn = 'local file.ipynb'
bfn = 'remote file.ipynb'
a = nbformat.read(afn, as_version=4)
b = nbformat.read(bfn, as_version=4)
with only_diff_targets(outputs=True):
diff = nbdime.diff_notebooks(a, b)
nbdime.prettyprint.pretty_print_notebook_diff(afn, bfn, a, diff)
> --
> You received this message because you are subscribed to the Google Groups
> "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
jupyter+u...@googlegroups.com.
> To post to this group, send email to
jup...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/jupyter/b7366123-7db7-4635-81c2-f27c19df0bca%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.