baptman21 / deepdiff_viewer

Visualization tool for the DeepDiff library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeepDiff Viewer

A simple utility to visualize DeepDiff in the terminal. Support rich for even prettier renders.

Install

pip install deepdiff_viewer

To use the RichViewer class:

pip install deepdiff_viewer[rich]

Usage

Simple usage:

from deepdiff import DeepDiff
from deepdiff_viewer.rich import RichViewer

t1 = {"a": 1}
t2 = {"a": 3}

ddiff = DeepDiff(t1, t2, view="tree")
viewer = RichViewer(ddiff)
print(viewer.render())

Pydantic support

If you use pydantic for your models, the RichViewer will use the model_dump function to render the model in a yaml format when you add or delete new object. Otherwise the render would show you the python class and not a pretty render of the object.

Note that pydantic is not a dependency of the project but will be imported if it is found.

Examples

See the examples/ folder.

Simple

simple

Complex

complex

With Pydantic

with_pydantic

Concepts

The DeepDiffTreeViewer class wraps a DeepDiff object that was built with the tree view mode. It generates a tree of all the differences found in the DeepDiff object so that it can be rendered.

Currently the only implemented viewer is the RichViewer but you can extend the DeepDiffTreeViewer base class to make your own viewer if you want to use something else than rich.

License

MIT

About

Visualization tool for the DeepDiff library.

License:MIT License


Languages

Language:Python 100.0%