Your IP : 3.138.60.175


Current Path : /opt/alt/python37/lib/python3.7/site-packages/urllib3/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/urllib3/__pycache__/_collections.cpython-37.pyc

B

��`;*�@s�ddlmZyddlmZmZWn$ek
rDddlmZmZYnXyddlmZWn"ek
rxGdd�d�ZYnXddlm	Z	ddl
mZdd	lm
Z
dd
lmZmZddgZe�ZGd
d�de�ZGdd�de�ZdS)�)�absolute_import)�Mapping�MutableMapping)�RLockc@seZdZdd�Zdd�ZdS)rcCsdS)N�)�selfrr�E/opt/alt/python37/lib/python3.7/site-packages/urllib3/_collections.py�	__enter__szRLock.__enter__cCsdS)Nr)r�exc_type�	exc_value�	tracebackrrr�__exit__szRLock.__exit__N)�__name__�
__module__�__qualname__r	r
rrrrrsr)�OrderedDict�)�
InvalidHeader)�six)�iterkeys�
itervalues�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"||_||_|��|_t�|_dS)N)�_maxsize�dispose_func�ContainerCls�
_containerr�lock)r�maxsizerrrr�__init__/s
zRecentlyUsedContainer.__init__c	Cs,|j�|j�|�}||j|<|SQRXdS)N)rr�pop)r�key�itemrrr�__getitem__6s
z!RecentlyUsedContainer.__getitem__c	Cslt}|j�@|j�|t�}||j|<t|j�|jkrF|jjdd�\}}WdQRX|jrh|tk	rh|�|�dS)NF)�last)�_Nullrr�get�lenr�popitemr)rr"�valueZ
evicted_value�_keyrrr�__setitem__=s
z!RecentlyUsedContainer.__setitem__c	Cs2|j�|j�|�}WdQRX|jr.|�|�dS)N)rrr!r)rr"r*rrr�__delitem__Lsz!RecentlyUsedContainer.__delitem__c	Cs|j�t|j�SQRXdS)N)rr(r)rrrr�__len__SszRecentlyUsedContainer.__len__cCstd��dS)Nz7Iteration over this class is unlikely to be threadsafe.)�NotImplementedError)rrrr�__iter__WszRecentlyUsedContainer.__iter__c	CsL|j�tt|j��}|j��WdQRX|jrHx|D]}|�|�q6WdS)N)r�listrr�clearr)r�valuesr*rrrr2\s
zRecentlyUsedContainer.clearc	Cs |j�tt|j��SQRXdS)N)rr1rr)rrrr�keysfszRecentlyUsedContainer.keys)rN)rrr�__doc__rrr r$r,r-r.r0r2r4rrrrrs

cs�eZdZdZd-�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ejr\e
jZe
jZe�Zdd�Zdd�Zefdd�Zdd�Zdd�Zdd�Zefdd�ZeZeZeZeZdd �Zd!d"�Zd#d$�Zd%d&�Z d'd(�Z!d)d*�Z"e#d+d,��Z$�Z%S).rap
    :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|���t�|_|dk	r>t|t�r4|�|�n
|�|�|rL|�|�dS)N)�superrr rr�
isinstance�
_copy_from�extend)r�headers�kwargs)�	__class__rrr �s

zHTTPHeaderDict.__init__cCs ||g|j|��<|j|��S)N)r�lower)rr"�valrrrr,�szHTTPHeaderDict.__setitem__cCs |j|��}d�|dd��S)Nz, r)rr=�join)rr"r>rrrr$�szHTTPHeaderDict.__getitem__cCs|j|��=dS)N)rr=)rr"rrrr-�szHTTPHeaderDict.__delitem__cCs|��|jkS)N)r=r)rr"rrr�__contains__�szHTTPHeaderDict.__contains__cCs^t|t�st|d�sdSt|t|��s2t|�|�}tdd�|��D��tdd�|��D��kS)Nr4Fcss|]\}}|��|fVqdS)N)r=)�.0�k�vrrr�	<genexpr>�sz(HTTPHeaderDict.__eq__.<locals>.<genexpr>css|]\}}|��|fVqdS)N)r=)rArBrCrrrrD�s)r7r�hasattr�type�dict�
itermerged)r�otherrrr�__eq__�szHTTPHeaderDict.__eq__cCs|�|�S)N)rJ)rrIrrr�__ne__�szHTTPHeaderDict.__ne__cCs
t|j�S)N)r(r)rrrrr.�szHTTPHeaderDict.__len__ccs"x|j��D]}|dVqWdS)Nr)rr3)r�valsrrrr0�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)rM)rr"rrr�discard�s
zHTTPHeaderDict.discardcCs4|��}||g}|j�||�}||k	r0|�|�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_valsrLrrr�add�s
	zHTTPHeaderDict.addcOst|�dkrtd�t|����t|�dkr2|dnd}t|t�rdx�|��D]\}}|�||�qJWnvt|t�r�xj|D]}|�|||�qtWnLt|d�r�x@|�	�D]}|�|||�q�Wnx|D]\}}|�||�q�Wx |�
�D]\}}|�||�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)rrr4N)r(�	TypeError�formatr7r�	iteritemsrSrrEr4�items)r�argsr;rIr"r>r*rrrr9�s$



zHTTPHeaderDict.extendcCsFy|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=rMrN)rr"rOrLrrr�getlists
zHTTPHeaderDict.getlistcCsdt|�jt|���fS)Nz%s(%s))rFrrGrH)rrrr�__repr__szHTTPHeaderDict.__repr__cCsBx<|D]4}|�|�}t|t�r&t|�}|g||j|��<qWdS)N)rYr7r1rr=)rrIr"r>rrrr8s



zHTTPHeaderDict._copy_fromcCst|��}|�|�|S)N)rFr8)r�clonerrr�copy"s

zHTTPHeaderDict.copyccsDx>|D]6}|j|��}x"|dd�D]}|d|fVq&WqWdS)z8Iterate over all header lines, including duplicate ones.rNr)rr=)rr"rLr>rrrrV's
zHTTPHeaderDict.iteritemsccs<x6|D].}|j|��}|dd�|dd��fVqWdS)z:Iterate over all headers, merging duplicate ones together.rz, rN)rr=r?)rr"r>rrrrH.s
zHTTPHeaderDict.itermergedcCst|���S)N)r1rV)rrrrrW4szHTTPHeaderDict.itemscCs�d}g}xr|jD]h}|�|�rV|s0td|��n&|d\}}||d|��f|d<q|�dd�\}}|�||��f�qW||�S)z4Read headers from a Python 2 httplib message object.)� �	z/Header continuation with no previous header: %s���r]�:r)r:�
startswithr�strip�splitrR)�cls�messageZobs_fold_continued_leadersr:�liner"r*rrr�from_httplib7s
zHTTPHeaderDict.from_httplib)N)&rrrr5r r,r$r-r@rJrKr�PY2rrr�objectrNr.r0r!rPrSr9rYZ
getheadersZgetallmatchingheadersZiget�get_allrZr8r\rVrHrW�classmethodrg�
__classcell__rr)r<rrks< 	
N)�
__future__r�collections.abcrr�ImportError�collections�	threadingrr�
exceptionsr�packagesrZpackages.sixrr�__all__rir&rrrrrr�<module>s L

?>