jenkins-bot has submitted this change and it was merged.
Change subject: (bug 55193) Missing key in ['query-continue'] value
......................................................................
(bug 55193) Missing key in ['query-continue'] value
Handling of multiple query-continue values.
https://bugzilla.wikimedia.org/show_bug.cgi?id=55193
Change-Id: I3941fca0daef38221f7ffe04e034c11cdaf6fe17
---
M pywikibot/data/api.py
1 file changed, 20 insertions(+), 11 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 043cc52..1dbd5ac 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -525,9 +525,16 @@
self.resultkey = "pages" # name of the "query"
subelement key
else: # to look for when iterating
self.resultkey = self.module
- self.continuekey = self.module # usually the query-continue key
- # is the same as the querymodule,
- # but not always
+
+ # usually the query-continue key is the same as the querymodule,
+ # but not always
+ # API can return more than one query-continue key, if multiple properties
+ # are requested by the query, e.g.
+ # "query-continue":{
+ # "langlinks":{"llcontinue":"12188973|pt"},
+ #
"templates":{"tlcontinue":"310820|828|Namespace_detect"}}
+ # self.continuekey is a list
+ self.continuekey = self.module.split('|')
@property
def __modules(self):
@@ -720,17 +727,19 @@
continue
if not "query-continue" in self.data:
return
- if not self.continuekey in self.data["query-continue"]:
+ if all(key not in self.data["query-continue"] for key in
self.continuekey):
pywikibot.log(
- u"Missing '%s' key in ['query-continue']
value."
+ u"Missing '%s' key(s) in ['query-continue']
value."
% self.continuekey)
return
- update = self.data["query-continue"][self.continuekey]
- for key, value in update.items():
- # query-continue can return ints
- if isinstance(value, int):
- value = str(value)
- self.request[key] = value
+ query_continue_pairs = self.data["query-continue"].values()
+ for query_continue_pair in query_continue_pairs:
+ for key, value in query_continue_pair.items():
+ # query-continue can return ints
+ if isinstance(value, int):
+ value = str(value)
+ self.request[key] = value
+
del self.data # a new request with query-continue is needed
def result(self, data):
--
To view, visit
https://gerrit.wikimedia.org/r/105975
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3941fca0daef38221f7ffe04e034c11cdaf6fe17
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Yurik <yurik(a)wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>