Skip to main content

tool to compare structured files like json, ini , yaml

Project description

diffant

diffant uses the structure of configuration files to do a more helpful comparison than standard diff.

diffant allows you to compare:

  • ini
  • json
  • yaml

For example, for the purpose of comparing configuration, these two files are the same. There should be no diff:

file_01.ini file_02.ini
[info] [info]
email=bob@example.com phone=212-555-1212
phone=212-555-1212 email = bob@example.com

diffant can meaningfully compare a heavily commented original configuration file with many lines to a minimized comment-less configuration file and find how the defaults have changed.

You are not limited to comparing 2 files, diffant can compare many files.

SAMPLE OUTPUT

fruit:  apple
          tests/sample_input.dirs/simple/file01.json
          tests/sample_input.dirs/simple/file03.json

        cherry
          tests/sample_input.dirs/simple/file02.json

        /*MISSING*/
          tests/sample_input.dirs/simple/file04.json

grain:  rice
          tests/sample_input.dirs/simple/file01.json

        /*MISSING*/
          tests/sample_input.dirs/simple/file02.json
          tests/sample_input.dirs/simple/file03.json
          tests/sample_input.dirs/simple/file04.json

inspiration:art:  Pablo Picasso
                    tests/sample_input.dirs/simple/file01.json
                    tests/sample_input.dirs/simple/file03.json

                  Frida Kahlo
                    tests/sample_input.dirs/simple/file02.json

                  /*MISSING*/
                    tests/sample_input.dirs/simple/file04.json

inspiration:music:  Dead Kennedys
                      tests/sample_input.dirs/simple/file01.json
                      tests/sample_input.dirs/simple/file02.json
                      tests/sample_input.dirs/simple/file03.json

                    /*MISSING*/
                      tests/sample_input.dirs/simple/file04.json

inspiration:tools:0:  hammer
                        tests/sample_input.dirs/simple/file02.json

                      /*MISSING*/
                        tests/sample_input.dirs/simple/file01.json
                        tests/sample_input.dirs/simple/file03.json
                        tests/sample_input.dirs/simple/file04.json

inspiration:tools:1:  rack
                        tests/sample_input.dirs/simple/file02.json

                      /*MISSING*/
                        tests/sample_input.dirs/simple/file01.json
                        tests/sample_input.dirs/simple/file03.json
                        tests/sample_input.dirs/simple/file04.json

vegetable:  spinach
              tests/sample_input.dirs/simple/file03.json

            /*MISSING*/
              tests/sample_input.dirs/simple/file01.json
              tests/sample_input.dirs/simple/file02.json
              tests/sample_input.dirs/simple/file04.json

SAMPLE INPUT

file01.json

{
"grain": "rice",
"color": "red",
 "fruit": "apple",
 "inspiration": {"art":"Pablo Picasso","music":"Dead Kennedys"}
}

file02.json

  {
   "color": "red",
   "fruit": "cherry",
   "inspiration": {"art":"Frida Kahlo","music":"Dead Kennedys","tools":["hammer","rack"]}
  }

file03.json

 {
   "vegetable": "spinach",
   "color": "red",
   "fruit": "apple",
   "inspiration": {"art":"Pablo Picasso","music":"Dead Kennedys"}
  }

file04.json

{
   "color": "red"
  }

REQUIREMENTS

  • pip
  • python >= 3.8

LICENSE

GNU General Public License v3.0

SETUP

pip3 install diffant

USAGE

diffant  <directory with files of same type>

BUGS

  1. The files you are comparing need to be at the top level of a directory that you supply as a positional argument to diffant
  2. The files need to have an extension that reflects their contents (ini,json.yml)
  3. You can't compare files of different types or have files of different types in your input directory.

SUPPORT

dan@omacneil.org

CONTRIBUTORS

  • @morgan: Helpful tweak to README.md
  • cpat-gpt: about 50% of the code

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffant-1.0.3.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

diffant-1.0.3-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file diffant-1.0.3.tar.gz.

File metadata

  • Download URL: diffant-1.0.3.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/6.1.0-1015-oem

File hashes

Hashes for diffant-1.0.3.tar.gz
Algorithm Hash digest
SHA256 138abb248c80e6637700f9039f2e8d22b709a1b2aa1340ade756d74ec5318ff7
MD5 c21bc5ac81bba7a7146c0355eedd955c
BLAKE2b-256 cc5b2623eddbaf9b0ce6a16b1c7b77af1434f219aeab4c121e3756fd09b249b5

See more details on using hashes here.

File details

Details for the file diffant-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: diffant-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/6.1.0-1015-oem

File hashes

Hashes for diffant-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 827b2ee5ce9024a6d1f837d7cd27a70a54e1c72c0cbb43481df5b2e4317a5ef6
MD5 d0e0f09c03115d9aa921dc9c5de9f0d1
BLAKE2b-256 daddc2f7c925a099ff8266759d2bea087af9dc8d2e1a6d82f09fe284a3f28598

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page