
    vKg                        S SK Jr  S SKJrJrJrJr  S SKJrJ	r	J
r
  / SQr " S S\5      r " S S\\\4   5      r " S	 S
\	5      r\
\\\\4   \\\\4      \4   rg)    )annotations)IterableIteratorMappingMutableMapping)AnyProtocolUnion)HeadersHeadersLikeMultipleValuesErrorc                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r   
   zH
Exception raised when :class:`Headers` has multiple values for a key.

c                   > [        U R                  5      S:X  a  [        U R                  S   5      $ [        TU ]  5       $ N   r   )lenargsreprsuper__str__)self	__class__s    Y/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/websockets/datastructures.pyr   MultipleValuesError.__str__   s3    tyy>Q		!%%w       returnstr)__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__r   s   @r   r   r   
   s    
! !r   r   c                     ^  \ rS rSrSrSS/rSS jrSS jrSS jrSS jr	SS	 jr
SS
 jrSS jrSS jrSS jrSS jrSS jrS S jrS!S jrSU 4S jjrS"S jrS#S jrSrU =r$ )$r      al  
Efficient data structure for manipulating HTTP headers.

A :class:`list` of ``(name, values)`` is inefficient for lookups.

A :class:`dict` doesn't suffice because header names are case-insensitive
and multiple occurrences of headers with the same name are possible.

:class:`Headers` stores HTTP headers in a hybrid data structure to provide
efficient insertions and lookups while preserving the original data.

In order to account for multiple values with minimal hassle,
:class:`Headers` follows this logic:

- When getting a header with ``headers[name]``:
    - if there's no value, :exc:`KeyError` is raised;
    - if there's exactly one value, it's returned;
    - if there's more than one value, :exc:`MultipleValuesError` is raised.

- When setting a header with ``headers[name] = value``, the value is
  appended to the list of values for that header.

- When deleting a header with ``del headers[name]``, all values for that
  header are removed (this is slow).

Other methods for manipulating headers are consistent with this logic.

As long as no header occurs multiple times, :class:`Headers` behaves like
:class:`dict`, except keys are lower-cased to provide case-insensitivity.

Two methods support manipulating multiple values explicitly:

- :meth:`get_all` returns a list of all values for a header;
- :meth:`raw_items` returns an iterator of ``(name, values)`` pairs.

_dict_listc                D    0 U l         / U l        U R                  " U0 UD6  g N)r+   r,   update)r   r   kwargss      r   __init__Headers.__init__@   s!    +-
,.
T$V$r   c                L    SR                  S U R                   5       5      S-   $ )N c              3  4   #    U H  u  pU S U S3v   M     g7f)z: 
Nr   ).0keyvalues      r   	<genexpr>"Headers.__str__.<locals>.<genexpr>F   s     Jz#bt,zs   r6   )joinr,   r   s    r   r   Headers.__str__E   s     wwJtzzJJVSSr   c                P    U R                   R                   SU R                  < S3$ )N())r   r!   r,   r=   s    r   __repr__Headers.__repr__H   s$    ..))*!DJJ>;;r   c                    U R                  5       nU R                  R                  5       Ul        U R                  R                  5       Ul        U$ r.   )r   r+   copyr,   )r   rE   s     r   rE   Headers.copyK   s7    ~~ZZ__&
ZZ__&
r   c                4    [        U 5      R                  5       $ r.   )r    encoder=   s    r   	serializeHeaders.serializeQ   s    4y!!r   c                j    [        U[        5      =(       a    UR                  5       U R                  ;   $ r.   )
isinstancer    lowerr+   r   r8   s     r   __contains__Headers.__contains__W   s#    #s#A		tzz(AAr   c                ,    [        U R                  5      $ r.   )iterr+   r=   s    r   __iter__Headers.__iter__Z   s    DJJr   c                ,    [        U R                  5      $ r.   )r   r+   r=   s    r   __len__Headers.__len__]   s    4::r   c                z    U R                   UR                  5          n[        U5      S:X  a  US   $ [        U5      er   )r+   rM   r   r   r   r8   r9   s      r   __getitem__Headers.__getitem__b   s5    

399;'u:?8O%c**r   c                    U R                   R                  UR                  5       / 5      R                  U5        U R                  R                  X45        g r.   )r+   
setdefaultrM   appendr,   rY   s      r   __setitem__Headers.__setitem__i   s;    

ciik2.55e<

3,'r   c                    UR                  5       nU R                  R                  U5        U R                   VVs/ sH  u  p4UR                  5       U:w  d  M  X44PM      snnU l        g s  snnf r.   )rM   r+   __delitem__r,   )r   r8   	key_lowerkvs        r   rb   Headers.__delitem__m   sO    IIK	

y))-NqwwyI7MfqfN
Ns   A)A)c                j    [        U[        5      (       d  [        $ U R                  UR                  :H  $ r.   )rL   r   NotImplementedr+   )r   others     r   __eq__Headers.__eq__s   s(    %))!!zzU[[((r   c                     0 U l         / U l        g)z
Remove all headers.

Nr+   r,   r=   s    r   clearHeaders.clearx   s    
 

r   c                J   > [        S U 5       5      n[        TU ]  " U0 UD6  g)zD
Update from a :class:`Headers` instance and/or keyword arguments.

c              3  n   #    U H,  n[        U[        5      (       a  UR                  5       OUv   M.     g 7fr.   )rL   r   	raw_items)r7   args     r   r:   !Headers.update.<locals>.<genexpr>   s*      
LPSz#w77CMMOS@Ds   35N)tupler   r/   )r   r   r0   r   s      r   r/   Headers.update   s/    
  
LP
 
 	''r   c                V    U R                   R                  UR                  5       / 5      $ )z\
Return the (possibly empty) list of all values for a header.

Args:
    key: Header name.

)r+   getrM   rN   s     r   get_allHeaders.get_all   s     zz~~ciik2..r   c                ,    [        U R                  5      $ )z?
Return an iterator of all values as ``(name, value)`` pairs.

)rR   r,   r=   s    r   rr   Headers.raw_items   s    
 DJJr   rm   )r   r   r0   r    r   Noner   )r   r   )r   bytes)r8   objectr   bool)r   zIterator[str])r   intr8   r    r   r    )r8   r    r9   r    r   r}   )r8   r    r   r}   )ri   r   r   r   )r   r}   )r8   r    r   z	list[str])r   zIterator[tuple[str, str]])r!   r"   r#   r$   r%   	__slots__r1   r   rB   rE   rI   rO   rS   rV   rZ   r_   rb   rj   rn   r/   ry   rr   r&   r'   r(   s   @r   r   r      sm    #J '"I%
T<"B 
+(O)
(/   r   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	SupportsKeysAndGetItem   zW
Dict-like types with ``keys() -> str`` and ``__getitem__(key: str) -> str`` methods.

c                    g r.   r   r=   s    r   keysSupportsKeysAndGetItem.keys   s    Sr   c                    g r.   r   rN   s     r   rZ   "SupportsKeysAndGetItem.__getitem__   s    Cr   r   N)r   zIterable[str]r   )r!   r"   r#   r$   r%   r   rZ   r&   r   r   r   r   r      s    
 )/r   r   N)
__future__r   collections.abcr   r   r   r   typingr   r	   r
   __all__LookupErrorr   r    r   r   ru   r   r   r   r   <module>r      s    " G G ' ' <
!+ 
!D nS#X& D P0X 0 CHU38_r   