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

Change subject: [bugfix] Fix botMayEdit logic
......................................................................

[bugfix] Fix botMayEdit logic

The warning was printed when there was a valid key but the value didn't match 
any skip condition.

Also, store calledModuleName() in a variable to save space (and a little time).

Change-Id: Ibfce75f9157dae8fb94255e109b222e82323ed04
---
M pywikibot/page/__init__.py
1 file changed, 16 insertions(+), 18 deletions(-)

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



diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index c6048e8..ccd8f41 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -1047,6 +1047,7 @@
             return True

         username = self.site.username()
+        module = pywikibot.calledModuleName()
         try:
             templates = self.templatesWithParams()
         except (NoPageError, IsRedirectPageError, SectionError):
@@ -1056,7 +1057,7 @@
         restrictions = set(self.site.get_edit_restricted_templates())

         # also add archive templates for non-archive bots
-        if pywikibot.calledModuleName() != 'archivebot':
+        if module != 'archivebot':
             restrictions.update(self.site.get_archived_page_templates())

         # multiple bots/nobots templates are allowed
@@ -1095,9 +1096,7 @@
                         'Edit declined' % key)
                     return False

-                if 'all' in names \
-                   or pywikibot.calledModuleName() in names \
-                   or username in names:
+                if 'all' in names or module in names or username in names:
                     return False

             if title == 'Bots':
@@ -1111,24 +1110,23 @@
                         '{{bots|%s=}} is not valid. Ignoring.' % key)
                     continue

-                if key == 'allow' and not ('all' in names
-                                           or username in names):
-                    return False
+                if key == 'allow':
+                    if not ('all' in names or username in names):
+                        return False

-                if key == 'deny' and ('all' in names or username in names):
-                    return False
+                elif key == 'deny':
+                    if 'all' in names or username in names:
+                        return False

-                if key == 'allowscript' \
-                   and not ('all' in names
-                            or pywikibot.calledModuleName() in names):
-                    return False
+                elif key == 'allowscript':
+                    if not ('all' in names or module in names):
+                        return False

-                if key == 'denyscript' \
-                   and ('all' in names
-                        or pywikibot.calledModuleName() in names):
-                    return False
+                elif key == 'denyscript':
+                    if 'all' in names or module in names:
+                        return False

-                if key:  # ignore unrecognized keys with a warning
+                elif key:  # ignore unrecognized keys with a warning
                     pywikibot.warning(
                         '{{bots|%s}} is not valid. Ignoring.' % params[0])


--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/697109
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: Ibfce75f9157dae8fb94255e109b222e82323ed04
Gerrit-Change-Number: 697109
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