
    nbi>                    |   d dl mZ d dlZd dlmZ d dlmZmZ d dlm	Z	 d dl
mZ ej        rd dlmZ  G d d	e          Zd
dgZ ej        d          Z ej        d          Z ej        d          Zej        dej        eef         ej        ej        eef                  d	f         Z G d de          Z e	d          dd            Zd dZ G d d
ej        eef         ej        eef                   Z  G d dej!        ej        eef                            Z" G d dej        eef                   Z#dS )!    )annotationsN)OrderedDict)Enumauto)	lru_cache)RLock)Protocolc                      e Zd ZddZd	dZdS )
HasGettableStringKeysreturntyping.Iterator[str]c                    d S N selfs    k/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/urllib3_future/_collections.pykeyszHasGettableStringKeys.keys             keystrc                    d S r   r   r   r   s     r   __getitem__z!HasGettableStringKeys.__getitem__   r   r   Nr   r   r   r   r   r   )__name__
__module____qualname__r   r   r   r   r   r   r      s(        3333333333r   r   RecentlyUsedContainerHTTPHeaderDict_KT_VT_DTc                  "    e Zd Z e            ZdS )	_SentinelN)r   r   r    r   
not_passedr   r   r   r'   r'   &   s        JJJr   r'   @   )maxsizestringr   r   c                *    |                                  S )zjReasoning: We are often calling lower on repetitive identical header key. This was unnecessary exhausting!)lower)r+   s    r   _lower_wrapperr.   *   s     <<>>r   	potentialobjectValidHTTPHeaderSource | Nonec                   t          | t                    r| S t          | t          j                  r1t          j        t          j        t
          t
          f         |           S t          | t          j                  rAt          j        t          j        t          j        t
          t
          f                  |           S t          | d          r%t          | d          rt          j        d|           S d S )Nr   r   r   )	
isinstancer"   typingMappingcastr   IterableTuplehasattr)r/   s    r   %ensure_can_construct_http_header_dictr:   0   s     )^,, 	Iv~	.	.  {6>#s(3Y???	Iv	/	/  {6?6<S+ABINNN	F	#	# 	=(I(I {2I>>>tr   c                       e Zd ZU dZded<   ded<   ded<   ded	<   	 	 dd fdZddZd dZd!dZd"dZ	d#dZ
d$dZd%dZ xZ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``. Caution: RecentlyUsedContainer is deprecated and scheduled for
    removal in a next major of urllib3.future. It has been replaced by a more
    suitable implementation in ``urllib3.util.traffic_police``.

    :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
    ztyping.OrderedDict[_KT, _VT]
_containerint_maxsize#typing.Callable[[_VT], None] | Nonedispose_funcr   lock
   Nr*   r   Nonec                    t                                                       || _        || _        t	                      | _        t                      | _        d S r   )super__init__r>   r@   r   r<   r   rA   )r   r*   r@   	__class__s      r   rF   zRecentlyUsedContainer.__init__Y   sD    
 	(%--GG			r   r   r#   r$   c                    | j         5  | j                            |          }|| j        |<   |cd d d            S # 1 swxY w Y   d S r   )rA   r<   pop)r   r   items      r   r   z!RecentlyUsedContainer.__getitem__d   s    Y 	 	?&&s++D#'DOC 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   &;??valuec                   d }| j         5  	 || j                            |          f}|| j        |<   nR# t          $ rE || j        |<   t	          | j                  | j        k    r| j                            d          }Y nw xY wd d d            n# 1 swxY w Y   |#| j        r|\  }}|                     |           d S d S d S )NF)last)rA   r<   rI   KeyErrorlenr>   popitemr@   )r   r   rL   evicted_item_evicted_values         r   __setitem__z!RecentlyUsedContainer.__setitem__k   sH   Y 	G 	GG  #DO$7$7$<$<<',$$ G G G (-$t''$-77 $(?#:#:#:#F#FLG	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G& #(9#+A}m,,,,, $###s2   B&3BAB?BBBBBc                    | j         5  | j                            |          }d d d            n# 1 swxY w Y   | j        r|                     |           d S d S r   )rA   r<   rI   r@   )r   r   rL   s      r   __delitem__z!RecentlyUsedContainer.__delitem__   s    Y 	- 	-O'',,E	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-  	%e$$$$$	% 	%s   /33c                l    | j         5  t          | j                  cd d d            S # 1 swxY w Y   d S r   )rA   rP   r<   r   s    r   __len__zRecentlyUsedContainer.__len__   s{    Y 	( 	(t''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   )--typing.NoReturnc                     t          d          )Nz7Iteration over this class is unlikely to be threadsafe.)NotImplementedErrorr   s    r   __iter__zRecentlyUsedContainer.__iter__   s    !E
 
 	
r   c                   | j         5  t          | j                                                  }| j                                         d d d            n# 1 swxY w Y   | j        r|D ]}|                     |           d S d S r   )rA   listr<   valuesclearr@   )r   r`   rL   s      r   ra   zRecentlyUsedContainer.clear   s    Y 	$ 	$$/002233FO!!###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$
  	) ) )!!%((((	) 	)) )s   A AAAset[_KT]c                    | j         5  t          | j                                                  cd d d            S # 1 swxY w Y   d S r   )rA   setr<   r   r   s    r   r   zRecentlyUsedContainer.keys   s    Y 	/ 	/t++--..	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/rK   )rB   N)r*   r=   r@   r?   r   rC   )r   r#   r   r$   )r   r#   rL   r$   r   rC   )r   r#   r   rC   r   r=   )r   rZ   )r   rC   )r   rb   )r   r   r    __doc____annotations__rF   r   rU   rW   rY   r]   ra   r   __classcell__rG   s   @r   r!   r!   D   s          -,,,MMM5555KKK <@	 	 	 	 	 	 	   - - - -2% % % %( ( ( (
 
 
 

) ) ) )/ / / / / / / /r   c                  >    e Zd ZU dZded<   ddZdd	ZddZddZdS )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"   _headersheadersr   rC   c                    || _         d S r   )rl   )r   rm   s     r   rF   zHTTPHeaderDictItemView.__init__   s    r   r=   c                h    t          t          | j                                                            S r   )rP   r_   rl   	iteritemsr   s    r   rY   zHTTPHeaderDictItemView.__len__   s&    4//1122333r    typing.Iterator[tuple[str, str]]c                4    | j                                         S r   )rl   rp   r   s    r   r]   zHTTPHeaderDictItemView.__iter__   s    }&&(((r   rJ   r0   boolc                    t          |t                    r]t          |          dk    rJ|\  }}t          |t                    r0t          |t                    r| j                            ||          S dS )N   F)r3   tuplerP   r   rl   _has_value_for_header)r   rJ   
passed_key
passed_vals       r   __contains__z#HTTPHeaderDictItemView.__contains__   so    dE"" 	Ss4yyA~~%)"J
*c** Sz*c/J/J S}:::zRRRur   N)rm   r"   r   rC   re   r   rq   )rJ   r0   r   rs   )	r   r   r    rf   rg   rF   rY   r]   rz   r   r   r   rk   rk      s~          8        4 4 4 4) ) ) )     r   rk   c                  @    e Zd ZU dZded<   d8d9 fd	Zd:dZd;dZd<dZd=dZ	d>d? fdZ
d@dZd@dZdAdZdBdZd<dZdd dCd"ZdDd%Zej        dEd'            Zej        dFd*            Zej        fdGd,ZeZeZeZeZdHd-ZdId.ZdJd/ZdKd1ZdKd2ZdLd4Z dMd7Z! xZ"S )Nr"   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]]r<   Nrm   r1   kwargsr   c                   t                                                       i | _        |@t          |t                    r|                     |           n|                     |           |r|                     |           d S d S r   )rE   rF   r<   r3   r"   
_copy_fromextend)r   rm   r}   rG   s      r   rF   zHTTPHeaderDict.__init__   s    '>22 %((((G$$$ 	 KK	  	 r   r   valr   rC   c                8    ||g| j         t          |          <   d S r   r<   r.   r   r   r   s      r   rU   zHTTPHeaderDict.__setitem__  s     03Szs++,,,r   c                    t          |t                    r|                    d          }| j        t	          |                   }d                    |dd                    S )Nlatin-1,    )r3   bytesdecoder<   r.   joinr   s      r   r   zHTTPHeaderDict.__getitem__  sS    c5!! 	(**Y''ConS112yyQRR!!!r   c                    t          |t                    r|                    d          }| j        t	          |          = d S )Nr   )r3   r   r   r<   r.   r   s     r   rW   zHTTPHeaderDict.__delitem__  s=    c5!! 	(**Y''CON3//000r   r0   rs   c                    t          |t                    r|                    d          }t          |t                    rt	          |          | j        v S dS )Nr   F)r3   r   r   r   r.   r<   r   s     r   rz   zHTTPHeaderDict.__contains__  sQ    c5!! 	(**Y''Cc3 	:!#&&$/99ur    defaultc                H    t                                          ||          S r   )rE   
setdefault)r   r   r   rG   s      r   r   zHTTPHeaderDict.setdefault  s    ww!!#w///r   otherc                    t          |          }|dS  t          |           |          }d |                                 D             d |                                D             k    S )NFc                4    i | ]\  }}t          |          |S r   r.   .0kvs      r   
<dictcomp>z)HTTPHeaderDict.__eq__.<locals>.<dictcomp>"  s&    CCCAq!!1CCCr   c                4    i | ]\  }}t          |          |S r   r   r   s      r   r   z)HTTPHeaderDict.__eq__.<locals>.<dictcomp>"  s9     H
 H
 H
%)QN1qH
 H
 H
r   )r:   type
itermerged)r   r   maybe_constructableother_as_http_header_dicts       r   __eq__zHTTPHeaderDict.__eq__  s    CEJJ&5(2T

3F(G(G%CC1B1BCCC H
 H
-F-Q-Q-S-SH
 H
 H
 
 	
r   c                .    |                      |           S r   )r   )r   r   s     r   __ne__zHTTPHeaderDict.__ne__&  s    ;;u%%%%r   r=   c                *    t          | j                  S r   )rP   r<   r   s    r   rY   zHTTPHeaderDict.__len__)  s    4?###r   r   c              #  V   K   | j                                         D ]}|d         V  d S )Nr   )r<   r`   )r   valss     r   r]   zHTTPHeaderDict.__iter__,  s<      O**,, 	 	Dq'MMMM	 	r   c                0    	 | |= d S # t           $ r Y d S w xY wr   )rO   r   s     r   discardzHTTPHeaderDict.discard1  s4    	S			 	 	 	DD	s    
F)combiner   c                   t          |          }||g}| j                            ||          }||ur,|r|d         dz   |z   |d<   dS |                    |           dS dS )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')]
        r   N)r.   r<   r   append)r   r   r   r   	key_lowernew_valsr   s          r   addzHTTPHeaderDict.add7  s    & #3''	:)))X>>4  !8d?S0RC       r   argsValidHTTPHeaderSourcec                   t          |          dk    r t          dt          |           d          t          |          dk    r|d         nd}t          |t                    r2|                                D ]\  }}|                     ||           nt          |t          j                  r1|                                D ]\  }}|                     ||           nt          |t          j	                  r`t          j
        t          j	        t          j        t          t          f                  |          }|D ]\  }}|                     ||           nSt          |d          rCt          |d          r3|                                D ]}|                     |||                    |                                D ]\  }}|                     ||           dS )	zGeneric 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__
        r   z/extend() takes at most 1 positional arguments (z given)r   r   r   r   N)rP   	TypeErrorr3   r"   rp   r   r4   r5   itemsr7   r6   r8   r   r9   r   )r   r   r}   r   r   r   rL   s          r   r   zHTTPHeaderDict.extendV  s   
 t99q==T#d))TTT   t99>>Qre^,, 	*!OO-- # #Sc""""#v~.. 	*!KKMM # #Sc""""#v// 	*KS#X0F GOOE# % %
Ue$$$$%UF## 	*}(E(E 	* zz|| * *eCj)))) ,,.. 	! 	!JCHHS%    	! 	!r   	list[str]c                    d S r   r   r   s     r   getlistzHTTPHeaderDict.getlistw  s    .1cr   r%   list[str] | _DTc                    d S r   r   )r   r   r   s      r   r   zHTTPHeaderDict.getlistz  s    BE#r   _Sentinel | _DTc                    t          |t                    r|                    d          }	 | j        t	          |                   }|dd         S # t
          $ r |t          j        u rg cY S |cY S w xY w)zmReturns a list of all the values for the named field. Returns an
        empty list if the key doesn't exist.r   r   N)r3   r   r   r<   r.   rO   r'   r(   )r   r   r   r   s       r   r   zHTTPHeaderDict.getlist}  s    
 c5!! 	(**Y''C	?>##6#67D 8O  	 	 	)...			NNN	s   A A1,A10A1c                t    t          |           j         dt          |                                            dS )N())r   r   dictr   r   s    r   __repr__zHTTPHeaderDict.__repr__  s4    t**%BBT__->->(?(?BBBBr   c                n    |D ]1}|                     |          }|g|| j        t          |          <   2d S r   )r   r<   r.   )r   r   r   r   s       r   r   zHTTPHeaderDict._copy_from  sI     	? 	?C--$$C47;#;DON3//00	? 	?r   c                ^     t          |                       }|                    |            |S r   )r   r   )r   clones     r   copyzHTTPHeaderDict.copy  s,    T

r   rq   c              #  z   K   | D ]5}| j         t          |                   }|dd         D ]}|d         |fV  6dS )z8Iterate over all header lines, including duplicate ones.r   Nr   r   )r   r   r   r   s       r   rp   zHTTPHeaderDict.iteritems  sf       	# 	#C?>##6#67DABBx # #1gsl""""#	# 	#r   c              #     K   | D ]C}| j         t          |                   }|d         d                    |dd                   fV  DdS )z:Iterate over all headers, merging duplicate ones together.r   r   r   N)r<   r.   r   r   s      r   r   zHTTPHeaderDict.itermerged  s_       	- 	-C/."5"56Ca&$))CG,,,,,,,	- 	-r   rk   c                     t          |           S r   )rk   r   s    r   r   zHTTPHeaderDict.items  s    %d+++r   header_namepotential_valuec                V    || v r$|| j         t          |                   dd          v S dS )Nr   Fr   )r   r   r   s      r   rw   z$HTTPHeaderDict._has_value_for_header  s8    $"don[6Q6Q&RSTSUSU&VVVur   r   )rm   r1   r}   r   )r   r   r   r   r   rC   r   )r   r   r   rC   )r   r0   r   rs   )r   )r   r   r   r   r   r   )r   r0   r   rs   re   r   )r   r   r   r   r   rs   r   rC   )r   r   r}   r   r   rC   )r   r   r   r   )r   r   r   r%   r   r   )r   r   r   r   r   r   )r   r   )r   r"   r   rC   )r   r"   r{   )r   rk   )r   r   r   r   r   rs   )#r   r   r    rf   rg   rF   rU   r   rW   rz   r   r   r   rY   r]   r   r   r   r4   overloadr   r'   r(   
getheadersgetallmatchingheadersigetget_allr   r   r   rp   r   r   rw   rh   ri   s   @r   r"   r"      sh         B 6555	  	  	  	  	  	  	 : : : :" " " "1 1 1 1
   0 0 0 0 0 0 0	
 	
 	
 	
& & & &$ $ $ $   
    :? ! ! ! ! ! !>! ! ! !B _111 _1_EEE _E 4=3G    * J#D GC C C C? ? ? ?
   
# # # #- - - -, , , ,       r   )r+   r   r   r   )r/   r0   r   r1   )$
__future__r   r4   collectionsr   enumr   r   	functoolsr   	threadingr   TYPE_CHECKINGtyping_extensionsr	   r   __all__TypeVarr#   r$   r%   Unionr5   r   r7   r8   r   r'   r.   r:   GenericMutableMappingr!   Setrk   r"   r   r   r   <module>r      st   " " " " " "  # # # # # #                    	 4 +*****4 4 4 4 4 4 4 4 #$4
5 fnUfnUfnU
N38
OFLc*+         2   
   (\/ \/ \/ \/ \/FN384f6KCQTH6U \/ \/ \/~- - - - -VZS#X(>? - - -`f f f f fV*384 f f f f fr   