io.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ##############################################################################
  2. # Copyright (c) 2020 Zope Foundation and Contributors.
  3. # All Rights Reserved.
  4. #
  5. # This software is subject to the provisions of the Zope Public License,
  6. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  7. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  8. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  10. # FOR A PARTICULAR PURPOSE.
  11. ##############################################################################
  12. """
  13. Interface definitions paralleling the abstract base classes defined in
  14. :mod:`io`.
  15. After this module is imported, the standard library types will declare
  16. that they implement the appropriate interface.
  17. .. versionadded:: 5.0.0
  18. """
  19. from __future__ import absolute_import
  20. import io as abc
  21. from zope.interface.common import ABCInterface
  22. # pylint:disable=inherit-non-class,
  23. # pylint:disable=no-member
  24. class IIOBase(ABCInterface):
  25. abc = abc.IOBase
  26. class IRawIOBase(IIOBase):
  27. abc = abc.RawIOBase
  28. class IBufferedIOBase(IIOBase):
  29. abc = abc.BufferedIOBase
  30. try:
  31. import cStringIO
  32. except ImportError:
  33. # Python 3
  34. extra_classes = ()
  35. else:
  36. import StringIO
  37. extra_classes = (StringIO.StringIO, cStringIO.InputType, cStringIO.OutputType)
  38. del cStringIO
  39. del StringIO
  40. class ITextIOBase(IIOBase):
  41. abc = abc.TextIOBase