jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/567255 )
Change subject: [cleanup] remove/depecate sysop parameter in several methods ......................................................................
[cleanup] remove/depecate sysop parameter in several methods
config.sysopnames is deprecated since 6f0cafd
flow.py: - remove sysop parameter in get methods of FlowPage and Post which wheren't implemented; don't raise NotImplementedError exception but let the runtime do this job
page.py: - remove sysop parameter of private method _getInterals - remove sysop parameter for loadrevisions call - remove sysop parameter of getOldVersion - remove sysop parameter of move method which was never implemented
site_tests.py: - remove sysop parameter in loadrevisions call
wikibase_tests.py: - remove TestDryPageGetNotImplemented which isn't applicable anymore
Change-Id: I14bc75d98d7d1bfe513b8b7ca37a37388288be61 --- M pywikibot/flow.py M pywikibot/page.py M tests/site_tests.py M tests/wikibase_tests.py 4 files changed, 16 insertions(+), 65 deletions(-)
Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/flow.py b/pywikibot/flow.py index 12a1388..74f9025 100644 --- a/pywikibot/flow.py +++ b/pywikibot/flow.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Objects representing Flow entities, like boards, topics, and posts.""" # -# (C) Pywikibot team, 2015-2018 +# (C) Pywikibot team, 2015-2020 # # Distributed under the terms of the MIT license. # @@ -65,9 +65,9 @@ self._load_uuid() return self._uuid
- def get(self, force=False, get_redirect=False, sysop=False): + def get(self, force=False, get_redirect=False): """Get the page's content.""" - if get_redirect or force or sysop: + if get_redirect or force: raise NotImplementedError
# TODO: Return more useful data @@ -434,22 +434,16 @@ self._current_revision['creator']['name']) return self._creator
- def get(self, format='wikitext', force=False, sysop=False): + def get(self, format='wikitext', force=False): """Return the contents of the post in the given format.
@param force: Whether to reload from the API instead of using the cache @type force: bool - @param sysop: Whether to load using sysop rights. Implies force. - @type sysop: bool @param format: Content format to return contents in @type format: str @return: The contents of the post in the given content format @rtype: str - @raises NotImplementedError: use of 'sysop' """ - if sysop: - raise NotImplementedError - if format not in self._content or force: self._load(format) return self._content[format] diff --git a/pywikibot/page.py b/pywikibot/page.py index aea88fa..ec0adc2 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -12,7 +12,7 @@
""" # -# (C) Pywikibot team, 2008-2019 +# (C) Pywikibot team, 2008-2020 # # Distributed under the terms of the MIT license. # @@ -458,10 +458,11 @@ """Return True if title of this Page is in the autoFormat dict.""" return self.autoFormat()[0] is not None
+ @remove_last_args(['sysop']) @deprecated_args(throttle=None, change_edit_time=None, expandtemplates=None) - def get(self, force=False, get_redirect=False, sysop=False): + def get(self, force=False, get_redirect=False): """ Return the wiki-text of the page.
@@ -479,15 +480,12 @@ @param force: reload all page attributes, including errors. @param get_redirect: return the redirect text, do not follow the redirect, do not raise an exception. - @param sysop: if the user has a sysop account, use it to - retrieve this page - @rtype: str """ if force: del self.latest_revision_id try: - self._getInternals(sysop) + self._getInternals() except pywikibot.IsRedirectPage: if not get_redirect: raise @@ -502,7 +500,7 @@ else: return None
- def _getInternals(self, sysop): + def _getInternals(self): """ Helper function for get().
@@ -517,7 +515,7 @@ # If not already stored, fetch revision if self._latest_cached_revision() is None: try: - self.site.loadrevisions(self, content=True, sysop=sysop) + self.site.loadrevisions(self, content=True) except (pywikibot.NoPage, pywikibot.SectionError) as e: self._getexception = e raise @@ -527,9 +525,9 @@ self._getexception = pywikibot.IsRedirectPage(self) raise self._getexception
+ @remove_last_args(['sysop']) @deprecated_args(throttle=None, change_edit_time=None) - def getOldVersion(self, oldid, force=False, get_redirect=False, - sysop=False): + def getOldVersion(self, oldid, force=False, get_redirect=False): """ Return text of an old revision of this page; same options as get().
@@ -540,8 +538,7 @@ or self._revisions[oldid].text is None: self.site.loadrevisions(self, content=True, - revids=oldid, - sysop=sysop) + revids=oldid) # TODO: what about redirects, errors? return self._revisions[oldid].text
@@ -1881,15 +1878,13 @@ @deprecated_args( throttle=None, deleteAndMove='noredirect', movetalkpage='movetalk') @remove_last_args(['safe']) - def move(self, newtitle, reason=None, movetalk=True, sysop=False, - noredirect=False): + def move(self, newtitle, reason=None, movetalk=True, noredirect=False): """ Move this page to a new title.
@param newtitle: The new page title. @param reason: The edit summary for the move. @param movetalk: If true, move this page's talk page (if it exists) - @param sysop: Try to move using sysop account, if available @param noredirect: if move succeeds, delete the old page (usually requires sysop privileges, depending on wiki settings) """ @@ -1897,7 +1892,6 @@ pywikibot.output('Moving %s to [[%s]].' % (self.title(as_link=True), newtitle)) reason = pywikibot.input('Please enter a reason for the move:') - # TODO: implement "sysop" parameter return self.site.movepage(self, newtitle, reason, movetalk=movetalk, noredirect=noredirect) diff --git a/tests/site_tests.py b/tests/site_tests.py index de2b044..fd6bbb1 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -2728,7 +2728,7 @@ def test_rollback(self): """Test the site.loadrevisions() method with rollback.""" mainpage = self.get_mainpage() - self.site.loadrevisions(mainpage, total=12, rollback=True, sysop=True) + self.site.loadrevisions(mainpage, total=12, rollback=True) self.assertIsNotEmpty(mainpage._revisions) self.assertLessEqual(len(mainpage._revisions), 12) self.assertTrue(all(rev.rollbacktoken is not None diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py index b43031f..768c42b 100644 --- a/tests/wikibase_tests.py +++ b/tests/wikibase_tests.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Tests for the Wikidata parts of the page module.""" # -# (C) Pywikibot team, 2008-2019 +# (C) Pywikibot team, 2008-2020 # # Distributed under the terms of the MIT license. # @@ -24,7 +24,6 @@ unittest, TestCase, WikidataTestCase, DeprecationTestCase, - DefaultWikibaseClientTestCase, )
from tests.basepage_tests import ( @@ -1717,42 +1716,6 @@ self._test_no_wikitext()
-class TestDryPageGetNotImplemented(DefaultWikibaseClientTestCase, - DeprecationTestCase): - - """Test not implement get arguments of WikibasePage classes.""" - - dry = True - - def test_base_get_args(self): - """Test WikibasePage.get() with sysop argument.""" - item = WikibasePage(self.repo, 'Q1') - # avoid loading anything - item._content = {} - with self.assertRaises(NotImplementedError): - item.get(force=True, sysop=True) - with self.assertRaises(NotImplementedError): - item.get(force=False, sysop=True) - with self.assertRaises(NotImplementedError): - item.get(force=False, sysop=False) - with self.assertRaises(NotImplementedError): - item.get(sysop=True) - - def test_item_get_args(self): - """Test ItemPage.get() with sysop argument.""" - item = ItemPage(self.repo, 'Q1') - item._content = {} - with self.assertRaises(NotImplementedError): - item.get(sysop=True) - - def test_property_get_args(self): - """Test PropertyPage.get() with sysop argument.""" - pp = PropertyPage(self.repo, 'P1') - pp._content = {} - with self.assertRaises(NotImplementedError): - pp.get(sysop=True) - - class TestLinks(WikidataTestCase):
"""Test cases to test links stored in Wikidata.
pywikibot-commits@lists.wikimedia.org