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. + -unprotect Acts 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 <zhuyifei1...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits