interfaces.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2003 Zope Foundation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE.
  12. #
  13. ##############################################################################
  14. """Interfaces for standard python exceptions
  15. """
  16. from zope.interface import Interface
  17. from zope.interface import classImplements
  18. class IException(Interface):
  19. "Interface for `Exception`"
  20. classImplements(Exception, IException) # noqa E305
  21. class IStandardError(IException):
  22. "Interface for `StandardError` (no longer existing.)"
  23. class IWarning(IException):
  24. "Interface for `Warning`"
  25. classImplements(Warning, IWarning) # noqa E305
  26. class ISyntaxError(IStandardError):
  27. "Interface for `SyntaxError`"
  28. classImplements(SyntaxError, ISyntaxError) # noqa E305
  29. class ILookupError(IStandardError):
  30. "Interface for `LookupError`"
  31. classImplements(LookupError, ILookupError) # noqa E305
  32. class IValueError(IStandardError):
  33. "Interface for `ValueError`"
  34. classImplements(ValueError, IValueError) # noqa E305
  35. class IRuntimeError(IStandardError):
  36. "Interface for `RuntimeError`"
  37. classImplements(RuntimeError, IRuntimeError) # noqa E305
  38. class IArithmeticError(IStandardError):
  39. "Interface for `ArithmeticError`"
  40. classImplements(ArithmeticError, IArithmeticError) # noqa E305
  41. class IAssertionError(IStandardError):
  42. "Interface for `AssertionError`"
  43. classImplements(AssertionError, IAssertionError) # noqa E305
  44. class IAttributeError(IStandardError):
  45. "Interface for `AttributeError`"
  46. classImplements(AttributeError, IAttributeError) # noqa E305
  47. class IDeprecationWarning(IWarning):
  48. "Interface for `DeprecationWarning`"
  49. classImplements(DeprecationWarning, IDeprecationWarning) # noqa E305
  50. class IEOFError(IStandardError):
  51. "Interface for `EOFError`"
  52. classImplements(EOFError, IEOFError) # noqa E305
  53. class IEnvironmentError(IStandardError):
  54. "Interface for `EnvironmentError`"
  55. classImplements(EnvironmentError, IEnvironmentError) # noqa E305
  56. class IFloatingPointError(IArithmeticError):
  57. "Interface for `FloatingPointError`"
  58. classImplements(FloatingPointError, IFloatingPointError) # noqa E305
  59. class IIOError(IEnvironmentError):
  60. "Interface for `IOError`"
  61. classImplements(IOError, IIOError) # noqa E305
  62. class IImportError(IStandardError):
  63. "Interface for `ImportError`"
  64. classImplements(ImportError, IImportError) # noqa E305
  65. class IIndentationError(ISyntaxError):
  66. "Interface for `IndentationError`"
  67. classImplements(IndentationError, IIndentationError) # noqa E305
  68. class IIndexError(ILookupError):
  69. "Interface for `IndexError`"
  70. classImplements(IndexError, IIndexError) # noqa E305
  71. class IKeyError(ILookupError):
  72. "Interface for `KeyError`"
  73. classImplements(KeyError, IKeyError) # noqa E305
  74. class IKeyboardInterrupt(IStandardError):
  75. "Interface for `KeyboardInterrupt`"
  76. classImplements(KeyboardInterrupt, IKeyboardInterrupt) # noqa E305
  77. class IMemoryError(IStandardError):
  78. "Interface for `MemoryError`"
  79. classImplements(MemoryError, IMemoryError) # noqa E305
  80. class INameError(IStandardError):
  81. "Interface for `NameError`"
  82. classImplements(NameError, INameError) # noqa E305
  83. class INotImplementedError(IRuntimeError):
  84. "Interface for `NotImplementedError`"
  85. classImplements(NotImplementedError, INotImplementedError) # noqa E305
  86. class IOSError(IEnvironmentError):
  87. "Interface for `OSError`"
  88. classImplements(OSError, IOSError) # noqa E305
  89. class IOverflowError(IArithmeticError):
  90. "Interface for `ArithmeticError`"
  91. classImplements(OverflowError, IOverflowError) # noqa E305
  92. class IOverflowWarning(IWarning):
  93. """Deprecated, no standard class implements this.
  94. This was the interface for ``OverflowWarning`` prior to Python 2.5,
  95. but that class was removed for all versions after that.
  96. """
  97. class IReferenceError(IStandardError):
  98. "Interface for `ReferenceError`"
  99. classImplements(ReferenceError, IReferenceError) # noqa E305
  100. class IRuntimeWarning(IWarning):
  101. "Interface for `RuntimeWarning`"
  102. classImplements(RuntimeWarning, IRuntimeWarning) # noqa E305
  103. class IStopIteration(IException):
  104. "Interface for `StopIteration`"
  105. classImplements(StopIteration, IStopIteration) # noqa E305
  106. class ISyntaxWarning(IWarning):
  107. "Interface for `SyntaxWarning`"
  108. classImplements(SyntaxWarning, ISyntaxWarning) # noqa E305
  109. class ISystemError(IStandardError):
  110. "Interface for `SystemError`"
  111. classImplements(SystemError, ISystemError) # noqa E305
  112. class ISystemExit(IException):
  113. "Interface for `SystemExit`"
  114. classImplements(SystemExit, ISystemExit) # noqa E305
  115. class ITabError(IIndentationError):
  116. "Interface for `TabError`"
  117. classImplements(TabError, ITabError) # noqa E305
  118. class ITypeError(IStandardError):
  119. "Interface for `TypeError`"
  120. classImplements(TypeError, ITypeError) # noqa E305
  121. class IUnboundLocalError(INameError):
  122. "Interface for `UnboundLocalError`"
  123. classImplements(UnboundLocalError, IUnboundLocalError) # noqa E305
  124. class IUnicodeError(IValueError):
  125. "Interface for `UnicodeError`"
  126. classImplements(UnicodeError, IUnicodeError) # noqa E305
  127. class IUserWarning(IWarning):
  128. "Interface for `UserWarning`"
  129. classImplements(UserWarning, IUserWarning) # noqa E305
  130. class IZeroDivisionError(IArithmeticError):
  131. "Interface for `ZeroDivisionError`"
  132. classImplements(ZeroDivisionError, IZeroDivisionError) # noqa E305