jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/494677 )
Change subject: [IMPR] use site.watch() when calling site.watchpage() ......................................................................
[IMPR] use site.watch() when calling site.watchpage()
- use site.watch() when calling site.watchpage() and remove code duplication. - self.watchpage is old enough to ommit the detailed api response. site.watch should be used in that case which raises a KeyError in such case.
Change-Id: I1143f0a8fa5c409760a656f154f28b79ad2ece94 --- M pywikibot/site.py 1 file changed, 7 insertions(+), 10 deletions(-)
Approvals: Huji: Looks good to me, approved D3r1ck01: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index ffa45da..36ba13c 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -6082,6 +6082,7 @@ if False add them (default). @return: True if API returned expected response; False otherwise @rtype: bool + @raises KeyError: 'watch' isn't in API response
""" parameters = {'action': 'watch', @@ -6125,16 +6126,12 @@ @rtype: bool
""" - parameters = {'action': 'watch', - 'title': page, - 'token': self.tokens['watch'], - 'unwatch': unwatch} - req = self._simple_request(**parameters) - result = req.submit() - if 'watch' not in result: - pywikibot.error('watchpage: Unexpected API response:\n%s' % result) - return False - return ('unwatched' if unwatch else 'watched') in result['watch'] + try: + result = self.watch(page, unwatch) + except KeyError: + pywikibot.error('watchpage: Unexpected API response') + result = False + return result
@must_be(group='user') def purgepages(
pywikibot-commits@lists.wikimedia.org