Skip to content

Commit 4604edd

Browse files
committed
Added continue functionality to page.get_query() #129
1 parent ff4c7c4 commit 4604edd

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

wptools/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _handle_continuations(self, response, cache_key):
122122
Select continue params and clear cache or last continue params
123123
"""
124124
rcontinue = response.get('continue')
125-
listen = ['blcontinue', 'cmcontinue']
125+
listen = ['blcontinue', 'cmcontinue', 'plcontinue']
126126
cparams = {}
127127

128128
if rcontinue:

wptools/page.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _query(self, action, qobj):
173173
if action == 'random':
174174
qstr = qobj.random()
175175
elif action == 'query':
176-
qstr = qobj.query(title, pageid)
176+
qstr = qobj.query(title, pageid, self._continue_params())
177177
elif action == 'querymore':
178178
qstr = qobj.querymore(title, pageid, self._continue_params())
179179
elif action == 'parse':
@@ -295,7 +295,7 @@ def _set_query_data(self, action='query'):
295295
data = self._load_response(action)
296296
page = data['query']['pages'][0]
297297

298-
self._handle_continuations(data, 'querymore')
298+
self._handle_continuations(data, action)
299299

300300
if action == 'query':
301301
self.data['random'] = data['query']['random'][0]["title"]
@@ -637,6 +637,9 @@ def get_query(self, show=True, proxy=None, timeout=0):
637637

638638
self._get('query', show, proxy, timeout)
639639

640+
while self.data.get('continue'):
641+
self._get('query', show, proxy, timeout)
642+
640643
return self
641644

642645
def get_querymore(self, show=True, proxy=None, timeout=0):

wptools/query.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def parse(self, title, pageid=None):
213213

214214
return qry
215215

216-
def query(self, titles, pageids=None):
216+
def query(self, titles, pageids=None, cparams=None):
217217
"""
218218
Returns MediaWiki action=query query string
219219
"""
@@ -226,6 +226,10 @@ def query(self, titles, pageids=None):
226226
if pageids and not titles:
227227
query = query.replace('&titles=', '&pageids=')
228228

229+
if cparams:
230+
query += cparams
231+
status += " (%s)" % cparams
232+
229233
if self.variant:
230234
query += '&variant=' + self.variant
231235

0 commit comments

Comments
 (0)