Skip to content

Commit

Permalink
fix(pikspect): update templates for pacman questions about package co…
Browse files Browse the repository at this point in the history
…nflicts
  • Loading branch information
actionless committed Sep 18, 2024
1 parent c25d9cb commit 00f6846
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions pikaur/pikspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,11 @@ def check_questions(self) -> None:

for answer, questions in self.default_questions.items():
for question in questions:
file_debug("question", question)
if not _match(question, historic_output):
continue
logger.debug("Found right answer to `{}`: `{}`", question, answer)
file_debug("Found right answer to `{}`: `{}`", question, answer)
self.next_answers.append(answer)
clear_buffer = True
break
Expand Down Expand Up @@ -478,23 +480,27 @@ def pikspect(
format_pacman_question("Do you want to remove these packages?"),
]
questions_conflict = format_pacman_question(
"%s and %s are in conflict. Remove %s?", YesNo.QUESTION_YN_NO,
".* %s-.* and %s-.* are in conflict. Remove %s?", YesNo.QUESTION_YN_NO,
)
questions_conflict_via_provided = format_pacman_question(
"%s and %s are in conflict (%s). Remove %s?", YesNo.QUESTION_YN_NO,
".* %s-.* and %s-.* are in conflict (%s). Remove %s?", YesNo.QUESTION_YN_NO,
)

def format_conflicts(conflicts: list[list[str]]) -> list[str]:
return [
questions_conflict % (new_pkg, old_pkg, old_pkg)
for new_pkg, old_pkg in conflicts
] + [
(
re.escape(questions_conflict_via_provided % (
re.escape(question).replace(r"\.\*", ".*")
for question in
[
questions_conflict % (
new_pkg, old_pkg, old_pkg,
)
for new_pkg, old_pkg in conflicts
] + [
questions_conflict_via_provided % (
new_pkg, old_pkg, ".*", old_pkg,
))
).replace(r"\.\*", ".*")
for new_pkg, old_pkg in conflicts
)
for new_pkg, old_pkg in conflicts
]
]

default_questions: dict[str, list[str]] = {}
Expand Down

0 comments on commit 00f6846

Please sign in to comment.