jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/965870 )
Change subject: Replace MW API deprecated inprop=preload with preloadcontent ......................................................................
Replace MW API deprecated inprop=preload with preloadcontent
Bug: T348910 Change-Id: I9c197df7dfdc597a6eff638ec2c5ac3d99846348 --- M tests/dry_api_tests.py M pywikibot/site/_apisite.py M pywikibot/data/api/_generators.py 3 files changed, 22 insertions(+), 4 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api/_generators.py b/pywikibot/data/api/_generators.py index 9e25f52..902c561 100644 --- a/pywikibot/data/api/_generators.py +++ b/pywikibot/data/api/_generators.py @@ -1024,7 +1024,10 @@ elif 'pageprops' in props: page._pageprops = {}
- if 'preload' in pagedict: + # preload is deprecated in MW 1.41, try preloadcontent first + if 'preloadcontent' in pagedict: + page._preloadedtext = pagedict['preloadcontent']['*'] + elif 'preload' in pagedict: page._preloadedtext = pagedict['preload']
if 'flowinfo' in pagedict: diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py index ba3e8ca..dbc1a18 100644 --- a/pywikibot/site/_apisite.py +++ b/pywikibot/site/_apisite.py @@ -15,9 +15,9 @@
import pywikibot from pywikibot import login -from pywikibot.backports import DefaultDict, Dict, List, Match +from pywikibot.backports import DefaultDict, Dict, Iterable, List, Match from pywikibot.backports import OrderedDict as OrderedDictType -from pywikibot.backports import Iterable, Set, Tuple, removesuffix +from pywikibot.backports import Set, Tuple, removesuffix from pywikibot.comms import http from pywikibot.data import api from pywikibot.exceptions import ( @@ -1336,7 +1336,10 @@ title = page.title(with_section=False) inprop = 'protection' if preload: - inprop += '|preload' + if self.mw_version >= MediaWikiVersion('1.41'): + inprop += '|preloadcontent' + else: + inprop += '|preload'
query = self._generator(api.PropertyGenerator, type_arg='info', diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py index 7ad0dd3..ad43304 100755 --- a/tests/dry_api_tests.py +++ b/tests/dry_api_tests.py @@ -335,6 +335,7 @@ 'url', 'watched', 'watchers', + 'preloadcontent', 'preload', 'readable', ], @@ -417,6 +418,7 @@ self.assertIn('deprecatedvalues', param) self.assertIsInstance(param['type'], list) self.assertIn('preload', param['type']) + self.assertIn('preloadcontent', param['type'])
def test_tokens_parameter(self): """Test parameter() method with 'tokens' module."""
pywikibot-commits@lists.wikimedia.org