eE FdZddlmZddlmZGddeZGddej eZGdd eZGd d ejeZ Gd d ee Z Gdde Z GddeZ Gdde ZGddeZGddej eee e Zy)ah Mapping 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.IMapping` and :class:`~zope.interface.common.collections.IMutableMapping`. This module is occasionally useful for its extremely fine grained breakdown of interfaces. The standard library :class:`dict` and :class:`collections.UserDict` implement ``IMutableMapping``, but *do not* implement any of the interfaces in this module. ) Interface) collectionsceZdZdZdZy) IItemMappingz%Simplest readable mapping object cy)z`Get a value for a key A `KeyError` is raised if there is no value for the key. Nkeys ?/usr/lib/python3/dist-packages/zope/interface/common/mapping.py __getitem__zIItemMapping.__getitem__&N)__name__ __module__ __qualname____doc__r rrr rr"s  rrceZdZdZddZdZy) IReadMappingz^ Basic mapping interface. .. versionchanged:: 5.0.0 Extend ``IContainer`` Ncy)zaGet a value for a key The default is returned if there is no value for the key. Nrr defaults r getzIReadMapping.get5r rcy)z$Tell if a key exists in the mapping.Nrr s r __contains__zIReadMapping.__contains__;r rN)rrrrrrrrr rr-s 3rrceZdZdZdZdZy) IWriteMappingz!Mapping methods for changing datacy)z.Delete a value from the mapping using the key.Nrr s r __delitem__zIWriteMapping.__delitem__Cr rcy)zSet a new item in the mapping.Nr)r values r __setitem__zIWriteMapping.__setitem__Fr rN)rrrrrr"rrr rr@s+=-rrc(eZdZdZdZdZdZdZy)IEnumerableMappingzp Mapping objects whose items can be enumerated. .. versionchanged:: 5.0.0 Extend ``ISized`` cy)z/Return the keys of the mapping object. Nrrrr keyszIEnumerableMapping.keysRr rcy)z?Return an iterator for the keys of the mapping object. Nrrrr __iter__zIEnumerableMapping.__iter__Vr rcy)z1Return the values of the mapping object. Nrrrr valueszIEnumerableMapping.valuesZr rcy)z0Return the items of the mapping object. Nrrrr itemszIEnumerableMapping.items^r rN)rrrrr&r(r*r,rrr r$r$Js    rr$ceZdZdZy)IMappingz Simple mapping interface Nrrrrrrr r.r.bs$rr.ceZdZdZy)IIterableMappingzLA mapping that has distinct methods for iterating without copying. Nr/rrr r1r1esrr1ceZdZdZdZy)IClonableMappingzSSomething that can produce a copy of itself. This is available in `dict`. cy)zreturn copy of dictNrrrr copyzIClonableMapping.copyrr rN)rrrrr5rrr r3r3ls  rr3ceZdZdZy)IExtendedReadMappingz Something with a particular method equivalent to ``__contains__``. On Python 2, `dict` provided the ``has_key`` method, but it was removed in Python 3. Nr/rrr r7r7usrr7c2eZdZdZdZdZddZddZdZy) IExtendedWriteMappingzHAdditional mutation methods. These are all provided by `dict`. cy)zdelete all itemsNrrrr clearzIExtendedWriteMapping.clearr rcy)z0 Update D from E: for k in E.keys(): D[k] = E[k]Nr)ds r updatezIExtendedWriteMapping.updater rNcy)z@D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in DNrrs r setdefaultz IExtendedWriteMapping.setdefaultr rcy)a  pop(k[,default]) -> value Remove specified key and return the corresponding value. If key is not found, *default* is returned if given, otherwise `KeyError` is raised. Note that *default* must not be passed by name. Nr)krs r popzIExtendedWriteMapping.popr rcy)zeremove and return some (key, value) pair as a 2-tuple; but raise KeyError if mapping is emptyNrrrr popitemzIExtendedWriteMapping.popitemr rr) rrrrr;r>r@rCrErrr r9r9~s! ;K  ;rr9ceZdZdZy) IFullMappinga$ Full mapping interface. Most uses of this interface should instead use :class:`~zope.interface.commons.collections.IMutableMapping` (one of the bases of this interface). The required methods are the same. .. versionchanged:: 5.0.0 Extend ``IMutableMapping`` Nr/rrr rGrGs rrGN)rzope.interfacerzope.interface.commonrr IContainerrrISizedr$r.r1r3r7r9IMutableMappingrGrrr rMs"%- 9 3;))<3&-I- ++\ 0%}0%)y+;M;< ##35Ex r