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.
--
To view, visit https://gerrit.wikimedia.org/r/567255
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I14bc75d98d7d1bfe513b8b7ca37a37388288be61
Gerrit-Change-Number: 567255
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/567243 )
Change subject: [tests] Skip HiddenKeyErrors within.TestLogEvents.test_logevents
......................................................................
[tests] Skip HiddenKeyErrors within.TestLogEvents.test_logevents
- test all logtypes
- use subTest for every log type
- use while loop instead of for loop to retrieve every single entry
inside a try/except statement
- skip subTest on HiddenKeyError
Bug: T216876
Change-Id: I7ca3a9bd463cfd2c66ec888289ea32d4097a6412
---
M tests/site_tests.py
1 file changed, 13 insertions(+), 4 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index de2b044..e0af211 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1323,10 +1323,19 @@
self.assertLessEqual(len(le), 10)
self.assertTrue(all(isinstance(entry, pywikibot.logentries.LogEntry)
for entry in le))
- for typ in ('block', 'protect', 'rights', 'delete', 'upload',
- 'move', 'import', 'patrol', 'merge'):
- for entry in mysite.logevents(logtype=typ, total=3):
- self.assertEqual(entry.type(), typ)
+
+ for logtype in mysite.logtypes:
+ with self.subTest(logtype=logtype):
+ gen = iter(mysite.logevents(logtype=logtype, total=3))
+ while True:
+ try:
+ entry = next(gen)
+ except StopIteration:
+ break
+ except HiddenKeyError as e: # T216876
+ self.skipTest(e)
+ else:
+ self.assertEqual(entry.type(), logtype)
def test_logevents_mainpage(self):
"""Test logevents method on the main page."""
--
To view, visit https://gerrit.wikimedia.org/r/567243
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7ca3a9bd463cfd2c66ec888289ea32d4097a6412
Gerrit-Change-Number: 567243
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/567215 )
Change subject: [tests] Show complete diff with DataBodyParameterTestCase
......................................................................
[tests] Show complete diff with DataBodyParameterTestCase
Bug: T243662
Change-Id: I92f484c5d47bb4917c17295fa01e73b69ca08844
---
M tests/http_tests.py
1 file changed, 2 insertions(+), 0 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/http_tests.py b/tests/http_tests.py
index 19af276..27f4d79 100644
--- a/tests/http_tests.py
+++ b/tests/http_tests.py
@@ -690,6 +690,8 @@
class DataBodyParameterTestCase(HttpbinTestCase):
"""Test data and body params of fetch/request methods are equivalent."""
+ maxDiff = None
+
def test_fetch(self):
"""Test that using the data and body params produce same results."""
r_data = http.fetch(uri=self.get_httpbin_url('/post'), method='POST',
--
To view, visit https://gerrit.wikimedia.org/r/567215
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I92f484c5d47bb4917c17295fa01e73b69ca08844
Gerrit-Change-Number: 567215
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/567213 )
Change subject: [bugfix] Fix UnboundLocalError in ProofreadPage._ocr_callback
......................................................................
[bugfix] Fix UnboundLocalError in ProofreadPage._ocr_callback
- use for statement instead of while
- return if loop is processed completely with 5 retries
and do not continue the method because response is not fetched
- move sleep statement out of exception handling; probably other
exceptions can also have retries in future
Bug: T243644
Change-Id: Id3601ea4678a3a0ab158a942644d792e46c7cea5
---
M pywikibot/proofreadpage.py
1 file changed, 7 insertions(+), 5 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 5ca3dfd..662cba0 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -599,17 +599,14 @@
(self._OCR_METHODS, ocr_tool))
# wrong link fail with Exceptions
- retry = 0
- while retry < 5:
+ for retry in range(5, 30, 5):
pywikibot.debug('{0}: get URI {1!r}'.format(ocr_tool, cmd_uri),
_logger)
try:
response = http.fetch(cmd_uri)
except requests.exceptions.ReadTimeout as e:
- retry += 1
+ timeout = e
pywikibot.warning('ReadTimeout %s: %s' % (cmd_uri, e))
- pywikibot.warning('retrying in %s seconds ...' % (retry * 5))
- time.sleep(retry * 5)
except Exception as e:
pywikibot.error('"%s": %s' % (cmd_uri, e))
return (True, e)
@@ -618,6 +615,11 @@
_logger)
break
+ pywikibot.warning('retrying in {} seconds ...'.format(retry))
+ time.sleep(retry)
+ else:
+ return True, timeout
+
if 400 <= response.status < 600:
return (True, 'Http response status {0}'.format(response.status))
--
To view, visit https://gerrit.wikimedia.org/r/567213
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id3601ea4678a3a0ab158a942644d792e46c7cea5
Gerrit-Change-Number: 567213
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/566521 )
Change subject: [IMPR] Increase skip counter and other improvements
......................................................................
[IMPR] Increase skip counter and other improvements
- increase _skip_counter if page is skipped by SkipPageError exception
- shorten info dict assignments
- shorten initialized_page assignment
Change-Id: I967fe7033a2ad0ee571795adc4984a70d1bc87fc
---
M pywikibot/bot.py
1 file changed, 5 insertions(+), 11 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index d0935a8..afafcc5 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -420,13 +420,9 @@
log('PACKAGES:')
for name in sorted(packages.keys()):
info = packages[name]
- if 'path' not in info:
- if 'type' in info:
- info['path'] = '[' + info['type'] + ']'
- else:
- info['path'] = '[path unknown]'
- if 'ver' not in info:
- info['ver'] = '??'
+ info.setdefault('path',
+ '[{}]'.format(info.get('type', 'path unknown')))
+ info.setdefault('ver', '??')
if 'err' in info:
log(' %(name)s: %(err)s' % info)
else:
@@ -1514,12 +1510,10 @@
# Python 2 does not clear the exception and it may seem
# that the generator stopped due to an exception
sys.exc_clear()
+ self._skip_counter += 1
continue
else:
- if initialized_page is None:
- page = item
- else:
- page = initialized_page
+ page = initialized_page or item
assert isinstance(page, pywikibot.page.BasePage), (
'"page" is not a pywikibot.page.BasePage object but {}.'
--
To view, visit https://gerrit.wikimedia.org/r/566521
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I967fe7033a2ad0ee571795adc4984a70d1bc87fc
Gerrit-Change-Number: 566521
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)