Gendiff is a program for comparing two data structures
Features of utility:
-
Supported formats: JSON, YAML
-
Report generation as plain text, structured text (stylish format) and JSON format
-
Usage as CLi-utility or external library
It's the second training project on Hexlet 'Python developer' course.
-
python3 -m pip install --user git+https://github.com/marinavasyukova/python-project-50.git
or
-
- Clone the repository
git clone https://github.com/marinavasyukova/python-project-50.git
- Go to the project directory
cd python-project-50
- Install the program
make setup
% gendiff -h
usage: gendiff [-h] [-f {plain,stylish,json}] first_file second_file
Compares two configuration files and shows a difference.
positional arguments:
first_file path to the first file
second_file path to the second file
options:
-h, --help show this help message and exit
-f {plain,stylish,json}, --format {plain,stylish,json}
set format of output (default: "stylish")
from gendiff import generate_diff
diff = generate_diff(file_path1, file_path2)
print(diff)
Example of 2 nested .json and .yaml files comparison (stylish format)
% gendiff file1.json file2.json
% gendiff file1.yaml file2.yaml
Example of 2 nested .json and .yaml files comparison in 2 different formats (stylish and plain)
% gendiff file1.json file2.json
% gendiff file1.json file2.json -f plain
% gendiff file1.yaml file2.yaml
% gendiff file1.yaml file2.yaml -f plain