jenkins-bot has submitted this change and it was merged. Change subject: [IMPROV] Request all tokens at once ......................................................................
[IMPROV] Request all tokens at once Prior to version 1.20 it wasn't requesting all tokens at once but each in a separate request. But the API actually allows to request all tokens at once. Change-Id: I91326d6a30269f617ba60d18079339832028da5b --- M pywikibot/site.py 1 file changed, 12 insertions(+), 14 deletions(-) Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/site.py b/pywikibot/site.py index c1fd08a..9e0c75a 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -2673,24 +2673,23 @@ if _version < MediaWikiVersion('1.20'): if all: types.extend(self.TOKENS_0) - for tokentype in self.validate_tokens(types): - # 'patrol' token is done later on. - if tokentype == 'patrol': - continue - query = api.PropertyGenerator('info', - titles='Dummy page', - intoken=tokentype, - site=self) - query.request._warning_handler = warn_handler + valid_tokens = set(self.validate_tokens(types)) + # don't request patrol + query = api.PropertyGenerator('info', + titles='Dummy page', + intoken=valid_tokens - set(['patrol']), + site=self) + query.request._warning_handler = warn_handler - for item in query: - pywikibot.debug(unicode(item), _logger) + for item in query: + pywikibot.debug(unicode(item), _logger) + for tokentype in valid_tokens: if (tokentype + 'token') in item: user_tokens[tokentype] = item[tokentype + 'token'] # patrol token require special handling. # TODO: try to catch exceptions? - if 'patrol' in types: + if 'patrol' in valid_tokens: if MediaWikiVersion('1.14') <= _version < MediaWikiVersion('1.17'): user_tokens['patrol'] = user_tokens['edit'] else: @@ -2707,8 +2706,7 @@ item = data['recentchanges'][0] pywikibot.debug(unicode(item), _logger) if 'patroltoken' in item: - user_tokens['patrol'] = item.get('patroltoken') - + user_tokens['patrol'] = item['patroltoken'] else: if _version < MediaWikiVersion('1.24wmf19'): if all is not False: -- To view, visit https://gerrit.wikimedia.org/r/184125 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I91326d6a30269f617ba60d18079339832028da5b Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: XZise <commodorefabia...@gmx.de> Gerrit-Reviewer: John Vandenberg <jay...@gmail.com> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl> Gerrit-Reviewer: Mpaa <mpaa.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits