XZise has uploaded a new change for review.
https://gerrit.wikimedia.org/r/180779
Change subject: [FIX] QueryGenerator: Allow missing 'query' entry
......................................................................
[FIX] QueryGenerator: Allow missing 'query' entry
The QueryGenerator stopped when the result didn't contain a 'query'
entry. If the result doesn't contain anything yet (but needs to be
continued) it's not returning a 'query' entry when used with the
'generator' API feature.
Instead of stopping the iteration when there is not 'query' entry it's
just stopping the iteration if there is no continuation provided.
Bug: T84860
Change-Id: I1f8c4986d69be18134987c951fd65237300e277e
---
M pywikibot/data/api.py
1 file changed, 6 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/79/180779/1
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 04420c2..864e0ea 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1483,14 +1483,7 @@
% self.__class__.__name__,
_logger)
return
- if "query" not in self.data:
- pywikibot.debug(
- u"%s: stopped iteration because 'query' not found in api "
- u"response." % self.__class__.__name__,
- _logger)
- pywikibot.debug(unicode(self.data), _logger)
- return
- if self.resultkey in self.data["query"]:
+ if 'query' in self.data and self.resultkey in self.data["query"]:
resultdata = self.data["query"][self.resultkey]
if isinstance(resultdata, dict):
pywikibot.debug(u"%s received %s; limit=%s"
@@ -1538,6 +1531,11 @@
# self.resultkey in data in last request.submit()
previous_result_had_data = True
else:
+ if 'query' not in self.data:
+ pywikibot.debug("%s: 'query' not found in api response." %
+ self.__class__.__name__,
+ _logger)
+ pywikibot.debug(unicode(self.data), _logger)
# if (query-)continue is present, self.resultkey might not have
# been fetched yet
if self.continue_name not in self.data:
--
To view, visit https://gerrit.wikimedia.org/r/180779
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1f8c4986d69be18134987c951fd65237300e277e
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits