A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
4.6 KiB

  1. # -*- coding: utf-8 -*-
  2. #
  3. # Copyright (C) 2009-2012 by Ben Kurtovic <ben.kurtovic@verizon.net>
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. # SOFTWARE.
  22. """
  23. EarwigBot Exceptions
  24. This module contains all exceptions used by EarwigBot::
  25. EarwigBotError
  26. +-- WikiToolsetError
  27. +-- SiteNotFoundError
  28. +-- SiteAPIError
  29. +-- LoginError
  30. +-- NamespaceNotFoundError
  31. +-- PageNotFoundError
  32. +-- InvalidPageError
  33. +-- RedirectError
  34. +-- UserNotFoundError
  35. +-- EditError
  36. | +-- PermissionsError
  37. | +-- EditConflictError
  38. | +-- NoContentError
  39. | +-- ContentTooBigError
  40. | +-- SpamDetectedError
  41. | +-- FilteredError
  42. +-- SQLError
  43. +-- CopyvioCheckError
  44. +-- UnknownSearchEngineError
  45. +-- UnsupportedSearchEngineError
  46. +-- SearchQueryError
  47. """
  48. class EarwigBotErorr(Exception):
  49. """Base exception class for errors in EarwigBot."""
  50. class WikiToolsetError(EarwigBotErorr):
  51. """Base exception class for errors in the Wiki Toolset."""
  52. class SiteNotFoundError(WikiToolsetError):
  53. """A site matching the args given to get_site() could not be found in the
  54. config file."""
  55. class SiteAPIError(WikiToolsetError):
  56. """We couldn't connect to a site's API, perhaps because the server doesn't
  57. exist, our URL is wrong or incomplete, or they're having temporary
  58. problems."""
  59. class LoginError(WikiToolsetError):
  60. """An error occured while trying to login. Perhaps the username/password is
  61. incorrect."""
  62. class NamespaceNotFoundError(WikiToolsetError):
  63. """A requested namespace name or namespace ID does not exist."""
  64. class PageNotFoundError(WikiToolsetError):
  65. """Attempting to get certain information about a page that does not
  66. exist."""
  67. class InvalidPageError(WikiToolsetError):
  68. """Attempting to get certain information about a page whose title is
  69. invalid."""
  70. class RedirectError(WikiToolsetError):
  71. """Page's get_redirect_target() method failed because the page is either
  72. not a redirect, or it is malformed."""
  73. class UserNotFoundError(WikiToolsetError):
  74. """Attempting to get certain information about a user that does not
  75. exist."""
  76. class EditError(WikiToolsetError):
  77. """We got some error while editing. Sometimes, a subclass of this exception
  78. will be used, like PermissionsError or EditConflictError."""
  79. class PermissionsError(EditError):
  80. """We tried to do something we don't have permission to, like a non-admin
  81. trying to delete a page, or trying to edit a page when no login information
  82. was provided."""
  83. class EditConflictError(EditError):
  84. """We've gotten an edit conflict or a (rarer) delete/recreate conflict."""
  85. class NoContentError(EditError):
  86. """We tried to create a page or new section with no content."""
  87. class ContentTooBigError(EditError):
  88. """The edit we tried to push exceeded the article size limit."""
  89. class SpamDetectedError(EditError):
  90. """The spam filter refused our edit."""
  91. class FilteredError(EditError):
  92. """The edit filter refused our edit."""
  93. class SQLError(WikiToolsetError):
  94. """Some error involving SQL querying occurred."""
  95. class CopyvioCheckError(WikiToolsetError):
  96. """An error occured when checking a page for copyright violations."""
  97. class UnknownSearchEngineError(CopyvioCheckError):
  98. """CopyrightMixin().copyvio_check() called with an unknown engine."""
  99. class UnsupportedSearchEngineError(CopyvioCheckError):
  100. """The engine requested is not available, e.g., because a required package
  101. is missing."""
  102. class SearchQueryError(CopyvioCheckError):
  103. """Some error ocurred while doing a search query."""