Skip to content

Repository files navigation

diff

Diff is a library to calculate deltas between structured data.

Features

  • Calculate detla(s)
  • Rebuild state from delta(s)

Supported Formats

  • JSON
  • YAML
  • XML
  • TOML

Usage

Diff

importdiffold= {"name": "David"}
new= {"name": "Alex"}
deltas=diff.diff(new=new, old=old)
fordeltaindeltas:
print(delta)

Output

Operation(op='modified', path='$.name', new_value='Alex', old_value='David')

Rebuild

importdiffold= {"name": "David"}
new= {"name": "Alex"}
deltas=diff.diff(new=new, old=old)
rebuild_new=diff.patch(base=old, deltas=deltas)
assertrebuild_new==old

Install

poetry add git+https://github.com/includeamin/diff.git#tag

About

A library to calculate diff between structured data

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages