jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] Site: blockuser's expiry supports datetime and False ......................................................................
[FEAT] Site: blockuser's expiry supports datetime and False
As it already support timestamps the addition of normal datetimes is not that far fetched. It also supports 'False' as an alias for 'never' so scripts are independent of the API and only pywikibot needs to use the actual API value.
This also adds the documentation for this function.
Change-Id: I352d155cea0d251f35d27e887bbc84e6ee83d549 --- M pywikibot/site.py 1 file changed, 33 insertions(+), 0 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index c4cd53d..626a8ee 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -4396,8 +4396,41 @@ @must_be(group='sysop') def blockuser(self, user, expiry, reason, anononly=True, nocreate=True, autoblock=True, noemail=False, reblock=False): + """ + Block a user for certain amount of time and for a certain reason.
+ @param user: The username/IP to be blocked without a namespace. + @type user: User + @param expiry: The length or date/time when the block expires. If + 'never', 'infinite', 'indefinite' it never does. If the value is + given as a basestring it's parsed by php's strtotime function: + http://php.net/manual/en/function.strtotime.php + The relative format is described there: + http://php.net/manual/en/datetime.formats.relative.php + It is recommended to not use a basestring if possible to be + independent of the API. + @type expiry: Timestamp/datetime (absolute), + basestring (relative/absolute) or False ('never') + @param reason: The reason for the block. + @type reason: basestring + @param anononly: Disable anonymous edits for this IP. + @type anononly: boolean + @param nocreate: Prevent account creation. + @type nocreate: boolean + @param autoblock: Automatically block the last used IP address and all + subsequent IP addresses from which this account logs in. + @type autoblock: boolean + @param noemail: Prevent user from sending email through the wiki. + @type noemail: boolean + @param reblock: If the user is already blocked, overwrite the existing + block. + @type reblock: boolean + @return: The data retrieved from the API request. + @rtype: dict + """ token = self.tokens['block'] + if expiry is False: + expiry = 'never' req = api.Request(site=self, action='block', user=user.username, expiry=expiry, reason=reason, token=token) if anononly:
pywikibot-commits@lists.wikimedia.org