Xqt has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/400236 )
Change subject: [IMPR] Remove not impelemted page and site methods
......................................................................
[IMPR] Remove not impelemted page and site methods
- page.py: only show a warning when using removeImage or replaceImage
which is the same behaviour as before this change
-site.py: remove depecated method which raised an NotImplementedError.
This raises an AttributeError now which a bit different but it shouldn't
care anyway,
Change-Id: I63e468f4b22714cf281755de90e8d9bf75647f7d
---
M pywikibot/page.py
M pywikibot/site.py
2 files changed, 12 insertions(+), 34 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/36/400236/1
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 3511f43..5948519 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2217,20 +2217,14 @@
restrictions = self.protection()
return dict((k, list(restrictions[k])) for k in restrictions)
-# ###### DISABLED METHODS (warnings provided) ######
- # these methods are easily replaced by editing the page's text using
- # textlib methods and then using put() on the result.
-
- def removeImage(self, image, put=False, summary=None, safe=True):
- """Old method to remove all instances of an image from page."""
- warn('Page.removeImage() is no longer supported.',
- _NotImplementedWarning, 2)
-
- def replaceImage(self, image, replacement=None, put=False, summary=None,
- safe=True):
- """Old method to replace all instances of an image with another."""
- warn('Page.replaceImage() is no longer supported.',
- _NotImplementedWarning, 2)
+ def __getattr__(self, name):
+ """Generic disabled method warnings."""
+ if name in ('removeImage', 'replaceImage'):
+ warn('Page.{0}() is no longer supported.'.format(name),
+ _NotImplementedWarning, 2)
+ return lambda x: None
+ raise AttributeError("'{0}' object has no attribute '{1}'"
+ .format(self.__class__.__name__, name))
class Page(BasePage):
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 9794b6e..c379a94 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -894,6 +894,10 @@
def __getattr__(self, attr):
"""Delegate undefined methods calls to the Family object."""
+ if attr in ('checkCharset', 'cookies', 'updateCookies',
+ 'solveCaptcha'):
+ raise NotImplementedError('{0}.{1} is deprecated.'
+ .format(self.__class__.__name__, attr))
if hasattr(self.__class__, attr):
return getattr(self.__class__, attr)
try:
@@ -1285,26 +1289,6 @@
compress=True, cookies=None):
"""DEPRECATED."""
return self.getUrl(address, data=data)
-
- @deprecated
- def checkCharset(self, charset):
- """DEPRECATED."""
- raise NotImplementedError
-
- @deprecated
- def cookies(self, sysop=False):
- """DEPRECATED."""
- raise NotImplementedError
-
- @deprecated
- def updateCookies(self, datas, sysop=False):
- """DEPRECATED."""
- raise NotImplementedError
-
- @deprecated
- def solveCaptcha(self, data):
- """DEPRECATED."""
- raise NotImplementedError
def must_be(group=None, right=None):
--
To view, visit https://gerrit.wikimedia.org/r/400236
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I63e468f4b22714cf281755de90e8d9bf75647f7d
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits