Browse Source

Support new method for query continuation.

tags/v0.2
Ben Kurtovic 10 years ago
parent
commit
07bbf240f6
1 changed files with 4 additions and 5 deletions
  1. +4
    -5
      earwigbot/wiki/category.py

+ 4
- 5
earwigbot/wiki/category.py View File

@@ -65,7 +65,7 @@ class Category(Page):
def _get_members_via_api(self, limit, follow): def _get_members_via_api(self, limit, follow):
"""Iterate over Pages in the category using the API.""" """Iterate over Pages in the category using the API."""
params = {"action": "query", "list": "categorymembers", params = {"action": "query", "list": "categorymembers",
"cmtitle": self.title}
"cmtitle": self.title, "continue": ""}


while 1: while 1:
params["cmlimit"] = limit if limit else "max" params["cmlimit"] = limit if limit else "max"
@@ -74,9 +74,8 @@ class Category(Page):
title = member["title"] title = member["title"]
yield self.site.get_page(title, follow_redirects=follow) yield self.site.get_page(title, follow_redirects=follow)


if "query-continue" in result:
qcontinue = result["query-continue"]["categorymembers"]
params["cmcontinue"] = qcontinue["cmcontinue"]
if "continue" in result:
params.update(result["continue"])
if limit: if limit:
limit -= len(result["query"]["categorymembers"]) limit -= len(result["query"]["categorymembers"])
else: else:
@@ -104,7 +103,7 @@ class Category(Page):
else: # Avoid doing a silly (albeit valid) ":Pagename" thing else: # Avoid doing a silly (albeit valid) ":Pagename" thing
title = base title = base
yield self.site.get_page(title, follow_redirects=follow, yield self.site.get_page(title, follow_redirects=follow,
pageid=row[2])
pageid=row[2])


def _get_size_via_api(self, member_type): def _get_size_via_api(self, member_type):
"""Return the size of the category using the API.""" """Return the size of the category using the API."""


Loading…
Cancel
Save