Skip to content

Commit 65bbe76

Browse files
committed
update stylish-formater
1 parent ed77855 commit 65bbe76

File tree

3 files changed

+11
-34
lines changed

3 files changed

+11
-34
lines changed

gendiff/gen_diff_stylish.py

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,18 @@ def gen_diff_stylish(value, lvl=1):
2525
res += f'{' ' * lvl}{el}: '
2626
res += gen_diff_stylish(val[1], lvl + 1) + '\n'
2727
case 'unchanged':
28-
if val[1] == '':
29-
res += (f'{' ' * lvl}{el}:'
30-
f'{stringify(val[1], lvl=lvl + 1)}') + '\n'
31-
else:
32-
res += (f'{' ' * lvl}{el}:'
33-
f' {stringify(val[1], lvl=lvl + 1)}') + '\n'
28+
res += (f'{' ' * lvl}{el}:'
29+
f' {stringify(val[1], lvl=lvl + 1)}') + '\n'
3430
case 'added':
35-
if val[1] == '':
36-
res += (f'{' ' * (lvl - 1) + ' + '}{el}:'
37-
f'{stringify(val[1], lvl=lvl + 1)}') + '\n'
38-
else:
39-
res += (f'{' ' * (lvl - 1) + ' + '}{el}:'
40-
f' {stringify(val[1], lvl=lvl + 1)}') + '\n'
31+
res += (f'{' ' * (lvl - 1) + ' + '}{el}:'
32+
f' {stringify(val[1], lvl=lvl + 1)}') + '\n'
4133
case 'removed':
42-
if val[1] == '':
43-
res += (f'{' ' * (lvl - 1) + ' - '}{el}:'
44-
f'{stringify(val[1], lvl=lvl + 1)}') + '\n'
45-
else:
46-
res += (f'{' ' * (lvl - 1) + ' - '}{el}:'
47-
f' {stringify(val[1], lvl=lvl + 1)}') + '\n'
34+
res += (f'{' ' * (lvl - 1) + ' - '}{el}:'
35+
f' {stringify(val[1], lvl=lvl + 1)}') + '\n'
4836
case 'changed':
49-
if val[1] == '':
50-
res += (f'{' ' * (lvl - 1) + ' - '}{el}:'
51-
f'{stringify(val[1], lvl=lvl + 1)}') + '\n'
52-
res += (f'{' ' * (lvl - 1) + ' + '}{el}:'
53-
f' {stringify(val[2], lvl=lvl + 1)}') + '\n'
54-
elif val[2] == '':
55-
res += (f'{' ' * (lvl - 1) + ' - '}{el}:'
56-
f' {stringify(val[1], lvl=lvl + 1)}') + '\n'
57-
res += (f'{' ' * (lvl - 1) + ' + '}{el}:'
58-
f'{stringify(val[2], lvl=lvl + 1)}') + '\n'
59-
else:
60-
res += (f'{' ' * (lvl - 1) + ' - '}{el}:'
61-
f' {stringify(val[1], lvl=lvl + 1)}') + '\n'
62-
res += (f'{' ' * (lvl - 1) + ' + '}{el}:'
63-
f' {stringify(val[2], lvl=lvl + 1)}') + '\n'
37+
res += (f'{' ' * (lvl - 1) + ' - '}{el}:'
38+
f' {stringify(val[1], lvl=lvl + 1)}') + '\n'
39+
res += (f'{' ' * (lvl - 1) + ' + '}{el}:'
40+
f' {stringify(val[2], lvl=lvl + 1)}') + '\n'
6441
res += ' ' * (lvl - 1) + '}'
6542
return res

tests/test_generate_diff_recurs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
def test_generate_diff():
6-
result = read_file('result_file11_file22.txt')
6+
result = read_file('result_file11_file22.cpp')
77
actual = generate_diff(str(get_test_data_path('file11.json')),
88
str(get_test_data_path('file22.json')))
99
yam_act = generate_diff(str(get_test_data_path('file11.yml')),

0 commit comments

Comments
 (0)