Skip to content

Commit 61edfc0

Browse files
Adjust codestyle
running flake8, black and reorder-python-imports.
1 parent b3bee77 commit 61edfc0

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

contrib/conflict_resolution/resolve_interactively.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
SPDX-FileCopyrightText: 2021 Intevation GmbH <https://intevation.de>
1717
1818
"""
19-
from pathlib import Path
2019
import re
2120
import subprocess
2221
import sys
22+
from pathlib import Path
2323

2424
KDIALOG = "/usr/bin/kdialog"
2525

2626
SUMMARY_PATTERN = re.compile("^(SUMMARY:.*)$", re.MULTILINE)
2727

28-
def get_summary(icalendar_text:str):
28+
29+
def get_summary(icalendar_text: str):
2930
"""Get the first SUMMARY: line from an iCalendar text.
3031
3132
Do not care about the line being continued.
@@ -38,30 +39,38 @@ def main(ical1_filename, ical2_filename):
3839
ical1 = ical1_filename.read_text()
3940
ical2 = ical2_filename.read_text()
4041

41-
additional_args = ["--yes-label", "take first"] # return code == 0
42-
additional_args += ["--no-label", "take second"] # return code == 1
43-
additional_args += ["--cancel-label", "do not resolve"] # return code == 2
44-
45-
r = subprocess.run(args = [
46-
KDIALOG,
47-
"--warningyesnocancel",
48-
"There was a sync conflict, do you prefer the first entry: \n" +
49-
get_summary(ical1) + "...\n(full contents: " + str(ical1_filename) +
50-
" )\n\nor the second entry: \n" +
51-
get_summary(ical2) + "...\n(full contents: " + str(ical2_filename) +
52-
" )?"
53-
] + additional_args)
42+
additional_args = ["--yes-label", "take first"] # return code == 0
43+
additional_args += ["--no-label", "take second"] # return code == 1
44+
additional_args += ["--cancel-label", "do not resolve"] # return code == 2
45+
46+
r = subprocess.run(
47+
args=[
48+
KDIALOG,
49+
"--warningyesnocancel",
50+
"There was a sync conflict, do you prefer the first entry: \n"
51+
+ get_summary(ical1)
52+
+ "...\n(full contents: "
53+
+ str(ical1_filename)
54+
+ " )\n\nor the second entry: \n"
55+
+ get_summary(ical2)
56+
+ "...\n(full contents: "
57+
+ str(ical2_filename)
58+
+ " )?",
59+
]
60+
+ additional_args
61+
)
5462

5563
if r.returncode == 2:
5664
# cancel was pressed
57-
return # shall lead to items not changed, because not copied
65+
return # shall lead to items not changed, because not copied
5866

5967
if r.returncode == 0:
6068
# we want to take the first item, so overwrite the second
6169
ical2_filename.write_text(ical1)
62-
else: # r.returncode == 1, we want the second item, so overwrite the first
70+
else: # r.returncode == 1, we want the second item, so overwrite the first
6371
ical1_filename.write_text(ical2)
6472

73+
6574
if len(sys.argv) != 3:
6675
sys.stdout.write(__doc__)
6776
else:

0 commit comments

Comments
 (0)