jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/274977 )

Change subject: [bugfix] Enable total parameter for site.watched_pages
......................................................................

[bugfix] Enable total parameter for site.watched_pages

- enable total parameter to limit the total number of items of that generator
- Also deprecate special_page_limit: special_page_limit was introduced in
  compat for retrieving pages from mw special list via screen scraping.
  The use of this parameter in compat is a mess but in core it is not used
  except in watched_pages. api may read all items except a total parameter
  for a generator or treat counter restricts it.

Bug: T187881
Change-Id: Idd0afa55cec93b92abbd5f0a9d2d0b9317a9a42a
---
M pywikibot/config2.py
M pywikibot/site.py
2 files changed, 11 insertions(+), 9 deletions(-)

Approvals:
  Dalba: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 257b3ee..2ae9a8c 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -95,7 +95,8 @@

 _private_values = ['authenticate', 'proxy', 'db_password']
 _deprecated_variables = ['use_SSL_onlogin', 'use_SSL_always',
-                         'available_ssl_project', 'fake_user_agent']
+                         'available_ssl_project', 'fake_user_agent',
+                         'special_page_limit']

 # ############# ACCOUNT SETTINGS ##############

@@ -646,11 +647,6 @@
 # at least 1 second.
 maxlag = 5

-# Maximum of pages which can be retrieved by special pages. Increase this if
-# you heavily use redirect.py with action "double", and especially if you're
-# running solve_disambiguation.py with the -primary argument.
-special_page_limit = 500
-
 # Maximum of pages which can be retrieved at one time from wiki server.
 # -1 indicates limit by api restriction
 step = -1
@@ -893,6 +889,10 @@
     'reviewer': u'',  # If so, under what reviewer name?
 }

+special_page_limit = 500
+
+# #############################################
+

 def makepath(path):
     """Return a normalized absolute version of the path argument.
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ad28b7a..9d71e1d 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -7306,15 +7306,17 @@
         @type sysop: bool
         @param force_reload: Reload watchlist
         @type force_reload: bool
+        @param total: if not None, limit the generator to yielding this many
+            items in total
+        @type total: int
         @return: list of pages in watchlist
         @rtype: list of pywikibot.Page objects
         """
         self.login(sysop=sysop)
-        if not total:
-            total = pywikibot.config.special_page_limit
         expiry = None if force else pywikibot.config.API_config_expiry
         gen = api.PageGenerator(site=self, generator='watchlistraw',
-                                expiry=expiry, gwrlimit=total)
+                                expiry=expiry)
+        gen.set_maximum_items(total)
         return gen

     # aliases for backwards compatibility

--
To view, visit https://gerrit.wikimedia.org/r/274977
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Idd0afa55cec93b92abbd5f0a9d2d0b9317a9a42a
Gerrit-Change-Number: 274977
Gerrit-PatchSet: 15
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: Dalba <dalba.w...@gmail.com>
Gerrit-Reviewer: Framawiki <framaw...@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Magul <tomasz.magul...@gmail.com>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
Pywikibot-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to