File tree Expand file tree Collapse file tree 11 files changed +67
-6
lines changed Expand file tree Collapse file tree 11 files changed +67
-6
lines changed Original file line number Diff line number Diff line change 11.venv /
22dist /
33__pycache__ /
4- gendiff1.cast
4+ gendiff1.cast
5+ gendiff2.cast
Original file line number Diff line number Diff line change 55[ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/88675eaf4e4ca1e04a88/maintainability )] ( https://codeclimate.com/github/ttehasi/python-project-50/maintainability )
66[ ![ Test Coverage] ( https://api.codeclimate.com/v1/badges/88675eaf4e4ca1e04a88/test_coverage )] ( https://codeclimate.com/github/ttehasi/python-project-50/test_coverage )
77
8- ## Asciinema:
8+ ## Asciinema JSON file :
99
1010[ ![ asciicast] ( https://asciinema.org/a/djCfDR2K0qTnGeiqy4hVWhLO9.svg )] ( https://asciinema.org/a/djCfDR2K0qTnGeiqy4hVWhLO9 )
1111
12+ ## Asciinema YAML file:
13+
14+ [ ![ asciicast] ( https://asciinema.org/a/H918cvPLQohe9DMY2NDxLKcaU.svg )] ( https://asciinema.org/a/H918cvPLQohe9DMY2NDxLKcaU )
15+
1216### Links
1317
1418This project was built using these tools:
Original file line number Diff line number Diff line change 11import json
22
3+ from gendiff .pars_yaml import open_ymlf
4+
35
46def open_f (path_to_file ) -> dict :
57 with open (path_to_file ) as file :
68 return json .load (file )
79
810
911def generate_diff (file1 , file2 ):
10- file1 = open_f (file1 )
11- file2 = open_f (file2 )
12+ if str (file1 )[- 5 :] == '.json' and str (file2 )[- 5 :] == '.json' :
13+ file1 = open_f (file1 )
14+ file2 = open_f (file2 )
15+ else :
16+ file1 = open_ymlf (file1 )
17+ file2 = open_ymlf (file2 )
1218 res = '''{
1319'''
1420 for i in sorted (list (file1 )):
Original file line number Diff line number Diff line change 1+ import yaml
2+
3+
4+ def open_ymlf (path ) -> dict :
5+ with open (path ) as file :
6+ return yaml .load (file , yaml .Loader )
7+
8+ print (open_ymlf ('/home/ttehasi/python-project-50/tests/test_data/file2.yml' ))
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ version = "0.1.0"
44description = " Add your description here"
55readme = " README.md"
66requires-python = " >=3.12"
7- dependencies = []
7+ dependencies = [
8+ " pyyaml>=6.0.2" ,
9+ ]
810
911[build-system ]
1012requires = [" hatchling" ]
Original file line number Diff line number Diff line change 1+ host : hexlet.io
2+ timeout : 50
3+ proxy : 123.234.53.22
4+ follow : false
Original file line number Diff line number Diff line change 1+ timeout : 20
2+ verbose : true
3+ host : hexlet.io
Original file line number Diff line number Diff line change @@ -15,4 +15,7 @@ def test_generate_diff():
1515 result = read_file ('result_file1_file2.txt' )
1616 actual = generate_diff (get_test_data_path ('file1.json' ),
1717 get_test_data_path ('file2.json' ))
18- assert actual == result
18+ yam_act = generate_diff (get_test_data_path ('file1.yml' ),
19+ get_test_data_path ('file2.yml' ))
20+ assert actual == result
21+ assert yam_act == result
You can’t perform that action at this time.
0 commit comments