Skip to content

marinavasyukova/python-project-50

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gendiff


Hexlet tests and linter status:

Actions Status Python CI Maintainability Test Coverage


Description

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.


Installation

  1. Using pip

    python3 -m pip install --user git+https://github.com/marinavasyukova/python-project-50.git

or

  1. Download from git repository

    1. Clone the repository
    git clone https://github.com/marinavasyukova/python-project-50.git
    1. Go to the project directory
    cd python-project-50
    1. Install the program
    make setup

Usage

Cli-utility

% 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")

Library

from gendiff import generate_diff

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

Demo

Example of 2 plain .json files comparison (stylish format)
% gendiff file1.json file2.json

asciicast

Example of 2 plain .yaml files comparison (stylish format)
% gendiff file1.yaml file2.yaml

asciicast

Example of 2 nested .json and .yaml files comparison (stylish format)
% gendiff file1.json file2.json
% gendiff file1.yaml file2.yaml

asciicast

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

asciicast

Example of 2 nested .json and .yaml files comparison in json format
% gendiff file1.json file2.json -f json
% gendiff file1.yaml file2.yaml -f json

asciicast

About

The training project "Gendiff" on the "Python Developer" course on Hexlet.io

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published