Your IP : 3.135.208.236


Current Path : /usr/lib/python3.6/site-packages/urllib3/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/urllib3/__pycache__/_collections.cpython-36.pyc

3

h��f+,�@s�ddlmZyddlmZmZWn$ek
rDddlmZmZYnXyddlmZWn"ek
rxGdd�d�ZYnXddlm	Z	ddl
mZdd	lm
Z
mZmZd
dgZe�ZGdd
�d
e�ZGd
d�de�ZdS)�)�absolute_import)�Mapping�MutableMapping)�RLockc@seZdZdd�Zdd�ZdS)rcCsdS)N�)�selfrr�"/usr/lib/python3.6/_collections.py�	__enter__
szRLock.__enter__cCsdS)Nr)r�exc_type�	exc_value�	tracebackrrr�__exit__
szRLock.__exit__N)�__name__�
__module__�__qualname__r	r
rrrrr	sr)�OrderedDict�)�
InvalidHeader)�iterkeys�
itervalues�PY3�RecentlyUsedContainer�HTTPHeaderDictc@sVeZdZdZeZddd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dS)ra�
    Provides a thread-safe dict-like container which maintains up to
    ``maxsize`` keys while throwing away the least-recently-used keys beyond
    ``maxsize``.

    :param maxsize:
        Maximum number of recent elements to retain.

    :param dispose_func:
        Every time an item is evicted from the container,
        ``dispose_func(value)`` is called.  Callback which will get called
    �
NcCs"||_||_|j�|_t�|_dS)N)�_maxsize�dispose_func�ContainerCls�
_containerr�lock)r�maxsizerrrr�__init__,s
zRecentlyUsedContainer.__init__c
Cs,|j�|jj|�}||j|<|SQRXdS)N)rr�pop)r�key�itemrrr�__getitem__3s
z!RecentlyUsedContainer.__getitem__c
Cslt}|j�@|jj|t�}||j|<t|j�|jkrF|jjdd�\}}WdQRX|jrh|tk	rh|j|�dS)NF)Zlast)�_Nullrr�get�lenr�popitemr)rr"�valueZ
evicted_valueZ_keyrrr�__setitem__:s
z!RecentlyUsedContainer.__setitem__c	Cs2|j�|jj|�}WdQRX|jr.|j|�dS)N)rrr!r)rr"r)rrr�__delitem__Isz!RecentlyUsedContainer.__delitem__c	Cs|j�t|j�SQRXdS)N)rr'r)rrrr�__len__PszRecentlyUsedContainer.__len__cCstd��dS)Nz7Iteration over this class is unlikely to be threadsafe.)�NotImplementedError)rrrr�__iter__TszRecentlyUsedContainer.__iter__c
CsL|j�tt|j��}|jj�WdQRX|jrHx|D]}|j|�q6WdS)N)r�listrr�clearr)r�valuesr)rrrr0Ws
zRecentlyUsedContainer.clearc
Cs |j�tt|j��SQRXdS)N)rr/rr)rrrr�keysaszRecentlyUsedContainer.keys)rN)rrr�__doc__rrr r$r*r+r,r.r0r2rrrrrs

cs�eZdZdZd/�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
esZej
Z
ejZe�Zdd�Zdd�Zefdd�Zdd�Zdd�Zdd�Zefdd�Zdd �ZeZeZeZeZd!d"�Zd#d$�Zd%d&�Zd'd(�Z d)d*�Z!d+d,�Z"e#d-d.��Z$�Z%S)0rap
    :param headers:
        An iterable of field-value pairs. Must not contain multiple field names
        when compared case-insensitively.

    :param kwargs:
        Additional field-value pairs to pass in to ``dict.update``.

    A ``dict`` like container for storing HTTP Headers.

    Field names are stored and compared case-insensitively in compliance with
    RFC 7230. Iteration provides the first case-sensitive key seen for each
    case-insensitive pair.

    Using ``__setitem__`` syntax overwrites fields that compare equal
    case-insensitively in order to maintain ``dict``'s api. For fields that
    compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add``
    in a loop.

    If multiple fields that are equal case-insensitively are passed to the
    constructor or ``.update``, the behavior is undefined and some will be
    lost.

    >>> headers = HTTPHeaderDict()
    >>> headers.add('Set-Cookie', 'foo=bar')
    >>> headers.add('set-cookie', 'baz=quxx')
    >>> headers['content-length'] = '7'
    >>> headers['SET-cookie']
    'foo=bar, baz=quxx'
    >>> headers['Content-Length']
    '7'
    NcsPtt|�j�t�|_|dk	r>t|t�r4|j|�n
|j|�|rL|j|�dS)N)�superrr rr�
isinstance�
_copy_from�extend)r�headers�kwargs)�	__class__rrr �s

zHTTPHeaderDict.__init__cCs ||g|j|j�<|j|j�S)N)r�lower)rr"�valrrrr*�szHTTPHeaderDict.__setitem__cCs |j|j�}dj|dd��S)Nz, r)rr;�join)rr"r<rrrr$�szHTTPHeaderDict.__getitem__cCs|j|j�=dS)N)rr;)rr"rrrr+�szHTTPHeaderDict.__delitem__cCs|j�|jkS)N)r;r)rr"rrr�__contains__�szHTTPHeaderDict.__contains__cCsbt|t�rt|d�rdSt|t|��s6t|�|�}tdd�|j�D��tdd�|j�D��kS)Nr2Fcss|]\}}|j�|fVqdS)N)r;)�.0�k�vrrr�	<genexpr>�sz(HTTPHeaderDict.__eq__.<locals>.<genexpr>css|]\}}|j�|fVqdS)N)r;)r?r@rArrrrB�s)r5r�hasattr�type�dict�
itermerged)r�otherrrr�__eq__�szHTTPHeaderDict.__eq__cCs|j|�S)N)rH)rrGrrr�__ne__�szHTTPHeaderDict.__ne__cCs
t|j�S)N)r'r)rrrrr,�szHTTPHeaderDict.__len__ccs"x|jj�D]}|dVqWdS)Nr)rr1)r�valsrrrr.�szHTTPHeaderDict.__iter__cCs<y||}Wn tk
r,||jkr(�|SX||=|SdS)z�D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
          If key is not found, d is returned if given, otherwise KeyError is raised.
        N)�KeyError�_HTTPHeaderDict__marker)rr"�defaultr)rrrr!�s
zHTTPHeaderDict.popcCs$y
||=Wntk
rYnXdS)N)rK)rr"rrr�discard�s
zHTTPHeaderDict.discardcCs4|j�}||g}|jj||�}||k	r0|j|�dS)z�Adds a (name, value) pair, doesn't overwrite the value if it already
        exists.

        >>> headers = HTTPHeaderDict(foo='bar')
        >>> headers.add('Foo', 'baz')
        >>> headers['foo']
        'bar, baz'
        N)r;r�
setdefault�append)rr"r<Z	key_lowerZnew_valsrJrrr�add�s
	zHTTPHeaderDict.addcOst|�dkrtdjt|����t|�dkr2|dnf}t|t�rdx�|j�D]\}}|j||�qJWnvt|t�r�xj|D]}|j|||�qtWnLt|d�r�x@|j	�D]}|j|||�q�Wnx|D]\}}|j||�q�Wx |j
�D]\}}|j||�q�WdS)z�Generic import function for any type of header-like object.
        Adapted version of MutableMapping.update in order to insert items
        with self.add instead of self.__setitem__
        rz9extend() takes at most 1 positional arguments ({0} given)rr2N)r'�	TypeError�formatr5r�	iteritemsrQrrCr2�items)r�argsr9rGr"r<r)rrrr7�s"



zHTTPHeaderDict.extendcCsFy|j|j�}Wn"tk
r4||jkr0gS|SX|dd�SdS)zmReturns a list of all the values for the named field. Returns an
        empty list if the key doesn't exist.rN)rr;rKrL)rr"rMrJrrr�getlist�s
zHTTPHeaderDict.getlistcCs.dddddddg}x|D]}|j|�qW|S)z�
        Remove content-specific header fields before changing the request
        method to GET or HEAD according to RFC 9110, Section 15.4.
        zContent-EncodingzContent-LanguagezContent-LocationzContent-TypezContent-LengthZDigestz
Last-Modified)rN)rZcontent_specific_headers�headerrrr�_prepare_for_method_changes
z)HTTPHeaderDict._prepare_for_method_changecCsdt|�jt|j��fS)Nz%s(%s))rDrrErF)rrrr�__repr__!szHTTPHeaderDict.__repr__cCsBx<|D]4}|j|�}t|t�r&t|�}|g||j|j�<qWdS)N)rWr5r/rr;)rrGr"r<rrrr6$s



zHTTPHeaderDict._copy_fromcCst|��}|j|�|S)N)rDr6)rZclonerrr�copy,s

zHTTPHeaderDict.copyccsDx>|D]6}|j|j�}x"|dd�D]}|d|fVq&WqWdS)z8Iterate over all header lines, including duplicate ones.rNr)rr;)rr"rJr<rrrrT1s
zHTTPHeaderDict.iteritemsccs<x6|D].}|j|j�}|ddj|dd��fVqWdS)z:Iterate over all headers, merging duplicate ones together.rz, rN)rr;r=)rr"r<rrrrF8s
zHTTPHeaderDict.itermergedcCst|j��S)N)r/rT)rrrrrU>szHTTPHeaderDict.itemscCs�d}g}xr|jD]h}|j|�rV|s0td|��n&|d\}}||d|j�f|d<q|jdd�\}}|j||j�f�qW||�S)	z4Read headers from a Python 2 httplib message object.� �	z/Header continuation with no previous header: %sr�:)r\r]���r_)r8�
startswithr�strip�splitrP)�cls�messageZobs_fold_continued_leadersr8�liner"r)rrr�from_httplibAs
zHTTPHeaderDict.from_httplib)N)&rrrr3r r*r$r+r>rHrIrrrr�objectrLr,r.r!rNrQr7rWrYZ
getheadersZgetallmatchingheadersZigetZget_allrZr6r[rTrFrU�classmethodrf�
__classcell__rr)r:rrfs> N)Z
__future__r�collections.abcrr�ImportError�collectionsZ	threadingrr�
exceptionsrZpackages.sixrrr�__all__rgr%rrrrrr�<module>sJ

?>