This library allows to compare two configuration files and display the difference between them. Files that can be compared must be either JSON or YAML type (ending with .json or .yaml/.yml respectively). It's important for both files to be the same type (you can't compare JSON with YAML). The difference shows what has changed in the second file relative to the first one. The difference can be showed in three ways (format types):
- Stylish (the default one)
- Plain
- JSON
The output examples are represented in the Asciinema section below.
- Choose a directory you want to store this library in
- Copy the link of this repo
- Paste it after
git clonein your terminal - Input
cd python-project-50 - Input
pip install .
After that you can use gendiff as a command in your CLI or as a library in your own .py files.
gendiffrequires two positional arguments that must be paths to files you want to compare. Paths to files must be specified relatively to your current working directorygendiffcan take an optional argument-f(--format) which defines how the difference will be showed: instylish,plainorjsonformatgendiff -hshows a brief descriptiongendiff path/to/first_file path/to/second_fileshows a difference between files in a default (stylish) format
- Simply make an import
from gendiff import generate_diffto use the difference generating function by itself - Signature:
generate_diff("path/to/first_file", "path/to/second_file", format_name="stylish"), returns a string
- python 3.12 or newer