jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1022503?usp=email )

Change subject: [IMPR] Respect 'text-contains' from fixes dictionaries
......................................................................

[IMPR] Respect 'text-contains' from fixes dictionaries

They were completely ignored, despite being documented.

Bug: T142324
Change-Id: I417e3c52c79346797ad62bfff1609f7be7d6b46b
---
M scripts/replace.py
1 file changed, 12 insertions(+), 4 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/scripts/replace.py b/scripts/replace.py
index 0302473..5a809f4 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -575,11 +575,14 @@
                     return True
         return False

-    def isTextExcepted(self, original_text) -> bool:
+    def isTextExcepted(self, text, exceptions=None) -> bool:
         """Return True iff one of the exceptions applies for the given text."""
-        if 'text-contains' in self.exceptions:
-            return any(exc.search(original_text)
-                       for exc in self.exceptions['text-contains'])
+        if exceptions is None:
+            exceptions = self.exceptions
+
+        if 'text-contains' in exceptions:
+            return any(exc.search(text) for exc in exceptions['text-contains'])
+
         return False

     def apply_replacements(self, original_text, applied, page=None):
@@ -601,6 +604,7 @@
             if (replacement.container
                     and replacement.container.name in skipped_containers):
                 continue
+
             if page is not None and self.isTitleExcepted(
                     page.title(), replacement.exceptions):
                 if replacement.container:
@@ -616,6 +620,10 @@
                         'the title is on the exceptions list.'.format(
                             replacement.description, page.title(as_link=True)))
                 continue
+
+            if self.isTextExcepted(original_text, replacement.exceptions):
+                continue
+
             old_text = new_text
             new_text = textlib.replaceExcept(
                 new_text, replacement.old_regex, replacement.new,

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1022503?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I417e3c52c79346797ad62bfff1609f7be7d6b46b
Gerrit-Change-Number: 1022503
Gerrit-PatchSet: 3
Gerrit-Owner: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to