From 69d581840bb2e21155c3125025b5cc46a416a30f Mon Sep 17 00:00:00 2001 From: Spooghetti420 Date: Thu, 3 Aug 2023 22:37:15 +0100 Subject: [PATCH] Don't add anagrams where normalised(title) == normalised(anagram) --- english-anagrams/en-anagrams.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/english-anagrams/en-anagrams.py b/english-anagrams/en-anagrams.py index 7795163..63d1874 100644 --- a/english-anagrams/en-anagrams.py +++ b/english-anagrams/en-anagrams.py @@ -156,7 +156,7 @@ def update_page(title: str, alphagram: str) -> bool: create_diff(page.text, page) - anagrams_to_add = anagrams[alphagram] - {title} + anagrams_to_add = anagrams[alphagram] - {title} - {ana for ana in anagrams[alphagram] if normalise(ana) == normalise(title)} new_content, added_anagrams = add_anagrams(page.text, anagrams_to_add, alphagram) new_content = re.sub("\n{3,}", "\n\n", new_content) @@ -165,7 +165,7 @@ def update_page(title: str, alphagram: str) -> bool: return False else: page.text = new_content - plural_s = "s" if len(anagrams_to_add) > 1 else "" + plural_s = "s" if len(added_anagrams) > 1 else "" exist_other_sections = len(mwparserfromhell.parse(page.text).get_sections([2])) > 1 page.save(f"Added anagram{plural_s} ({', '.join(added_anagrams)}){' to English section' if exist_other_sections else ''}", minor=False) return True