U
    (qÝ\¥  ã                   @   s<   d Z ddlmZmZmZ G dd„ deƒZG dd„ deƒZdS )zO
requests.structures
~~~~~~~~~~~~~~~~~~~

Data structures that power Requests.
é   )ÚOrderedDictÚMappingÚMutableMappingc                   @   sb   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚCaseInsensitiveDictaÖ  A case-insensitive ``dict``-like object.

    Implements all methods and operations of
    ``MutableMapping`` as well as dict's ``copy``. Also
    provides ``lower_items``.

    All keys are expected to be strings. The structure remembers the
    case of the last key to be set, and ``iter(instance)``,
    ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()``
    will contain case-sensitive keys. However, querying and contains
    testing is case insensitive::

        cid = CaseInsensitiveDict()
        cid['Accept'] = 'application/json'
        cid['aCCEPT'] == 'application/json'  # True
        list(cid) == ['Accept']  # True

    For example, ``headers['content-encoding']`` will return the
    value of a ``'Content-Encoding'`` response header, regardless
    of how the header name was originally stored.

    If the constructor, ``.update``, or equality comparison
    operations are given keys that have equal ``.lower()``s, the
    behavior is undefined.
    Nc                 K   s&   t ƒ | _|d kri }| j|f|Ž d S ©N)r   Ú_storeÚupdate)ÚselfÚdataÚkwargs© r   ú5/usr/lib/python3/dist-packages/requests/structures.pyÚ__init__(   s    zCaseInsensitiveDict.__init__c                 C   s   ||f| j | ¡ < d S r   ©r   Úlower)r	   ÚkeyÚvaluer   r   r   Ú__setitem__.   s    zCaseInsensitiveDict.__setitem__c                 C   s   | j | ¡  d S )Nr   r   ©r	   r   r   r   r   Ú__getitem__3   s    zCaseInsensitiveDict.__getitem__c                 C   s   | j | ¡ = d S r   r   r   r   r   r   Ú__delitem__6   s    zCaseInsensitiveDict.__delitem__c                 C   s   dd„ | j  ¡ D ƒS )Nc                 s   s   | ]\}}|V  qd S r   r   )Ú.0ZcasedkeyZmappedvaluer   r   r   Ú	<genexpr>:   s     z/CaseInsensitiveDict.__iter__.<locals>.<genexpr>)r   Úvalues©r	   r   r   r   Ú__iter__9   s    zCaseInsensitiveDict.__iter__c                 C   s
   t | jƒS r   )Úlenr   r   r   r   r   Ú__len__<   s    zCaseInsensitiveDict.__len__c                 C   s   dd„ | j  ¡ D ƒS )z.Like iteritems(), but with all lowercase keys.c                 s   s   | ]\}}||d  fV  qdS )r   Nr   )r   ZlowerkeyZkeyvalr   r   r   r   A   s   ÿz2CaseInsensitiveDict.lower_items.<locals>.<genexpr>)r   Úitemsr   r   r   r   Úlower_items?   s    ýzCaseInsensitiveDict.lower_itemsc                 C   s0   t |tƒrt|ƒ}ntS t|  ¡ ƒt| ¡ ƒkS r   )Ú
isinstancer   r   ÚNotImplementedÚdictr   )r	   Úotherr   r   r   Ú__eq__G   s    

zCaseInsensitiveDict.__eq__c                 C   s   t | j ¡ ƒS r   )r   r   r   r   r   r   r   ÚcopyP   s    zCaseInsensitiveDict.copyc                 C   s   t t|  ¡ ƒƒS r   )Ústrr"   r   r   r   r   r   Ú__repr__S   s    zCaseInsensitiveDict.__repr__)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r$   r%   r'   r   r   r   r   r      s   
	r   c                       s<   e Zd ZdZd‡ fdd„	Zdd„ Zdd„ Zdd	d
„Z‡  ZS )Ú
LookupDictzDictionary lookup object.Nc                    s   || _ tt| ƒ ¡  d S r   )ÚnameÚsuperr,   r   )r	   r-   ©Ú	__class__r   r   r   Z   s    zLookupDict.__init__c                 C   s
   d| j  S )Nz<lookup '%s'>)r-   r   r   r   r   r'   ^   s    zLookupDict.__repr__c                 C   s   | j  |d ¡S r   ©Ú__dict__Úgetr   r   r   r   r   a   s    zLookupDict.__getitem__c                 C   s   | j  ||¡S r   r1   )r	   r   Údefaultr   r   r   r3   f   s    zLookupDict.get)N)N)	r(   r)   r*   r+   r   r'   r   r3   Ú__classcell__r   r   r/   r   r,   W   s
   r,   N)r+   Úcompatr   r   r   r   r"   r,   r   r   r   r   Ú<module>   s   J