interfaces.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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)
  21. class IStandardError(IException):
  22. "Interface for `StandardError` (Python 2 only.)"
  23. try:
  24. classImplements(StandardError, IStandardError)
  25. except NameError: #pragma NO COVER
  26. pass # StandardError does not exist in Python 3
  27. class IWarning(IException):
  28. "Interface for `Warning`"
  29. classImplements(Warning, IWarning)
  30. class ISyntaxError(IStandardError):
  31. "Interface for `SyntaxError`"
  32. classImplements(SyntaxError, ISyntaxError)
  33. class ILookupError(IStandardError):
  34. "Interface for `LookupError`"
  35. classImplements(LookupError, ILookupError)
  36. class IValueError(IStandardError):
  37. "Interface for `ValueError`"
  38. classImplements(ValueError, IValueError)
  39. class IRuntimeError(IStandardError):
  40. "Interface for `RuntimeError`"
  41. classImplements(RuntimeError, IRuntimeError)
  42. class IArithmeticError(IStandardError):
  43. "Interface for `ArithmeticError`"
  44. classImplements(ArithmeticError, IArithmeticError)
  45. class IAssertionError(IStandardError):
  46. "Interface for `AssertionError`"
  47. classImplements(AssertionError, IAssertionError)
  48. class IAttributeError(IStandardError):
  49. "Interface for `AttributeError`"
  50. classImplements(AttributeError, IAttributeError)
  51. class IDeprecationWarning(IWarning):
  52. "Interface for `DeprecationWarning`"
  53. classImplements(DeprecationWarning, IDeprecationWarning)
  54. class IEOFError(IStandardError):
  55. "Interface for `EOFError`"
  56. classImplements(EOFError, IEOFError)
  57. class IEnvironmentError(IStandardError):
  58. "Interface for `EnvironmentError`"
  59. classImplements(EnvironmentError, IEnvironmentError)
  60. class IFloatingPointError(IArithmeticError):
  61. "Interface for `FloatingPointError`"
  62. classImplements(FloatingPointError, IFloatingPointError)
  63. class IIOError(IEnvironmentError):
  64. "Interface for `IOError`"
  65. classImplements(IOError, IIOError)
  66. class IImportError(IStandardError):
  67. "Interface for `ImportError`"
  68. classImplements(ImportError, IImportError)
  69. class IIndentationError(ISyntaxError):
  70. "Interface for `IndentationError`"
  71. classImplements(IndentationError, IIndentationError)
  72. class IIndexError(ILookupError):
  73. "Interface for `IndexError`"
  74. classImplements(IndexError, IIndexError)
  75. class IKeyError(ILookupError):
  76. "Interface for `KeyError`"
  77. classImplements(KeyError, IKeyError)
  78. class IKeyboardInterrupt(IStandardError):
  79. "Interface for `KeyboardInterrupt`"
  80. classImplements(KeyboardInterrupt, IKeyboardInterrupt)
  81. class IMemoryError(IStandardError):
  82. "Interface for `MemoryError`"
  83. classImplements(MemoryError, IMemoryError)
  84. class INameError(IStandardError):
  85. "Interface for `NameError`"
  86. classImplements(NameError, INameError)
  87. class INotImplementedError(IRuntimeError):
  88. "Interface for `NotImplementedError`"
  89. classImplements(NotImplementedError, INotImplementedError)
  90. class IOSError(IEnvironmentError):
  91. "Interface for `OSError`"
  92. classImplements(OSError, IOSError)
  93. class IOverflowError(IArithmeticError):
  94. "Interface for `ArithmeticError`"
  95. classImplements(OverflowError, IOverflowError)
  96. class IOverflowWarning(IWarning):
  97. """Deprecated, no standard class implements this.
  98. This was the interface for ``OverflowWarning`` prior to Python 2.5,
  99. but that class was removed for all versions after that.
  100. """
  101. class IReferenceError(IStandardError):
  102. "Interface for `ReferenceError`"
  103. classImplements(ReferenceError, IReferenceError)
  104. class IRuntimeWarning(IWarning):
  105. "Interface for `RuntimeWarning`"
  106. classImplements(RuntimeWarning, IRuntimeWarning)
  107. class IStopIteration(IException):
  108. "Interface for `StopIteration`"
  109. classImplements(StopIteration, IStopIteration)
  110. class ISyntaxWarning(IWarning):
  111. "Interface for `SyntaxWarning`"
  112. classImplements(SyntaxWarning, ISyntaxWarning)
  113. class ISystemError(IStandardError):
  114. "Interface for `SystemError`"
  115. classImplements(SystemError, ISystemError)
  116. class ISystemExit(IException):
  117. "Interface for `SystemExit`"
  118. classImplements(SystemExit, ISystemExit)
  119. class ITabError(IIndentationError):
  120. "Interface for `TabError`"
  121. classImplements(TabError, ITabError)
  122. class ITypeError(IStandardError):
  123. "Interface for `TypeError`"
  124. classImplements(TypeError, ITypeError)
  125. class IUnboundLocalError(INameError):
  126. "Interface for `UnboundLocalError`"
  127. classImplements(UnboundLocalError, IUnboundLocalError)
  128. class IUnicodeError(IValueError):
  129. "Interface for `UnicodeError`"
  130. classImplements(UnicodeError, IUnicodeError)
  131. class IUserWarning(IWarning):
  132. "Interface for `UserWarning`"
  133. classImplements(UserWarning, IUserWarning)
  134. class IZeroDivisionError(IArithmeticError):
  135. "Interface for `ZeroDivisionError`"
  136. classImplements(ZeroDivisionError, IZeroDivisionError)