jenkins-bot has submitted this change and it was merged.
Change subject: Deprecate APISite.checkBlocks
......................................................................
Deprecate APISite.checkBlocks
The 'checkBlocks' method is unused, and 'is blocked' is nearly always
wrong and should be replaced with permission checking using 'has_right'.
Also, use redirect_func to provide the already deprecated methods
'isBlocked' and 'isAllowed'.
Change-Id: Iafc023d3bda1d1012d1d453ff2e990f34eebe333
---
M pywikibot/site.py
1 file changed, 24 insertions(+), 13 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5848169..8b60c0e 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1745,22 +1745,29 @@
globaluserinfo = property(fget=getglobaluserinfo, doc=getuserinfo.__doc__)
def is_blocked(self, sysop=False):
- """Return true if and only if user is blocked.
+ """
+ Return True when logged in user is blocked.
+
+ To check whether a user can perform an action,
+ the method has_right should be used.
@param sysop: If true, log in to sysop account (if available)
-
+ @type sysop: bool
+ @rtype: bool
"""
if not self.logged_in(sysop):
self.login(sysop)
return 'blockinfo' in self._userinfo
- @deprecated('is_blocked()')
- def isBlocked(self, sysop=False):
- """DEPRECATED."""
- return self.is_blocked(sysop)
-
+ @deprecated('has_right() or is_blocked()')
def checkBlocks(self, sysop=False):
- """Check if the user is blocked, and raise an exception if
so."""
+ """
+ Raise an exception when the user is blocked. DEPRECATED.
+
+ @param sysop: If true, log in to sysop account (if available)
+ @type sysop: bool
+ @raises UserBlocked: The logged in user/sysop account is blocked.
+ """
if self.is_blocked(sysop):
# User blocked
raise UserBlocked('User is blocked in site %s' % self)
@@ -1823,11 +1830,6 @@
if not self.logged_in(sysop):
self.login(sysop)
return right.lower() in self._userinfo['rights']
-
- @deprecated("Site.has_right()")
- def isAllowed(self, right, sysop=False):
- """DEPRECATED."""
- return self.has_right(right, sysop)
def has_group(self, group, sysop=False):
"""Return true if and only if the user is a member of specified
group.
@@ -5392,6 +5394,12 @@
comparison = data['compare']['*']
return comparison
+ # aliases for backwards compatibility
+ isBlocked = redirect_func(is_blocked, old_name='isBlocked',
+ class_name='APISite')
+ isAllowed = redirect_func(has_right, old_name='isAllowed',
+ class_name='APISite')
+
class DataSite(APISite):
@@ -5937,6 +5945,9 @@
def isBlocked(self, *args, **kwargs):
raise NotImplementedError
+ def checkBlocks(self, *args, **kwargs):
+ raise NotImplementedError
+
def isAllowed(self, *args, **kwargs):
raise NotImplementedError
--
To view, visit
https://gerrit.wikimedia.org/r/180719
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iafc023d3bda1d1012d1d453ff2e990f34eebe333
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>