jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/400977 )
Change subject: protect.py: Add expiry parameter
......................................................................
protect.py: Add expiry parameter
If the paramater is unset, use None, meaning indefinite and protection
will not expire automatically. If '-expiry' is set but the value is
unspecified, the script will prompt with pywikibot.input(). The value,
either specified directly or in by the prompt, will be passes to
page.protect(), which will then pass it on to site.protect().
Bug: T183796
Change-Id: I486b5b140c46460048d55d14e1be3309dc7e1744
---
M scripts/protect.py
1 file changed, 13 insertions(+), 0 deletions(-)
Approvals:
Framawiki: Looks good to me, but someone else must approve
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/protect.py b/scripts/protect.py
index 92d5934..47f7551 100755
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -16,6 +16,11 @@
the page selector. If no summary is supplied or couldn't
determine one from the selector it'll ask for one.
+-expiry: Supply a custom protection expiry, which defaults to
+ indefinite. Any string understandable by MediaWiki, including
+ relative and absolute, is acceptable. See:
+
https://www.mediawiki.org/wiki/API:Protect#Parameters
+
-unprotect Acts like "default:all"
-default: Sets the default protection level (default 'sysop'). If no
@@ -84,6 +89,7 @@
"""
self.availableOptions.update({
'summary': None,
+ 'expiry': None,
})
super(ProtectionRobot, self).__init__(site=site, **kwargs)
self.generator = generator
@@ -104,6 +110,7 @@
protections = dict(
prot for prot in self.protections.items() if prot[0] in applicable)
page.protect(reason=self.getOption('summary'),
+ expiry=self.getOption('expiry'),
protections=protections)
@@ -177,6 +184,12 @@
options['summary'] = None
else:
options['summary'] = arg[len('-summary:'):]
+ elif arg.startswith('-expiry'):
+ if len(arg) == len('-expiry'):
+ options['expiry'] = pywikibot.input(
+ 'Enter a protection expiry:')
+ else:
+ options['expiry'] = arg[len('-expiry:'):]
elif arg.startswith('-images'):
pywikibot.output(color_format(
'\n{lightred}-image option is deprecated. '
--
To view, visit
https://gerrit.wikimedia.org/r/400977
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I486b5b140c46460048d55d14e1be3309dc7e1744
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>