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.

125 lines
4.5 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's Wiki Toolset: Exceptions
  24. This module contains all exceptions used by the wiki package. There are a lot:
  25. -- WikiToolsetError
  26. -- SiteNotFoundError
  27. -- SiteAPIError
  28. -- LoginError
  29. -- NamespaceNotFoundError
  30. -- PageNotFoundError
  31. -- InvalidPageError
  32. -- RedirectError
  33. -- UserNotFoundError
  34. -- EditError
  35. -- PermissionsError
  36. -- EditConflictError
  37. -- NoContentError
  38. -- ContentTooBigError
  39. -- SpamDetectedError
  40. -- FilteredError
  41. -- SQLError
  42. -- CopyvioCheckError
  43. -- UnknownSearchEngineError
  44. -- UnsupportedSearchEngineError
  45. -- SearchQueryError
  46. """
  47. class WikiToolsetError(Exception):
  48. """Base exception class for errors in the Wiki Toolset."""
  49. class SiteNotFoundError(WikiToolsetError):
  50. """A site matching the args given to get_site() could not be found in the
  51. config file."""
  52. class SiteAPIError(WikiToolsetError):
  53. """We couldn't connect to a site's API, perhaps because the server doesn't
  54. exist, our URL is wrong or incomplete, or they're having temporary
  55. problems."""
  56. class LoginError(WikiToolsetError):
  57. """An error occured while trying to login. Perhaps the username/password is
  58. incorrect."""
  59. class NamespaceNotFoundError(WikiToolsetError):
  60. """A requested namespace name or namespace ID does not exist."""
  61. class PageNotFoundError(WikiToolsetError):
  62. """Attempting to get certain information about a page that does not
  63. exist."""
  64. class InvalidPageError(WikiToolsetError):
  65. """Attempting to get certain information about a page whose title is
  66. invalid."""
  67. class RedirectError(WikiToolsetError):
  68. """Page's get_redirect_target() method failed because the page is either
  69. not a redirect, or it is malformed."""
  70. class UserNotFoundError(WikiToolsetError):
  71. """Attempting to get certain information about a user that does not
  72. exist."""
  73. class EditError(WikiToolsetError):
  74. """We got some error while editing. Sometimes, a subclass of this exception
  75. will be used, like PermissionsError or EditConflictError."""
  76. class PermissionsError(EditError):
  77. """We tried to do something we don't have permission to, like a non-admin
  78. trying to delete a page, or trying to edit a page when no login information
  79. was provided."""
  80. class EditConflictError(EditError):
  81. """We've gotten an edit conflict or a (rarer) delete/recreate conflict."""
  82. class NoContentError(EditError):
  83. """We tried to create a page or new section with no content."""
  84. class ContentTooBigError(EditError):
  85. """The edit we tried to push exceeded the article size limit."""
  86. class SpamDetectedError(EditError):
  87. """The spam filter refused our edit."""
  88. class FilteredError(EditError):
  89. """The edit filter refused our edit."""
  90. class SQLError(WikiToolsetError):
  91. """Some error involving SQL querying occurred."""
  92. class CopyvioCheckError(WikiToolsetError):
  93. """An error occured when checking a page for copyright violations."""
  94. class UnknownSearchEngineError(CopyvioCheckError):
  95. """CopyrightMixin().copyvio_check() called with an unknown engine."""
  96. class UnsupportedSearchEngineError(CopyvioCheckError):
  97. """The engine requested is not available, e.g., because a required package
  98. is missing."""
  99. class SearchQueryError(CopyvioCheckError):
  100. """Some error ocurred while doing a search query."""