[Pywikipedia-l] SVN: [5361] branches/rewrite/pywikibot

russblau at svn.wikimedia.org russblau at svn.wikimedia.org
Mon May 12 20:37:06 UTC 2008


Revision: 5361
Author:   russblau
Date:     2008-05-12 20:37:06 +0000 (Mon, 12 May 2008)

Log Message:
-----------
improve handling of limit parameter

Modified Paths:
--------------
    branches/rewrite/pywikibot/data/api.py
    branches/rewrite/pywikibot/site.py

Modified: branches/rewrite/pywikibot/data/api.py
===================================================================
--- branches/rewrite/pywikibot/data/api.py	2008-05-12 20:33:47 UTC (rev 5360)
+++ branches/rewrite/pywikibot/data/api.py	2008-05-12 20:37:06 UTC (rev 5361)
@@ -242,7 +242,8 @@
     and use the query-continue element, if present, to continue iterating as
     long as the wiki returns additional values.  However, if the iterator's
     limit attribute is set to a positive int, the iterator will stop after
-    iterating that many values.
+    iterating that many values. If limit is negative, the limit parameter
+    will not be passed to the API at all.
 
     """
     def __init__(self, **kwargs):
@@ -322,12 +323,15 @@
         """
         count = 0
         while True:
-            if self.query_limit is not None and "revisions" not in self.module:
-                if self.limit is not None:
+            if self.query_limit is not None:
+                if self.limit is None:
+                    new_limit = self.query_limit
+                elif self.limit > 0:
                     new_limit = min(self.query_limit, self.limit - count)
                 else:
-                    new_limit = self.query_limit
-                self.request[self.prefix+"limit"] = str(new_limit)
+                    new_limit = None
+                if new_limit is not None:
+                    self.request[self.prefix+"limit"] = str(new_limit)
             self.data = self.request.submit()
             if not self.data or not isinstance(self.data, dict):
                 logging.debug(

Modified: branches/rewrite/pywikibot/site.py
===================================================================
--- branches/rewrite/pywikibot/site.py	2008-05-12 20:33:47 UTC (rev 5360)
+++ branches/rewrite/pywikibot/site.py	2008-05-12 20:37:06 UTC (rev 5361)
@@ -861,7 +861,9 @@
                     u"ids|flags|timestamp|user|comment|content"
             if section is not None:
                 rvgen.request[u"rvsection"] = unicode(section)
-        if isinstance(limit, int):
+        if latest:
+            rvgen.limit = -1  # suppress use of rvlimit parameter
+        elif isinstance(limit, int):
             rvgen.limit = limit
         if rvdir:
             rvgen.request[u"rvdir"] = u"newer"





More information about the Pywikipedia-l mailing list