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)
On Mon, Jul 10, 2017 at 7:52 PM, Adam Rule <[email protected]> wrote:
> I noticed there are console commands for controlling which part of the
> notebook to diff using nbdime (source, output, metadata, attachments). How
> do I set these options when calling nbdime.diff() from python rather than
> the command line? I've looked through the documentation and source code and
> it seems to be related to the `differs` parameter in the diff function, but
> I have not (yet) figured out how to set it properly.
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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.
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jupyter/CADZ1C%3DyG_BKt%3D3O0TB87r4rk%2BVdXgWEZX-a6pYAh%3Df64khC2dA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.