o
    9k¼b`  ã                   @   sD   d Z ddlmZ ddl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 u r
i }| j|fi |¤Ž d S ©N)r   Ú_storeÚupdate)ÚselfÚdataÚkwargs© r   ú7usr/lib/python3.10/site-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   ó   zCaseInsensitiveDict.__delitem__c                 C   ó   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   r   )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__C   s   

zCaseInsensitiveDict.__eq__c                 C   s   t | j ¡ ƒS r   )r   r   r   r   r   r   r   ÚcopyL   ó   zCaseInsensitiveDict.copyc                 C   s   t t|  ¡ ƒƒS r   )Ústrr%   r!   r   r   r   r   Ú__repr__O   r   zCaseInsensitiveDict.__repr__r   )Ú__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ƒ  ¡  d S r   )ÚnameÚsuperr   )r
   r1   ©Ú	__class__r   r   r   V   s   zLookupDict.__init__c                 C   s   d| j › dS )Nz	<lookup 'z'>)r1   r   r   r   r   r+   Z   r)   zLookupDict.__repr__c                 C   s   | j  |d ¡S r   ©Ú__dict__Úgetr   r   r   r   r   ]   s   zLookupDict.__getitem__c                 C   s   | j  ||¡S r   r5   )r
   r   Údefaultr   r   r   r7   b   r)   zLookupDict.getr   )	r,   r-   r.   r/   r   r+   r   r7   Ú__classcell__r   r   r3   r   r0   S   s    r0   N)	r/   Úcollectionsr   Úcompatr   r   r   r%   r0   r   r   r   r   Ú<module>   s
    F