Skip to content

The computer of the differences is a program that determines the difference between the two data structures. A similar mechanism, for example, is used in the output of tests or in automatic monitoring of changes in configuration files.

Notifications You must be signed in to change notification settings

sergeikuz/python-project-50

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

145 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculus of differences

Hexlet tests and linter status:

Actions Status Actions Status Maintainability Test Coverage


Description

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.

Utility opportunities:

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

Used technologies:

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"

Install

git clone https://github.com/sergeikuz/python-project-50
cd python-project-50
make setup

asciicast

They are launched with simple commands:*

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.

Examples of teams for different output formats:

asciicast

  1. 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

asciicast

  1. 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

asciicast

  1. 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

asciicast

How to find differences between two files:

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

Good luck and have a fun! 🤚

About

The computer of the differences is a program that determines the difference between the two data structures. A similar mechanism, for example, is used in the output of tests or in automatic monitoring of changes in configuration files.

Resources

Stars

Watchers

Forks

Packages

No packages published