Xqt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/289361

Change subject: [FEAT] Add EditingPageBot class
......................................................................

[FEAT] Add EditingPageBot class

Add a new CurrentPageBot class which only treats unlocked pages.

Change-Id: Id8886ab78f7066a29033004f40139217c0eb3b98
---
M pywikibot/bot.py
1 file changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/61/289361/1

diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 2788b86..37a64fa 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1727,6 +1727,24 @@
         super(CreatingPageBot, self).treat(page)
 
 
+class EditingPageBot(CurrentPageBot):
+
+    """A CurrentPageBot class which only treats unlocked pages."""
+
+    def treat(self, page):
+        """Treat page if it is not locked."""
+        if page.exists():
+            restrictions = page.getRestrictions()
+            if (restrictions and
+                    'edit' in restrictions and
+                    restrictions['edit'] and
+                    'sysop' in restrictions['edit']):
+                pywikibot.warning('Page "{0}" is locked by sysop.'
+                                  ''.format(page.title(asLink=True)))
+                return
+        super(EditingPageBot, self).treat(page)
+
+
 class RedirectPageBot(CurrentPageBot):
 
     """A RedirectPageBot class which only treats redirects."""

-- 
To view, visit https://gerrit.wikimedia.org/r/289361
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id8886ab78f7066a29033004f40139217c0eb3b98
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to