anytree icon indicating copy to clipboard operation
anytree copied to clipboard

Are there plans to include diff feature which compares two trees and points out the differences?

Open sreeshas opened this issue 8 years ago • 4 comments

Title says it all. It would be really cool to have diff api which

  1. Compares two trees
  2. List the differences
  3. Lists out steps for transforming one into another.

Consider this as feature request.

sreeshas avatar Nov 02 '17 20:11 sreeshas

I am thinking about it already ;-)

The idea is to have a Comparator class which compares the tree node by node. Then nodes need to implement some kind of hashing for identity.

Do you have a code example of your explicit use case?

c0fec0de avatar Nov 05 '17 23:11 c0fec0de

The best way is to dump the tree to a text format and use https://docs.python.org/3/library/difflib.html I will add an example in the documentation

c0fec0de avatar Jun 29 '21 20:06 c0fec0de

Hi, this is implemented over here.

https://bigtree.readthedocs.io/en/latest/bigtree/tree/helper.html#bigtree.tree.helper.get_tree_diff

kayjan avatar Nov 12 '22 15:11 kayjan

While ist is not a feature yet, I think it can be done by exporting the trees to dicts and using dictdiffer or deepdiff to get the delta. Has anyone tried this?

jkbgbr avatar Mar 28 '24 23:03 jkbgbr