[MediaWiki-commits] [Gerrit] pywikibot/core[master]: protect.py: Add expiry parameter

2018-01-01 Thread jenkins-bot (Code Review)
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
+
 -unprotectActs 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 
Gerrit-Reviewer: Framawiki 
Gerrit-Reviewer: John Vandenberg 
Gerrit-Reviewer: Mpaa 
Gerrit-Reviewer: Xqt 
Gerrit-Reviewer: Zhuyifei1999 
Gerrit-Reviewer: Zoranzoki21 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] pywikibot/core[master]: protect.py: Add expiry parameter

2017-12-29 Thread Zhuyifei1999 (Code Review)
Zhuyifei1999 has uploaded a new change for review. ( 
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, 12 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/77/400977/1

diff --git a/scripts/protect.py b/scripts/protect.py
index 92d5934..790b02a 100755
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -16,6 +16,10 @@
   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.
+
 -unprotectActs like "default:all"
 
 -default: Sets the default protection level (default 'sysop'). If no
@@ -84,6 +88,7 @@
 """
 self.availableOptions.update({
 'summary': None,
+'expiry': None,
 })
 super(ProtectionRobot, self).__init__(site=site, **kwargs)
 self.generator = generator
@@ -104,6 +109,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 +183,12 @@
 options['summary'] = None
 else:
 options['summary'] = arg[len('-summary:'):]
+elif arg.startswith('-expiry'):
+if len(arg) == len('-expiry'):
+options['expiry'] = pywikibot.input(
+u'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: newchange
Gerrit-Change-Id: I486b5b140c46460048d55d14e1be3309dc7e1744
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Zhuyifei1999 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits