mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Adjust codestyle
running flake8, black and reorder-python-imports.
This commit is contained in:
parent
b3bee77c17
commit
61edfc090e
1 changed files with 25 additions and 16 deletions
|
|
@ -16,16 +16,17 @@ SPDX-License-Identifier: BSD-3-Clause
|
|||
SPDX-FileCopyrightText: 2021 Intevation GmbH <https://intevation.de>
|
||||
Author: <bernhard.reiter@intevation.de>
|
||||
"""
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
KDIALOG = "/usr/bin/kdialog"
|
||||
|
||||
SUMMARY_PATTERN = re.compile("^(SUMMARY:.*)$", re.MULTILINE)
|
||||
|
||||
def get_summary(icalendar_text:str):
|
||||
|
||||
def get_summary(icalendar_text: str):
|
||||
"""Get the first SUMMARY: line from an iCalendar text.
|
||||
|
||||
Do not care about the line being continued.
|
||||
|
|
@ -38,30 +39,38 @@ def main(ical1_filename, ical2_filename):
|
|||
ical1 = ical1_filename.read_text()
|
||||
ical2 = ical2_filename.read_text()
|
||||
|
||||
additional_args = ["--yes-label", "take first"] # return code == 0
|
||||
additional_args += ["--no-label", "take second"] # return code == 1
|
||||
additional_args += ["--cancel-label", "do not resolve"] # return code == 2
|
||||
additional_args = ["--yes-label", "take first"] # return code == 0
|
||||
additional_args += ["--no-label", "take second"] # return code == 1
|
||||
additional_args += ["--cancel-label", "do not resolve"] # return code == 2
|
||||
|
||||
r = subprocess.run(args = [
|
||||
KDIALOG,
|
||||
"--warningyesnocancel",
|
||||
"There was a sync conflict, do you prefer the first entry: \n" +
|
||||
get_summary(ical1) + "...\n(full contents: " + str(ical1_filename) +
|
||||
" )\n\nor the second entry: \n" +
|
||||
get_summary(ical2) + "...\n(full contents: " + str(ical2_filename) +
|
||||
" )?"
|
||||
] + additional_args)
|
||||
r = subprocess.run(
|
||||
args=[
|
||||
KDIALOG,
|
||||
"--warningyesnocancel",
|
||||
"There was a sync conflict, do you prefer the first entry: \n"
|
||||
+ get_summary(ical1)
|
||||
+ "...\n(full contents: "
|
||||
+ str(ical1_filename)
|
||||
+ " )\n\nor the second entry: \n"
|
||||
+ get_summary(ical2)
|
||||
+ "...\n(full contents: "
|
||||
+ str(ical2_filename)
|
||||
+ " )?",
|
||||
]
|
||||
+ additional_args
|
||||
)
|
||||
|
||||
if r.returncode == 2:
|
||||
# cancel was pressed
|
||||
return # shall lead to items not changed, because not copied
|
||||
return # shall lead to items not changed, because not copied
|
||||
|
||||
if r.returncode == 0:
|
||||
# we want to take the first item, so overwrite the second
|
||||
ical2_filename.write_text(ical1)
|
||||
else: # r.returncode == 1, we want the second item, so overwrite the first
|
||||
else: # r.returncode == 1, we want the second item, so overwrite the first
|
||||
ical1_filename.write_text(ical2)
|
||||
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
sys.stdout.write(__doc__)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue