The computer of the differences is a program that determines the difference between the two data structures. This is a popular task, for the solution of which there are many online services, for example, jsondiff. A similar mechanism, for example, is used in the output of tests or in automatic monitoring of changes in configuration files.
1. Support for different input formats: yml(yaml), json
2. Generation of the report in the form of plain text, stylish and json
This is project "Calculus of differences" on the Python Development course on Hexlet.io
This project was built using these tools:
| Tool | Description |
|---|---|
| poetry | "Python dependency management and packaging made easy" |
| Py.Test | "A mature full-featured Python testing tool" |
| Flake8 | "Your Tool For Style Guide Enforcement" |
git clone https://github.com/sergeikuz/python-project-50
cd python-project-50
make setup
usage: gendiff [-h] [-f {stylish,plain,json}] first_file second_file
Compares two configuration files and shows a difference.
positional arguments:
first_file
second_file
options:
-h, --help show this help message and exit
-f {stylish,plain,json}, --format {stylish,plain,json}
set format of output, you can choose formats: stylish, plain, json, (default format: stylish)
gendiff tests/fixtures/file1.yml tests/fixtures/file2.yml
gendiff -f plain tests/fixtures/file1.yml tests/fixtures/file2.yml
gendiff --format plain tests/fixtures/file1.json tests/fixtures/file2.json
gendiff --format json tests/fixtures/file1.json tests/fixtures/file2.json
✏️*Make sure that you have Python version 3.10 or higher installed.
- Stylish style: *Compares two configuration files and shows a difference in stylish format.
*stylish is default format
gendiff tests/fixtures/file1.yml tests/fixtures/file2.yml
gendiff -f stylish tests/fixtures/file1.yml tests/fixtures/file2.yml
gendiff --format stylish tests/fixtures/file1.json tests/fixtures/file2.json
gendiff --format stylish tests/fixtures/file1.json tests/fixtures/file2.json
- Plain style: Compares two configuration files and shows a difference in plain format.
gendiff -f plain tests/fixtures/file1.yml tests/fixtures/file2.yml
gendiff --format plain tests/fixtures/file1.json tests/fixtures/file2.json
- Json style: Compares two configuration files and shows a difference in json format.
gendiff -f json tests/fixtures/file1.yml tests/fixtures/file2.yml
gendiff --format json tests/fixtures/file1.json tests/fixtures/file2.json
Place two files that you want to compare in the tests/fixtures folder. Follow the team to search for differences:
gendiff -f plain tests/fixtures/file1.json tests/fixtures/file2.json
Replace file1.json and file2.json with your files