jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/282517 )
Change subject: [compat2core] Add information about templatesWithParams ......................................................................
[compat2core] Add information about templatesWithParams
- templatesWithParams() has a breaking change between compat and core. As this was done in the first implementation for core, we shouldn't change its behavior but note it in README-conversion.txt and give a warning in compat2core.py utility script. - Also correct the docstring of the method: templatesWithParams is not a generator but returns a list of tuples with two items, a Page object and a list of parameters.
Bug: T131952 Change-Id: I9ef501f7271d126d5720cec3ad48dcb21740f96b --- M README-conversion.txt M pywikibot/page.py M scripts/maintenance/compat2core.py 3 files changed, 12 insertions(+), 5 deletions(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/README-conversion.txt b/README-conversion.txt index 381c4a7..d67b702 100644 --- a/README-conversion.txt +++ b/README-conversion.txt @@ -89,6 +89,9 @@ The following methods have had their outputs changed:
- getVersionHistory(): Returns a pywikibot.Timestamp object instead of a MediaWiki one +- templatesWithParams(): Returns a list of tuples with two items. The first item is + a Page object of the template, the second is a list of parameters. In compat we have + a list of tuples with two items. The first item is the template title.
=== FilePage objects ===
diff --git a/pywikibot/page.py b/pywikibot/page.py index 2f525b8..e953da0 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -2191,12 +2191,12 @@ @deprecate_arg("get_redirect", None) def templatesWithParams(self): """ - Iterate templates used on this Page. + Return templates used on this Page.
- @return: a generator that yields a tuple for each use of a template + @return: a list that contains a tuple for each use of a template in the page, with the template Page as the first entry and a list of parameters as the second entry. - @rtype: generator + @rtype: list """ # WARNING: may not return all templates used in particularly # intricate cases such as template substitution diff --git a/scripts/maintenance/compat2core.py b/scripts/maintenance/compat2core.py index 46c09a7..ec7a3dc 100755 --- a/scripts/maintenance/compat2core.py +++ b/scripts/maintenance/compat2core.py @@ -25,7 +25,7 @@ python pwb.py compat2core <scriptname> -warnonly """ # -# (C) xqt, 2014-2015 +# (C) xqt, 2014-2017 # (C) Pywikibot team, 2014-2017 # # Distributed under the terms of the MIT license. @@ -117,7 +117,11 @@ 'query.GetData() should be replaced by pywikibot.data.api.Request or\n' 'by a direct site request'), ('.verbose', - 'verbose_output need "from pywikibot import config" first') + 'verbose_output need "from pywikibot import config" first'), + ('templatesWithParams(', + 'the first item of each template info is a Page object of the template,\n' + 'not the title. ' + 'Please refer README-conversion.txt and the documentation.'), )
pywikibot-commits@lists.wikimedia.org