Skip to content

Commit

Permalink
Refactoring in parser.py, in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AntiViruS90 committed Aug 26, 2024
1 parent 48ee9b1 commit 850500e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ gendiff/scripts/__pycache__
gendiff/formats/__pycache__
.coverage
cc-test-reporter
coverage.xml
coverage.xml
small_json.cast
small_yaml.cast
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,30 @@
[![Actions Status](https://github.com/AntiViruS90/python-project-50/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/AntiViruS90/python-project-50/actions)
[![Maintainability](https://api.codeclimate.com/v1/badges/68428dfb9d1613d87ed3/maintainability)](https://codeclimate.com/github/AntiViruS90/python-project-50/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/68428dfb9d1613d87ed3/test_coverage)](https://codeclimate.com/github/AntiViruS90/python-project-50/test_coverage)

Difference-Calculator is a Python console cly-utility that compares two files in 'json' or 'yaml'(yml) formats and outputs the result of comparing (differences) between them in different formatter

### **Requirements:**

| TOOLS | VERSION |
|-------:|-----------|
| python | "^3.10" |
| pyyaml | "^6.0.2" |


### **Tools in this cli-utility**:

| TOOLS | VERSION |
|-------:|---------|
| Python | 3.10 |
| Pytest | ^8.3.2 |
| Flake8 | 7.1.1 |


**Examples**

Generating json-files differences:
[![asciicast](https://asciinema.org/a/UF8VryWz6nQnKuSXniB5yx5Xl.svg)](https://asciinema.org/a/UF8VryWz6nQnKuSXniB5yx5Xl)

Generating yaml_files differences:
[![asciicast](https://asciinema.org/a/fdpkckdoZyPEGhISNgHkdtSJt.svg)](https://asciinema.org/a/fdpkckdoZyPEGhISNgHkdtSJt)
7 changes: 5 additions & 2 deletions gendiff/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@


def current_format(file):
if file[-4:] == 'json':
file_split = file.split('.')

if file_split[1] == 'json':
return 'json'
elif file[-4:] in ['yaml', 'yml']:
elif file_split[1] in ['yaml', 'yml']:
return 'yaml'



def parser(data, file_format):
if file_format == 'json':
return json.load(data)
Expand Down

0 comments on commit 850500e

Please sign in to comment.