Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
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.

builtins.py 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 for builtin types.
  14. After this module is imported, the standard library types will declare
  15. that they implement the appropriate interface.
  16. .. versionadded:: 5.0.0
  17. """
  18. from zope.interface import classImplements
  19. from zope.interface.common import collections
  20. from zope.interface.common import numbers
  21. from zope.interface.common import io
  22. __all__ = [
  23. 'IList',
  24. 'ITuple',
  25. 'ITextString',
  26. 'IByteString',
  27. 'INativeString',
  28. 'IBool',
  29. 'IDict',
  30. 'IFile',
  31. ]
  32. # pylint:disable=no-self-argument
  33. class IList(collections.IMutableSequence):
  34. """
  35. Interface for :class:`list`
  36. """
  37. extra_classes = (list,)
  38. def sort(key=None, reverse=False):
  39. """
  40. Sort the list in place and return None.
  41. *key* and *reverse* must be passed by name only.
  42. """
  43. class ITuple(collections.ISequence):
  44. """
  45. Interface for :class:`tuple`
  46. """
  47. extra_classes = (tuple,)
  48. class ITextString(collections.ISequence):
  49. """
  50. Interface for text ("unicode") strings.
  51. This is :class:`str`
  52. """
  53. extra_classes = (str,)
  54. class IByteString(collections.IByteString):
  55. """
  56. Interface for immutable byte strings.
  57. On all Python versions this is :class:`bytes`.
  58. Unlike :class:`zope.interface.common.collections.IByteString`
  59. (the parent of this interface) this does *not* include
  60. :class:`bytearray`.
  61. """
  62. extra_classes = (bytes,)
  63. class INativeString(ITextString):
  64. """
  65. Interface for native strings.
  66. On all Python versions, this is :class:`str`. Tt extends
  67. :class:`ITextString`.
  68. """
  69. # We're not extending ABCInterface so extra_classes won't work
  70. classImplements(str, INativeString)
  71. class IBool(numbers.IIntegral):
  72. """
  73. Interface for :class:`bool`
  74. """
  75. extra_classes = (bool,)
  76. class IDict(collections.IMutableMapping):
  77. """
  78. Interface for :class:`dict`
  79. """
  80. extra_classes = (dict,)
  81. class IFile(io.IIOBase):
  82. """
  83. Interface for :class:`file`.
  84. It is recommended to use the interfaces from :mod:`zope.interface.common.io`
  85. instead of this interface.
  86. On Python 3, there is no single implementation of this interface;
  87. depending on the arguments, the :func:`open` builtin can return
  88. many different classes that implement different interfaces from
  89. :mod:`zope.interface.common.io`.
  90. """
  91. extra_classes = ()