o
    $x`R                     @   s   d Z ddlmZ ddlmZ ddlmZ G dd deZG dd dej	eZ
G d	d
 d
eZG dd deje
ZG dd deeZG dd deZG dd deZG dd deZG dd deZG dd dejeeeeZdS )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)PYTHON2)collectionsc                   @      e Zd ZdZdd ZdS )IItemMappingz%Simplest readable mapping object
    c                 C      dS )z`Get a value for a key

        A `KeyError` is raised if there is no value for the key.
        N keyr   r   ?/usr/lib/python3/dist-packages/zope/interface/common/mapping.py__getitem__'       zIItemMapping.__getitem__N)__name__
__module____qualname____doc__r   r   r   r   r   r   #   s    r   c                   @   s"   e Zd ZdZdddZdd ZdS )IReadMappingz^
    Basic mapping interface.

    .. versionchanged:: 5.0.0
       Extend ``IContainer``
    Nc                 C   r   )zaGet a value for a key

        The default is returned if there is no value for the key.
        Nr   r
   defaultr   r   r   get6   r   zIReadMapping.getc                 C   r   )z$Tell if a key exists in the mapping.Nr   r	   r   r   r   __contains__<   r   zIReadMapping.__contains__N)r   r   r   r   r   r   r   r   r   r   r   .   s    
r   c                   @   s    e Zd ZdZdd Zdd ZdS )IWriteMappingz!Mapping methods for changing datac                 C   r   )z.Delete a value from the mapping using the key.Nr   r	   r   r   r   __delitem__D   r   zIWriteMapping.__delitem__c                 C   r   )zSet a new item in the mapping.Nr   )r
   valuer   r   r   __setitem__G   r   zIWriteMapping.__setitem__N)r   r   r   r   r   r   r   r   r   r   r   A   s    r   c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )IEnumerableMappingzp
    Mapping objects whose items can be enumerated.

    .. versionchanged:: 5.0.0
       Extend ``ISized``
    c                   C   r   )z/Return the keys of the mapping object.
        Nr   r   r   r   r   keysS   r   zIEnumerableMapping.keysc                   C   r   )z?Return an iterator for the keys of the mapping object.
        Nr   r   r   r   r   __iter__W   r   zIEnumerableMapping.__iter__c                   C   r   )z1Return the values of the mapping object.
        Nr   r   r   r   r   values[   r   zIEnumerableMapping.valuesc                   C   r   )z0Return the items of the mapping object.
        Nr   r   r   r   r   items_   r   zIEnumerableMapping.itemsN)r   r   r   r   r   r   r   r    r   r   r   r   r   K   s    r   c                   @      e Zd ZdZdS )IMappingz Simple mapping interface Nr   r   r   r   r   r   r   r   r"   c   s    r"   c                   @   s0   e Zd ZdZerdd Zdd Zdd ZdS dS )	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.
    c                   C   r   )z-iterate over keys; equivalent to ``__iter__``Nr   r   r   r   r   iterkeysp   r   zIIterableMapping.iterkeysc                   C   r   )ziterate over valuesNr   r   r   r   r   
itervaluess   r   zIIterableMapping.itervaluesc                   C   r   )ziterate over itemsNr   r   r   r   r   	iteritemsv   r   zIIterableMapping.iteritemsN)r   r   r   r   PY2r%   r&   r'   r   r   r   r   r$   f   s    r$   c                   @   r   )IClonableMappingzSSomething that can produce a copy of itself.

    This is available in `dict`.
    c                   C   r   )zreturn copy of dictNr   r   r   r   r   copy   r   zIClonableMapping.copyN)r   r   r   r   r*   r   r   r   r   r)   y   s    r)   c                   @   s    e Zd ZdZerdd ZdS dS )IExtendedReadMappingz
    Something with a particular method equivalent to ``__contains__``.

    On Python 2, `dict` provides this method, but it was removed
    in Python 3.
    c                 C   r   )zCTell if a key exists in the mapping; equivalent to ``__contains__``Nr   r	   r   r   r   has_key   r   zIExtendedReadMapping.has_keyN)r   r   r   r   r(   r,   r   r   r   r   r+      s
    r+   c                   @   s<   e Zd ZdZdd Zdd ZdddZdd	d
Zdd ZdS )IExtendedWriteMappingzHAdditional mutation methods.

    These are all provided by `dict`.
    c                   C   r   )zdelete all itemsNr   r   r   r   r   clear   r   zIExtendedWriteMapping.clearc                 C   r   )z0 Update D from E: for k in E.keys(): D[k] = E[k]Nr   )dr   r   r   update   r   zIExtendedWriteMapping.updateNc                 C   r   )z@D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in DNr   r   r   r   r   
setdefault   r   z IExtendedWriteMapping.setdefaultc                 C   r   )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   )kr   r   r   r   pop   r   zIExtendedWriteMapping.popc                   C   r   )zeremove and return some (key, value) pair as a
        2-tuple; but raise KeyError if mapping is emptyNr   r   r   r   r   popitem   r   zIExtendedWriteMapping.popitemr   )	r   r   r   r   r.   r0   r1   r3   r4   r   r   r   r   r-      s    

r-   c                   @   r!   )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#   r   r   r   r   r5      s    r5   N)r   zope.interfacer   zope.interface._compatr   r(   zope.interface.commonr   r   
IContainerr   r   ISizedr   r"   r$   r)   r+   r-   IMutableMappingr5   r   r   r   r   <module>   s"   
	
