
    vKg                          S r SSKrSSKrSSKrSSKJrJrJrJr  SSK	J
r  SSKJr  SSKJ
r
  Sr " S S	\5      r " S
 S\5      r " S S\5      rS\\
\4   S\\\4   4S jrS\S\\   4S jrS\4S jrS\S\4S jrg)za
wsproto/utilities
~~~~~~~~~~~~~~~~~

Utility functions that do not belong in a separate module.
    N)DictListOptionalUnion)Headers   )Events$   258EAFA5-E914-47DA-95CA-C5AB0DC85B11c                       \ rS rSrSrg)ProtocolError    N)__name__
__module____qualname____firstlineno____static_attributes__r       Q/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/wsproto/utilities.pyr   r      s    r   r   c                       \ rS rSrSrSrg)LocalProtocolError   zIndicates an error due to local/programming errors.

This is raised when the connection is asked to do something that
is either incompatible with the state or the websocket standard.

r   N)r   r   r   r   __doc__r   r   r   r   r   r      s     	r   r   c                   F   ^  \ rS rSrSrS	S\S\\   SS4U 4S jjjrSr	U =r
$ )
RemoteProtocolError$   aQ  Indicates an error due to the remote's actions.

This is raised when processing the bytes from the remote if the
remote has sent data that is incompatible with the websocket
standard.

.. attribute:: event_hint

   This is a suggested wsproto Event to send to the client based
   on the error. It could be None if no hint is available.

Nmessage
event_hintreturnc                 0   > X l         [        TU ]	  U5        g N)r   super__init__)selfr   r   	__class__s      r   r"   RemoteProtocolError.__init__2   s    $!r   )r   r    )r   r   r   r   r   strr   r	   r"   r   __classcell__)r$   s   @r   r   r   $   s+    " "% "D " "r   r   h11_headersr   c                     0 nU  H&  u  p#UR                  U/ 5      R                  U5        M(     0 nUR                  5        H  u  p%SR                  U5      XB'   M     U$ )Ns   , )
setdefaultappenditemsjoin)r(   name_to_valuesnamevaluename_to_normed_valuevaluess         r   normed_header_dictr3   8   sc    
 02N"!!$+2259 #&,,.%*ZZ%7" /r   r0   c                     U R                  S5       Vs/ sH!  oR                  S5      R                  5       PM#     sn$ s  snf )N   ,ascii)splitdecodestrip)r0   pieces     r   split_comma_headerr;   K   s5    7<{{47HI7HeLL!'')7HIIIs   '>c                  V    [         R                  " [        R                  " S5      5      $ )N   )base64	b64encodeosurandomr   r   r   generate_noncerB   O   s     BJJrN++r   tokenc                     U [         -   n[        R                  " U5      R                  5       n[        R
                  " U5      $ r    )ACCEPT_GUIDhashlibsha1digestr>   r?   )rC   accept_tokens     r   generate_accept_tokenrJ   U   s4    ;&L<<-446LL))r   )r   r>   rF   r@   typingr   r   r   r   h11._headersr   
H11Headerseventsr	   rE   	Exceptionr   r   r   bytesr3   r&   r;   rB   rJ   r   r   r   <module>rQ      s      	 . . .   6	I 		 	"- "( E':*=$>  4uCU  &Je JS	 J, ,* *5 *r   