Current File : //usr/lib/python3/dist-packages/urllib3/__pycache__/_collections.cpython-312.pyc
�

�g�C��j�ddlmZddlZddlmZddlmZmZddlm	Z	ejrddlmZm
Z
Gd�de�Zd	d
gZej d�Zej d�Zej d
�Zej(d
ej*eefej.ej0eefdfZGd�de�Z				dd�ZGd�d	ej8eefej:eef�ZGd�dej>ej0eef�Z Gd�d
ej:eef�Z!y)�)�annotationsN)�OrderedDict)�Enum�auto)�RLock)�Protocol�Selfc��eZdZdd�Zdd�Zy)�HasGettableStringKeysc��y�N���selfs �6/usr/lib/python3/dist-packages/urllib3/_collections.py�keyszHasGettableStringKeys.keys����c��yr
r�r�keys  r�__getitem__z!HasGettableStringKeys.__getitem__rrN��returnztyping.Iterator[str]�r�strrr)�__name__�
__module__�__qualname__rrrrrrr
s��	�	rr�RecentlyUsedContainer�HTTPHeaderDict�_KT�_VT�_DTc��eZdZe�Zy)�	_SentinelN)rrrr�
not_passedrrrr&r&'s	����Jrr&c���t|t�r|St|tj�r1tjtjt
t
f|�St|tj�rBtjtjtjt
t
f|�St|d�r"t|d�rtjd|�Sy)Nrrr)	�
isinstancer!�typing�Mapping�castr�Iterable�Tuple�hasattr)�	potentials r�%ensure_can_construct_http_header_dictr1+s����)�^�,���	�I�v�~�~�	.��{�{�6�>�>�#�s�(�3�Y�?�?�	�I�v���	/��{�{�6�?�?�6�<�<��S��+A�B�I�N�N�	��F�	#��	�=�(I��{�{�2�I�>�>�rc���eZdZUdZded<ded<ded<ded	<		d					d�fd
�
Zdd�Zdd�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Z�xZ
S)r a�
    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
    ztyping.OrderedDict[_KT, _VT]�
_container�int�_maxsize�#typing.Callable[[_VT], None] | None�dispose_funcr�lockc�z��t�|��||_||_t	�|_t
�|_yr
)�super�__init__r5r7rr3rr8)r�maxsizer7�	__class__s   �rr;zRecentlyUsedContainer.__init__Rs1���
	������
�(���%�-����G��	rc��|j5|jj|�}||j|<|cddd�S#1swYyxYwr
)r8r3�pop)rr�items   rrz!RecentlyUsedContainer.__getitem__]sC��
�Y�Y�	��?�?�&�&�s�+�D�#'�D�O�O�C� ��	�	�	�s�,A�Ac��d}|j5	||jj|�f}||j|<ddd�|�$|jr|\}}|j|�yyy#t$rP||j|<t	|j�|j
kDr|jj
d��}Y��wxYw#1swY��xYw)NF)�last)r8r3r?�KeyError�lenr5�popitemr7)rr�value�evicted_item�_�
evicted_values      r�__setitem__z!RecentlyUsedContainer.__setitem__ds�����
�Y�Y�	G�
G� #�D�O�O�$7�$7��$<�<��',�����$�	G�&�#��(9�(9�+��A�}����m�,�):�#���
G�(-�����$��t���'�$�-�-�7�$(�?�?�#:�#:��#:�#F�L��
G��	G�	G�s)�C�,A,�,AC�C�C�C�Cc��|j5|jj|�}ddd�|jr|j�yy#1swY�(xYwr
)r8r3r?r7)rrrFs   r�__delitem__z!RecentlyUsedContainer.__delitem__}sP��
�Y�Y�	-��O�O�'�'��,�E�	-�������e�$��	-�	-�s�A�Ac�p�|j5t|j�cddd�S#1swYyxYwr
)r8rDr3rs r�__len__zRecentlyUsedContainer.__len__�s*��
�Y�Y�	(��t���'�	(�	(�	(�s�,�5c��td��)Nz7Iteration over this class is unlikely to be threadsafe.)�NotImplementedErrorrs r�__iter__zRecentlyUsedContainer.__iter__�s��!�E�
�	
rc�
�|j5t|jj��}|jj	�ddd�|j
rD]}|j|��yy#1swY�/xYwr
)r8�listr3�values�clearr7)rrTrFs   rrUzRecentlyUsedContainer.clear�sr��
�Y�Y�	$��$�/�/�0�0�2�3�F��O�O�!�!�#�	$�
����
)���!�!�%�(�
)��	$�	$�s�>A9�9Bc��|j5t|jj��cddd�S#1swYyxYwr
)r8�setr3rrs rrzRecentlyUsedContainer.keys�s3��
�Y�Y�	/��t���+�+�-�.�	/�	/�	/�s	�#:�A)�
N)r<r4r7r6r�None)rr"rr#)rr"rFr#rrY)rr"rrY�rr4)rztyping.NoReturn)rrY)rzset[_KT])rrr�__doc__�__annotations__r;rrJrLrNrQrUr�
__classcell__�r=s@rr r ?sl����-�,��M�5�5�
�K��<@�	��	�:�	�
�		��-�2%�(�
�
)�/rc�<�eZdZUdZded<d	d�Zd
d�Zdd�Zdd�Zy)
�HTTPHeaderDictItemViewa�
    HTTPHeaderDict is unusual for a Mapping[str, str] in that it has two modes of
    address.

    If we directly try to get an item with a particular name, we will get a string
    back that is the concatenated version of all the values:

    >>> d['X-Header-Name']
    'Value1, Value2, Value3'

    However, if we iterate over an HTTPHeaderDict's items, we will optionally combine
    these values based on whether combine=True was called when building up the dictionary

    >>> d = HTTPHeaderDict({"A": "1", "B": "foo"})
    >>> d.add("A", "2", combine=True)
    >>> d.add("B", "bar")
    >>> list(d.items())
    [
        ('A', '1, 2'),
        ('B', 'foo'),
        ('B', 'bar'),
    ]

    This class conforms to the interface required by the MutableMapping ABC while
    also giving us the nonstandard iteration behavior we want; items with duplicate
    keys, ordered by time of first insertion.
    r!�_headersc��||_yr
)ra)r�headerss  rr;zHTTPHeaderDictItemView.__init__�s	����
rc�Z�tt|jj���Sr
)rDrSra�	iteritemsrs rrNzHTTPHeaderDictItemView.__len__�s���4��
�
�/�/�1�2�3�3rc�6�|jj�Sr
)rarers rrQzHTTPHeaderDictItemView.__iter__�s���}�}�&�&�(�(rc���t|t�rOt|�dk(rA|\}}t|t�r,t|t�r|jj||�Sy)N�F)r)�tuplerDrra�_has_value_for_header)rr@�
passed_key�
passed_vals    r�__contains__z#HTTPHeaderDictItemView.__contains__�sM���d�E�"�s�4�y�A�~�%)�"�J�
��*�c�*�z�*�c�/J��}�}�:�:�:�z�R�R�rN)rcr!rrYrZ�rz typing.Iterator[tuple[str, str]])r@�objectr�bool)	rrrr[r\r;rNrQrmrrrr`r`�s#���8�� �4�)�rr`c�|��eZdZUdZded<d!d"�fd�
Zd#d�Zd$d�Zd%d�Zd&d�Z	d'd(�fd	�
Z
d)d
�Zd)d�Zd*d�Z
d+d
�Zd%d�Zdd�d,d�Zd-d�Zej&d.d��Zej&d/d��Zej,f					d0d�Zd1d�ZeZeZeZeZd2d�Zd3d�Zd4d�Zd5d�Zd5d�Z d6d�Z!d7d�Z"d8d�Z#d8d�Z$d8d �Z%�xZ&S)9r!ap
    :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'
    z%typing.MutableMapping[str, list[str]]r3c����t�|��i|_|�3t|t�r|j|�n|j
|�|r|j
|�yyr
)r:r;r3r)r!�
_copy_from�extend)rrc�kwargsr=s   �rr;zHTTPHeaderDict.__init__�sQ���
����������'�>�2�����(����G�$���K�K���rc��t|t�r|jd�}||g|j|j	�<y)N�latin-1)r)�bytes�decoder3�lower�rr�vals   rrJzHTTPHeaderDict.__setitem__�s2���c�5�!��*�*�Y�'�C�(+�S�z�����	�	��$rc�d�|j|j�}dj|dd�S)N�, ��r3rz�joinr{s   rrzHTTPHeaderDict.__getitem__s+���o�o�c�i�i�k�*���y�y��Q�R��!�!rc�:�|j|j�=yr
�r3rzrs  rrLzHTTPHeaderDict.__delitem__s���O�O�C�I�I�K�(rc�\�t|t�r|j�|jvSy�NF)r)rrzr3rs  rrmzHTTPHeaderDict.__contains__s$���c�3���9�9�;�$�/�/�1�1�rc�$��t�|�||�Sr
)r:�
setdefault)rr�defaultr=s   �rr�zHTTPHeaderDict.setdefault
s����w�!�#�w�/�/rc�"�t|�}|�yt|�|�}|j�D��cic]\}}|j�|��c}}|j�D��cic]\}}|j�|��c}}k(Scc}}wcc}}wr�)r1�type�
itermergedrz)r�other�maybe_constructable�other_as_http_header_dict�k�vs      r�__eq__zHTTPHeaderDict.__eq__s���C�E�J���&��(2��T�
�3F�(G�%�)-���):�;���A����	�1��;�%>�%I�%I�%K�@
�!�Q��A�G�G�I�q�L�@
�
�	
��;��@
s�B�$Bc�&�|j|�Sr
)r�)rr�s  r�__ne__zHTTPHeaderDict.__ne__s���;�;�u�%�%�%rc�,�t|j�Sr
)rDr3rs rrNzHTTPHeaderDict.__len__s���4�?�?�#�#rc#�XK�|jj�D]	}|d���y�w)Nr)r3rT)r�valss  rrQzHTTPHeaderDict.__iter__!s+�����O�O�*�*�,�	�D��q�'�M�	�s�(*c�*�	||=y#t$rYywxYwr
)rCrs  r�discardzHTTPHeaderDict.discard&s ��	��S�	���	��	�s��	�F)�combinec��t|t�r|jd�}|j�}||g}|jj||�}||ur3t
|�dk\sJ�|r|ddz|z|d<y|j|�yy)a�Adds a (name, value) pair, doesn't overwrite the value if it already
        exists.

        If this is called with combine=True, instead of adding a new header value
        as a distinct item during iteration, this will instead append the value to
        any existing header value with a comma. If no existing header value exists
        for the key, then the value will simply be added, ignoring the combine parameter.

        >>> headers = HTTPHeaderDict(foo='bar')
        >>> headers.add('Foo', 'baz')
        >>> headers['foo']
        'bar, baz'
        >>> list(headers.items())
        [('foo', 'bar'), ('foo', 'baz')]
        >>> headers.add('foo', 'quz', combine=True)
        >>> list(headers.items())
        [('foo', 'bar, baz, quz')]
        rwrh���r~N)r)rxryrzr3r�rD�append)rrr|r��	key_lower�new_valsr�s       r�addzHTTPHeaderDict.add,s���(�c�5�!��*�*�Y�'�C��I�I�K�	���:�����)�)�)�X�>���4���t�9��>�!�>����8�d�?�S�0��R�����C� � rc�F�t|�dkDrtdt|��d���t|�dk\r|dnd}t|t�r,|j	�D]\}}|j||���nt|tj�r+|j�D]\}}|j||��n�t|tj�r_t
jtjtjttf|�}|D]\}}|j||��nBt|d�r6t|d�r*|j�D]}|j|||��|j�D]\}}|j||��y)	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__
        rz/extend() takes at most 1 positional arguments (z given)rrrrN)rD�	TypeErrorr)r!rer�r*r+�itemsr-r,r.rr/r)r�argsrur�rr|rFs       rrtzHTTPHeaderDict.extendOsd��
�t�9�q�=��A�#�d�)��G�T��
��t�9��>��Q��r���e�^�,�!�O�O�-�
#���S�����c�"�
#�
��v�~�~�
.�!�K�K�M�
#���S�����c�"�
#�
��v���
/��K�K�������S�#�X�0F� G��O�E�#�
%�
��U�����e�$�
%�
�U�F�
#���}�(E��z�z�|�
*������e�C�j�)�
*�!�,�,�.�	!�J�C���H�H�S�%� �	!rc��yr
rrs  r�getlistzHTTPHeaderDict.getlistp���rc��yr
r)rrr�s   rr�zHTTPHeaderDict.getlisttr�rc��	|j|j�}|ddS#t$r|tjurgcYS|cYSwxYw)zmReturns a list of all the values for the named field. Returns an
        empty list if the key doesn't exist.rN)r3rzrCr&r')rrr�r�s    rr�zHTTPHeaderDict.getlistxsQ��
	��?�?�3�9�9�;�/�D����8�O���	��)�.�.�.��	��N�	�s�$�A�A�Ac�>�gd�}|D]}|j|��|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-Length�Digestz
Last-Modified)r�)r�content_specific_headers�headers   r�_prepare_for_method_changez)HTTPHeaderDict._prepare_for_method_change�s,��
$
� �/�	!�F��L�L�� �	!��rc�f�t|�j�dt|j���d�S)N�(�))r�r�dictr�rs r�__repr__zHTTPHeaderDict.__repr__�s-���t�*�%�%�&�a��T�_�_�->�(?�'@��B�Brc�t�|D]3}|j|�}|g|�|j|j�<�5yr
)r�r3rz)rr�rr|s    rrszHTTPHeaderDict._copy_from�s9���	7�C��-�-��$�C�,/�;�#�;�D�O�O�C�I�I�K�(�	7rc�H�t|��}|j|�|Sr
)r�rs)r�clones  r�copyzHTTPHeaderDict.copy�s"����T�
���
������rc#�zK�|D]2}|j|j�}|ddD]}|d|f���
�4y�w)z8Iterate over all header lines, including duplicate ones.rNrr�)rrr�r|s    rrezHTTPHeaderDict.iteritems�sL�����	#�C��?�?�3�9�9�;�/�D��A�B�x�
#���1�g�s�l�"�
#�	#�s�9;c#�K�|D]:}|j|j�}|ddj|dd�f���<y�w)z:Iterate over all headers, merging duplicate ones together.rr~rNr�r{s   rr�zHTTPHeaderDict.itermerged�sG�����	-�C��/�/�#�)�)�+�.�C��a�&�$�)�)�C���G�,�,�,�	-�s�AAc��t|�Sr
)r`rs rr�zHTTPHeaderDict.items�s
��%�d�+�+rc�P�||vr"||j|j�ddvSy)NrFr�)r�header_name�potential_values   rrjz$HTTPHeaderDict._has_value_for_header�s1���$��"�d�o�o�k�6G�6G�6I�&J�1�2�&N�N�N�rc�N�t|�}|�tS|j|�|Sr
)r1�NotImplementedrt)rr�r�s   r�__ior__zHTTPHeaderDict.__ior__�s.��D�E�J���&�!�!����'�(��rc�n�t|�}|�tS|j�}|j|�|Sr
)r1r�r�rt�rr�r��results    r�__or__zHTTPHeaderDict.__or__�s9��D�E�J���&�!�!�������
�
�)�*��
rc�p�t|�}|�tSt|�|�}|j|�|Sr
)r1r�r�rtr�s    r�__ror__zHTTPHeaderDict.__ror__�s>��D�E�J���&�!�!���d��/�0���
�
�d���
rr
)rc�ValidHTTPHeaderSource | Nonerur)rrr|rrrYr)rrrrY)rrorrp)�)rrr�rrr)r�rorrprZr)rrr|rr�rprrY)r��ValidHTTPHeaderSourcerurrrY)rrrz	list[str])rrr�r$r�list[str] | _DT)rrr�z_Sentinel | _DTrr�)rr	)rr)r�r!rrY)rr!rn)rr`)r�rr�rrrp)r�rorr!)'rrrr[r\r;rJrrLrmr�r�r�rNrQr�r�rtr*�overloadr�r&r'r��
getheaders�getallmatchingheaders�iget�get_allr�rsr�rer�r�rjr�r�r�r]r^s@rr!r!�s����B6�5�	 �2�"�)��
0�	
�&�$��
�:?�!!�F!�B�_�_�����_�_����4=�3G�3G����!0��	��$�&�J�#���D��G�C�7�
�
#�-�,��
��r)r0rorr�)"�
__future__rr*�collectionsr�enumrr�	threadingr�
TYPE_CHECKING�typing_extensionsrr	r�__all__�TypeVarr"r#r$�Unionr+rr-r.r�r&r1�Generic�MutableMappingr �Setr`r!rrr�<module>r�s?��"�
�#���	���1����#�$4�
5���f�n�n�U����f�n�n�U����f�n�n�U�������
�N�N�3��8��
�O�O�F�L�L��c��*�+�����������!��(Z/�F�N�N�3��8�4�f�6K�6K�C�QT�H�6U�Z/�z-�V�Z�Z����S�#�X�(>�?�-�`U�V�*�*�3��8�4�Ur