Skip to content

AABur/python-project-lvl2

Repository files navigation

Gendiff

Actions Status CitHub_CI CodeQL

Maintainability Test Coverage wemake-python-styleguide

Challenge | 100 Days of Code

Gendiff (GENerator of DIFFerences) - a program defining the difference between two data structures (JSON or YAML) and generating new structure containing differences details (including unchanged).

Features

  • Supported input formats: YAML, JSON
  • Report generation as plain text, structured text and JSON
  • Usage as CLI util or library function

Installation

Use the package manager pip to install gendiff.

pip install --user git+https://github.com/AABur/python-project-lvl2.git

Installation and usage example

asciicast

Usage

As library function

from gendiff import generate_diff

diff = generate_diff(file_path1, file_path2, style)
print(diff)

As CLI util

❯ gendiff -h
usage: gendiff [-h] [-f {json,plain,stylish}] first_file second_file

Generate difference of two JSON or YAML files.

positional arguments:
  first_file            first file to compare
  second_file           second file to compare

optional arguments:
  -h, --help            show this help message and exit
  -f {json,plain,stylish}, --format {json,plain,stylish}
                        set output format (default: 'stylish')

Usage examples

JSON output (-f json)

asciicast

Structured output (-f stylish)

asciicast

Plain output (-f plain)

asciicast

Contributing

This is a learning project and the contribution is not accepted.

License

MIT License

About

This is the second of four training projects on the Python Software Developer course on Hexlet.io. https://ru.hexlet.io/professions/python/projects/50

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published