Skip to content

Commit f6e8b59

Browse files
committed
dop chenches
1 parent acaf29f commit f6e8b59

File tree

7 files changed

+22
-15
lines changed

7 files changed

+22
-15
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
dist/
33
__pycache__/
44
gendiff1.cast
5-
gendiff2.cast
5+
gendiff2.cast
6+
gendiff11.cast
7+
gendiff22.cast

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99

1010
[![asciicast](https://asciinema.org/a/djCfDR2K0qTnGeiqy4hVWhLO9.svg)](https://asciinema.org/a/djCfDR2K0qTnGeiqy4hVWhLO9)
1111

12+
[![asciicast](https://asciinema.org/a/mkiLw1Llc4brT2wrSHaMW7H4T.svg)](https://asciinema.org/a/mkiLw1Llc4brT2wrSHaMW7H4T)
13+
1214
## Asciinema YAML file:
1315

1416
[![asciicast](https://asciinema.org/a/H918cvPLQohe9DMY2NDxLKcaU.svg)](https://asciinema.org/a/H918cvPLQohe9DMY2NDxLKcaU)
1517

18+
[![asciicast](https://asciinema.org/a/eqSYOXkzxMhXXDIPTiRrzoWmN.svg)](https://asciinema.org/a/eqSYOXkzxMhXXDIPTiRrzoWmN)
19+
1620
### Links
1721

1822
This project was built using these tools:

gendiff/gen_diff.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ def stringify(value, lvl=1):
2727
return result
2828

2929

30-
def generate_diff(file1, file2, lvl=1):
30+
def generate_diff(file1, file2, lvl=1, format_name='stylish'):
3131
if isinstance(file1, str) and isinstance(file2, str):
3232
if str(file1)[-5:] == '.json' and str(file2)[-5:] == '.json':
3333
file1 = open_f(file1)
3434
file2 = open_f(file2)
3535
else:
3636
file1 = open_ymlf(file1)
3737
file2 = open_ymlf(file2)
38-
result = '{\n'
38+
result = ''
3939
if isinstance(file1, dict) and isinstance(file2, dict):
40+
result += '{\n'
4041
keys1 = sorted(list(file1.keys()))
4142
keys2 = sorted(list(file2.keys()))
4243
keys12 = sorted(set(keys1 + keys2))

tests/test_data/result_file11_file22.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
common: {
3-
+ follow: False
3+
+ follow: false
44
setting1: Value 1
55
- setting2: 200
6-
- setting3: True
6+
- setting3: true
77
+ setting3: null
88
+ setting4: blah blah
99
+ setting5: {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
- follow: False
2+
- follow: false
33
host: hexlet.io
44
- proxy: 123.234.53.22
55
- timeout: 50
66
+ timeout: 20
7-
+ verbose: True
7+
+ verbose: true
88
}

tests/test_generate_diff.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def read_file(filename):
1313

1414
def test_generate_diff():
1515
result = read_file('result_file1_file2.txt')
16-
actual = generate_diff(get_test_data_path('file1.json'),
17-
get_test_data_path('file2.json'))
18-
yam_act = generate_diff(get_test_data_path('file1.yml'),
19-
get_test_data_path('file2.yml'))
16+
actual = generate_diff(str(get_test_data_path('file1.json')),
17+
str(get_test_data_path('file2.json')))
18+
yam_act = generate_diff(str(get_test_data_path('file1.yml')),
19+
str(get_test_data_path('file2.yml')))
2020
assert actual == result
2121
assert yam_act == result

tests/test_generate_diff_recurs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
def test_generate_diff():
66
result = read_file('result_file11_file22.txt')
7-
actual = generate_diff(get_test_data_path('file11.json'),
8-
get_test_data_path('file22.json'))
9-
yam_act = generate_diff(get_test_data_path('file11.yml'),
10-
get_test_data_path('file22.yml'))
7+
actual = generate_diff(str(get_test_data_path('file11.json')),
8+
str(get_test_data_path('file22.json')))
9+
yam_act = generate_diff(str(get_test_data_path('file11.yml')),
10+
str(get_test_data_path('file22.yml')))
1111
assert actual == result
1212
assert yam_act == result

0 commit comments

Comments
 (0)