jenkins-bot merged this change.

View Change

Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
[cleanup] use content parameter instead of getText in loadrevisions

deprecate "getText" parameter of Site.loadrevisions and use "content" instead.
"content" is used on all other methods to preload text.

Change-Id: I6125fd1f1aec429548f2335e2d052dbccbb222f1
---
M pywikibot/page.py
M pywikibot/site.py
M tests/basepage_tests.py
M tests/site_tests.py
4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/pywikibot/page.py b/pywikibot/page.py
index ddef974..46a43e1 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -508,7 +508,7 @@
# If not already stored, fetch revision
if self._latest_cached_revision() is None:
try:
- self.site.loadrevisions(self, getText=True, sysop=sysop)
+ self.site.loadrevisions(self, content=True, sysop=sysop)
except (pywikibot.NoPage, pywikibot.SectionError) as e:
self._getexception = e
raise
@@ -530,7 +530,7 @@
if force or oldid not in self._revisions \
or self._revisions[oldid].text is None:
self.site.loadrevisions(self,
- getText=True,
+ content=True,
revids=oldid,
sysop=sysop)
# TODO: what about redirects, errors?
@@ -1697,7 +1697,7 @@
rollback=False, starttime=None, endtime=None):
"""Generator which loads the version history as Revision instances."""
# TODO: Only request uncached revisions
- self.site.loadrevisions(self, getText=content, rvdir=reverse,
+ self.site.loadrevisions(self, content=content, rvdir=reverse,
starttime=starttime, endtime=endtime,
total=total, rollback=rollback)
return (self._revisions[rev] for rev in
diff --git a/pywikibot/site.py b/pywikibot/site.py
index e5bc29a..20c6d62 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3981,7 +3981,8 @@
total=total, g_content=content, **cmargs)
return cmgen

- def loadrevisions(self, page, getText=False, revids=None,
+ @deprecated_args(getText='content')
+ def loadrevisions(self, page, content=False, revids=None,
startid=None, endid=None, starttime=None,
endtime=None, rvdir=None, user=None, excludeuser=None,
section=None, sysop=False, step=None, total=None,
@@ -4000,10 +4001,11 @@

@param page: retrieve revisions of this Page (required unless ids
is specified)
- @param getText: if True, retrieve the wiki-text of each revision;
+ @param content: if True, retrieve the wiki-text of each revision;
otherwise, only retrieve the revision metadata (default)
+ @type content: bool
@param section: if specified, retrieve only this section of the text
- (getText must be True); section must be given by number (top of
+ (content must be True); section must be given by number (top of
the article is section 0), not name
@type section: int
@param revids: retrieve only the specified revision ids (raise
@@ -4058,7 +4060,7 @@
rvargs['rvprop'].append('contentmodel')
if MediaWikiVersion(self.version()) >= MediaWikiVersion('1.19'):
rvargs['rvprop'].append('sha1')
- if getText:
+ if content:
rvargs['rvprop'].append('content')
if section is not None:
rvargs[u"rvsection"] = unicode(section)
diff --git a/tests/basepage_tests.py b/tests/basepage_tests.py
index 99449de..58bbde9 100644
--- a/tests/basepage_tests.py
+++ b/tests/basepage_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Tests for BasePage subclasses."""
#
-# (C) Pywikibot team, 2015
+# (C) Pywikibot team, 2015-2018
#
# Distributed under the terms of the MIT license.
#
@@ -65,7 +65,7 @@
self.assertFalse(hasattr(page, '_text'))
self.assertIsNone(page._latest_cached_revision())

- self.site.loadrevisions(page, total=1, getText=True)
+ self.site.loadrevisions(page, total=1, content=True)
self.assertFalse(hasattr(page, '_text'))
self.assertIsNotNone(page._latest_cached_revision())

diff --git a/tests/site_tests.py b/tests/site_tests.py
index e42c3eb..667011e 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -2384,9 +2384,9 @@
# The revision content will be loaded by .text
self.assertIsNotNone(self.mainpage.text)

- def testLoadRevisions_getText(self):
- """Test the site.loadrevisions() method with getText=True."""
- self.mysite.loadrevisions(self.mainpage, getText=True, total=5)
+ def test_loadrevisions_content(self):
+ """Test the site.loadrevisions() method with content=True."""
+ self.mysite.loadrevisions(self.mainpage, content=True, total=5)
self.assertFalse(hasattr(self.mainpage, '_text'))
self.assertIn(self.mainpage._revid, self.mainpage._revisions)
self.assertIsNotNone(self.mainpage._revisions[self.mainpage._revid].text)

To view, visit change 425128. To unsubscribe, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6125fd1f1aec429548f2335e2d052dbccbb222f1
Gerrit-Change-Number: 425128
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot <>