3 [@sdZddlmZGdddeZGdddeZGdddeZGd d d eZGd d d eeZGd ddeZGdddeZ GdddeZ GdddeZ Gddde e e eZ dS)zyMapping Interfaces. Importing this module does *not* mark any standard classes as implementing any of these interfaces. ) Interfacec@seZdZdZddZdS) IItemMappingz%Simplest readable mapping object cCsdS)z`Get a value for a key A `KeyError` is raised if there is no value for the key. N)keyrr/usr/lib64/python3.6/mapping.py __getitem__szIItemMapping.__getitem__N)__name__ __module__ __qualname____doc__rrrrrrsrc@s"eZdZdZdddZddZdS) IReadMappingzBasic mapping interface NcCsdS)zaGet a value for a key The default is returned if there is no value for the key. Nr)rdefaultrrrget$szIReadMapping.getcCsdS)z$Tell if a key exists in the mapping.Nr)rrrr __contains__*szIReadMapping.__contains__)N)rr r r rrrrrrr s r c@s eZdZdZddZddZdS) IWriteMappingz!Mapping methods for changing datacCsdS)z.Delete a value from the mapping using the key.Nr)rrrr __delitem__1szIWriteMapping.__delitem__cCsdS)zSet a new item in the mapping.Nr)rvaluerrr __setitem__4szIWriteMapping.__setitem__N)rr r r rrrrrrr.src@s8eZdZdZddZddZddZdd Zd d Zd S) IEnumerableMappingz3Mapping objects whose items can be enumerated. cCsdS)z/Return the keys of the mapping object. Nrrrrrkeys<szIEnumerableMapping.keyscCsdS)z?Return an iterator for the keys of the mapping object. Nrrrrr__iter__@szIEnumerableMapping.__iter__cCsdS)z1Return the values of the mapping object. NrrrrrvaluesDszIEnumerableMapping.valuescCsdS)z0Return the items of the mapping object. NrrrrritemsHszIEnumerableMapping.itemscCsdS)z$Return the number of items. Nrrrrr__len__LszIEnumerableMapping.__len__N) rr r r rrrrrrrrrr8s rc@seZdZdZdS)IMappingz Simple mapping interface N)rr r r rrrrrPsrc@s(eZdZdZddZddZddZdS) IIterableMappingzA mapping that has distinct methods for iterating without copying. On Python 2, a `dict` has these methods, but on Python 3 the methods defined in `IEnumerableMapping` already iterate without copying. cCsdS)z-iterate over keys; equivalent to ``__iter__``Nrrrrriterkeys\szIIterableMapping.iterkeyscCsdS)ziterate over valuesNrrrrr itervalues_szIIterableMapping.itervaluescCsdS)ziterate over itemsNrrrrr iteritemsbszIIterableMapping.iteritemsN)rr r r rrrrrrrrSsrc@seZdZdZddZdS)IClonableMappingzSSomething that can produce a copy of itself. This is available in `dict`. cCsdS)zreturn copy of dictNrrrrrcopykszIClonableMapping.copyN)rr r r r rrrrresrc@seZdZdZddZdS)IExtendedReadMappingz Something with a particular method equivalent to ``__contains__``. On Python 2, `dict` provides this method, but it was removed in Python 3. cCsdS)zCTell if a key exists in the mapping; equivalent to ``__contains__``Nr)rrrrhas_keyvszIExtendedReadMapping.has_keyN)rr r r r"rrrrr!nsr!c@s:eZdZdZddZddZd ddZd d Zd d ZdS)IExtendedWriteMappingzHAdditional mutation methods. These are all provided by `dict`. cCsdS)zdelete all itemsNrrrrrclearszIExtendedWriteMapping.clearcCsdS)z0 Update D from E: for k in E.keys(): D[k] = E[k]Nr)drrrupdateszIExtendedWriteMapping.updateNcCsdS)z@D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in DNr)rr rrr setdefaultsz IExtendedWriteMapping.setdefaultcGsdS)zRemove specified key and return the corresponding value. ``*args`` may contain a single default value, or may not be supplied. If key is not found, default is returned if given, otherwise `KeyError` is raisedNr)kargsrrrpopszIExtendedWriteMapping.popcCsdS)zeremove and return some (key, value) pair as a 2-tuple; but raise KeyError if mapping is emptyNrrrrrpopitemszIExtendedWriteMapping.popitem)N) rr r r r$r&r'r*r+rrrrr#ys  r#c@seZdZdZdS) IFullMappingz Full mapping interface N)rr r r rrrrr,sr,N) r Zzope.interfacerrr rrrrrr!r#r,rrrrs