jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/628344 )

Change subject: [IMPR] Simplify understandBlock in blockpageschecker.py
......................................................................

[IMPR] Simplify understandBlock in blockpageschecker.py

Change-Id: Ib11562bdaf0dc08238bf62572080d85b91943c6b
---
M scripts/blockpageschecker.py
1 file changed, 7 insertions(+), 15 deletions(-)

Approvals:
  Hazard-SJ: Looks good to me, but someone else must approve
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py
index 85b5cbf..e76277b 100755
--- a/scripts/blockpageschecker.py
+++ b/scripts/blockpageschecker.py
@@ -45,8 +45,6 @@
 #
 # Distributed under the terms of the MIT license.
 #
-from __future__ import absolute_import, division, unicode_literals
-
 import re
 import time
 import webbrowser
@@ -165,21 +163,15 @@
 
 def understandBlock(text, TTP, TSP, TSMP, TTMP, TU):
     """Understand if the page is blocked and if it has the right template."""
-    if TTP:
-        for catchRegex in TTP:  # TTP = templateTotalProtection
+    results = 'sysop-total', 'autoconfirmed-total', 'unique'
+    for index, template in enumerate((TTP, TSP, TU)):
+        if not template:
+            continue
+        for catchRegex in template:
             resultCatch = re.findall(catchRegex, text)
             if resultCatch:
-                return ('sysop-total', catchRegex)
-    if TSP:
-        for catchRegex in TSP:
-            resultCatch = re.findall(catchRegex, text)
-            if resultCatch:
-                return ('autoconfirmed-total', catchRegex)
-    if TU:
-        for catchRegex in TU:
-            resultCatch = re.findall(catchRegex, text)
-            if resultCatch:
-                return ('unique', catchRegex)
+                return results[index], catchRegex
+
     if TSMP and TTMP and TTP != TTMP and TSP != TSMP:
         for catchRegex in TTMP:
             resultCatch = re.findall(catchRegex, text)

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/628344
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: Ib11562bdaf0dc08238bf62572080d85b91943c6b
Gerrit-Change-Number: 628344
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Hazard-SJ <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to