Skip to content

Kulakoff1988/python-project-lvl2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Maintainability Test Coverage

Diff generator

This is the utility for getting diff between two json or yaml files.

Bellow you may see the way to install and use the package:

pip install --user --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ kulakoff1988-gendiff

asciicast

Diff between two flat yaml or json files:

gendiff tests/fixtures/test_flat_old.yml tests/fixtures/test_flat_new.yml

The output in the string format by default:

{
    constant: yep
  - test: bar
  + test: foo
  - foo: bar
  + bar: foo
}

asciicast

Diff between two recursive structured files:

gendiff tests/fixtures/test_nested_old.json tests/fixtures/test_nested_new.json

Output:

{
    common: {
        setting1: Value 1
      - setting2: 200
        setting3: true
      - setting6: {
            key: value
        }
      + setting4: blah blah
      + setting5: {
            key5: value5
        }
    }
    group1: {
      - baz: bas
      + baz: bars
        foo: bar
    }
  - group2: {
        abc: 12345
    }
  + group3: {
        fee: 100500
    }
}

asciicast

Diff between two files in plain format:

gendiff tests/fixtures/test_nested_old.json tests/fixtures/test_nested_new.json -f plain
Property "common.setting2" was removed
Property "common.setting6" was removed
Property "common.setting4" was added with value: "blah blah"
Property "common.setting5" was added with value: "complex value"
Property "group1.baz" was changed. From "bas" to "bars"
Property "group2" was removed
Property "group3" was added with value: "complex value"

asciicast

To get diff between two files in json format use the command: asciicast