http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11259
Revision: 11259
Author: legoktm
Date: 2013-03-25 07:29:54 +0000 (Mon, 25 Mar 2013)
Log Message:
-----------
PEP8 fixes
Modified Paths:
--------------
branches/rewrite/pywikibot/exceptions.py
Modified: branches/rewrite/pywikibot/exceptions.py
===================================================================
--- branches/rewrite/pywikibot/exceptions.py 2013-03-25 07:17:53 UTC (rev
11258)
+++ branches/rewrite/pywikibot/exceptions.py 2013-03-25 07:29:54 UTC (rev
11259)
@@ -15,6 +15,7 @@
# TODO: These are copied from wikipedia.py; not certain that all of them
# will be needed in the rewrite.
+
class Error(Exception):
"""Wikipedia error"""
def __init__(self, arg):
@@ -23,11 +24,14 @@
self.string = arg.encode(config.console_encoding,
"xmlcharrefreplace")
except (AttributeError, TypeError):
self.string = arg.encode("ascii", "xmlcharrefreplace")
+
def __str__(self):
return self.string
+
def __unicode__(self):
return self.unicode
+
class PageRelatedError(Error):
"""Abstract Exception, used when the Exception concerns a particular
Page, and when a generic message can be written once for all"""
@@ -35,6 +39,7 @@
# Override this in subclasses.
# u"Oh noes! Page %s is too funky, we should not delete it ;("
message = None
+
def __init__(self, page):
"""
@param page
@@ -48,24 +53,30 @@
def getPage(self):
return self._page
+
class NoUsername(Error):
"""Username is not in user-config.py"""
+
class NoPage(PageRelatedError):
"""Page does not exist"""
message = u"Page %s doesn't exist."
+
class NoSuchSite(Error):
"""Site does not exist"""
+
class IsRedirectPage(PageRelatedError):
"""Page is a redirect page"""
message = u"Page %s is a redirect page."
+
class IsNotRedirectPage(PageRelatedError):
"""Page is not a redirect page"""
message = u"Page %s is not a redirect page."
+
class CircularRedirect(Error):
"""Page is a circular redirect
@@ -75,22 +86,28 @@
"""
+
class InvalidTitle(Error):
"""Invalid page title"""
+
class LockedPage(PageRelatedError):
"""Page is locked"""
message = u"Page %s is locked."
+
class SectionError(Error):
"""The section specified by # does not exist"""
+
class PageNotSaved(Error):
"""Saving the page has failed"""
+
class EditConflict(PageNotSaved):
"""There has been an edit conflict while uploading the page"""
+
class SpamfilterError(PageNotSaved):
"""Saving the page has failed because the MediaWiki spam filter detected a
blacklisted URL."""
def __init__(self, arg):
@@ -98,35 +115,46 @@
self.url = arg
self.args = arg,
+
class ServerError(Error):
"""Got unexpected server response"""
+
class Server504Error(Error):
"""Server timed out with http 504 code"""
+
class BadTitle(Error):
"""Server responded with BadTitle."""
# UserBlocked exceptions should in general not be caught. If the bot has
# been blocked, the bot operator should address the reason for the block
# before continuing.
+
+
class UserBlocked(Error):
"""Your username or IP has been blocked"""
+
class PageNotFound(Error):
"""Page not found in list"""
+
class CaptchaError(Error):
"""Captcha is asked and config.solve_captcha == False."""
+
class UploadWarning(Error):
"""Upload failed with a warning message (passed as the argument)."""
+
class AutoblockUser(Error):
"""
The class AutoblockUserError is an exception that is raised whenever
an action is requested on a virtual autoblock user that's not available
for him (i.e. roughly everything except unblock).
"""
+
+
class UserActionRefuse(Error):
pass
_______________________________________________
Pywikipedia-svn mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn