o $ x`@sdZdZddlmZddlmZddlmZGdddej Z Gdd d ej e Z Gd d d ej e ZGd d d eZGdddeZGdddeZGdddeeZdS)a Sequence Interfaces Importing this module does *not* mark any standard classes as implementing any of these interfaces. While this module is not deprecated, new code should generally use :mod:`zope.interface.common.collections`, specifically :class:`~zope.interface.common.collections.ISequence` and :class:`~zope.interface.common.collections.IMutableSequence`. This module is occasionally useful for its fine-grained breakdown of interfaces. The standard library :class:`list`, :class:`tuple` and :class:`collections.UserList`, among others, implement ``ISequence`` or ``IMutableSequence`` but *do not* implement any of the interfaces in this module. restructuredtext) Interface) collections)PYTHON2c@eZdZdZddZdS)IMinimalSequenceaMost basic sequence interface. All sequences are iterable. This requires at least one of the following: - a `__getitem__()` method that takes a single argument; integer values starting at 0 must be supported, and `IndexError` should be raised for the first index for which there is no value, or - an `__iter__()` method that returns an iterator as defined in the Python documentation (http://docs.python.org/lib/typeiter.html). cCdS)z``x.__getitem__(index) <==> x[index]`` Declaring this interface does not specify whether `__getitem__` supports slice objects.Nindexr r @/usr/lib/python3/dist-packages/zope/interface/common/sequence.py __getitem__4zIMinimalSequence.__getitem__N)__name__ __module__ __qualname____doc__r r r r r r%s rc@eZdZdZdS)IFiniteSequencez[ A sequence of bound size. .. versionchanged:: 5.0.0 Extend ``ISized`` Nrrrrr r r r r:rc@speZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ er6ddZdSdS) IReadSequencea. read interface shared by tuple and list This interface is similar to :class:`~zope.interface.common.collections.ISequence`, but requires that all instances be totally ordered. Most users should prefer ``ISequence``. .. versionchanged:: 5.0.0 Extend ``IContainer`` cCr)z'``x.__contains__(item) <==> item in x``Nr itemr r r __contains__OrzIReadSequence.__contains__cCr)z"``x.__lt__(other) <==> x < other``Nr otherr r r __lt__SrzIReadSequence.__lt__cCr)z#``x.__le__(other) <==> x <= other``Nr rr r r __le__VrzIReadSequence.__le__cCr)z#``x.__eq__(other) <==> x == other``Nr rr r r __eq__YrzIReadSequence.__eq__cCr)z#``x.__ne__(other) <==> x != other``Nr rr r r __ne__\rzIReadSequence.__ne__cCr)z"``x.__gt__(other) <==> x > other``Nr rr r r __gt___rzIReadSequence.__gt__cCr)z#``x.__ge__(other) <==> x >= other``Nr rr r r __ge__brzIReadSequence.__ge__cCr)z#``x.__add__(other) <==> x + other``Nr rr r r __add__erzIReadSequence.__add__cCr)z``x.__mul__(n) <==> x * n``Nr nr r r __mul__hrzIReadSequence.__mul__cCr)z``x.__rmul__(n) <==> n * x``Nr r$r r r __rmul__krzIReadSequence.__rmul__cCr)z``x.__getslice__(i, j) <==> x[i:j]`` Use of negative indices is not supported. Deprecated since Python 2.0 but still a part of `UserList`. Nr ijr r r __getslice__orzIReadSequence.__getslice__N)rrrrrrrrr r!r"r#r&r'PY2r+r r r r rBs  rc@s eZdZdZddZddZdS)IExtendedReadSequencezFull read interface for listscCr)z%Return number of occurrences of valueNr rr r r countzrzIExtendedReadSequence.countcGr)zTindex(value, [start, [stop]]) -> int Return first index of *value* Nr )rargsr r r r }rzIExtendedReadSequence.indexN)rrrrr.r r r r r r-ws r-c@sxeZdZdZddZddZerddZdd Zd d Z d d Z ddZ dddZ ddZ ddZdddZddZdS)IUniqueMemberWriteSequencezAThe write contract for a sequence that may enforce unique memberscCr)z``x.__setitem__(index, item) <==> x[index] = item`` Declaring this interface does not specify whether `__setitem__` supports slice objects. Nr r rr r r __setitem__rz&IUniqueMemberWriteSequence.__setitem__cCr)z``x.__delitem__(index) <==> del x[index]`` Declaring this interface does not specify whether `__delitem__` supports slice objects. Nr r r r r __delitem__rz&IUniqueMemberWriteSequence.__delitem__cCr)z``x.__setslice__(i, j, other) <==> x[i:j] = other`` Use of negative indices is not supported. Deprecated since Python 2.0 but still a part of `UserList`. Nr )r)r*rr r r __setslice__rz'IUniqueMemberWriteSequence.__setslice__cCr)z``x.__delslice__(i, j) <==> del x[i:j]`` Use of negative indices is not supported. Deprecated since Python 2.0 but still a part of `UserList`. Nr r(r r r __delslice__rz'IUniqueMemberWriteSequence.__delslice__cCr)z``x.__iadd__(y) <==> x += y``Nr )yr r r __iadd__rz#IUniqueMemberWriteSequence.__iadd__cCr)zAppend item to endNr rr r r appendrz!IUniqueMemberWriteSequence.appendcCr)zInsert item before indexNr r1r r r insertrz!IUniqueMemberWriteSequence.insertcCr)z.Remove and return item at index (default last)Nr r r r r poprzIUniqueMemberWriteSequence.popcCr)z Remove first occurrence of valueNr rr r r removerz!IUniqueMemberWriteSequence.removecCr)zReverse *IN PLACE*Nr r r r r reverserz"IUniqueMemberWriteSequence.reverseNcCr)z3Stable sort *IN PLACE*; `cmpfunc(x, y)` -> -1, 0, 1Nr )cmpfuncr r r sortrzIUniqueMemberWriteSequence.sortcCr)z3Extend list by appending elements from the iterableNr )iterabler r r extendrz!IUniqueMemberWriteSequence.extend)r:)N)rrrrr2r3r,r4r5r7r8r9r;r<r=r?rAr r r r r0s   r0c@r)IWriteSequencez!Full write contract for sequencescCr)z``x.__imul__(n) <==> x *= n``Nr r$r r r __imul__rzIWriteSequence.__imul__N)rrrrrCr r r r rBs rBc@r) ISequencea Full sequence contract. New code should prefer :class:`~zope.interface.common.collections.IMutableSequence`. Compared to that interface, which is implemented by :class:`list` (:class:`~zope.interface.common.builtins.IList`), among others, this interface is missing the following methods: - clear - count - index This interface adds the following methods: - sort Nrr r r r rDrrDN)r __docformat__zope.interfacerzope.interface.commonrzope.interface._compatrr, IIterablerISizedr IContainerrr-r0rBrDr r r r s    5 :