
    Y jT                     J    S r SSKrSrSrS/rSr " S S5      r " S S	5      rg)
a{  
Vendored file: Server Side Events (SSE) client for Python.

Source:
- Author: Maxime Petazzoni <maxime.petazzoni@bulix.org>
- Repository: https://github.com/mpetazzoni/sseclient
- File: https://github.com/mpetazzoni/sseclient/blob/main/sseclient/__init__.py

License:
- Apache-2.0 (from upstream project)

Provides a generator of SSE received through an existing HTTP response.
    Nz-Maxime Petazzoni <maxime.petazzoni@bulix.org>zmaxime.petazzoni@bulix.org	SSEClient:c                   4    \ rS rSrSrS	S jrS rS rS rSr	g)
r      zoImplementation of a SSE client.

See http://www.w3.org/TR/2009/WD-eventsource-20091029/ for the
specification.
c                     [         R                  " U R                  R                  5      U l        U R                  R                  SU5        Xl        X l        g)a  Initialize the SSE client over an existing, ready to consume
event source.

The event source is expected to be a binary stream and have a close()
method. That would usually be something that implements
io.BinaryIOBase, like an httplib or urllib3 HTTPResponse object.
z+Initialized SSE client from event source %sN)logging	getLogger	__class__
__module___loggerdebug_event_source	_char_enc)selfevent_sourcechar_encs      w/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/huggingface_hub/_hot_reload/sse_client.py__init__SSEClient.__init__   sC     (()B)BCH'	))!    c              #      #    SnU R                    H=  nUR                  S5       H%  nX-  nUR                  S5      (       d  M  Uv   SnM'     M?     U(       a  Uv   gg7f)aR  Read the incoming event source stream and yield event chunks.

Unfortunately it is possible for some servers to decide to break an
event into multiple HTTP chunks in the response. It is thus necessary
to correctly stitch together consecutive response chunks and find the
SSE delimiter (empty new line) to yield full, correct event chunks.r   T)s   s   

s   

N)r   
splitlinesendswith)r   datachunklines       r   _readSSEClient._read-   sa      ''E((.==!@AAJD	 / ( J s   >AAc              #     #    U R                  5        GH  n[        5       nUR                  5        GH  nUR                  U R                  5      nUR                  5       (       a  UR                  [        5      (       a  MP  UR                  [        S5      nUS   nXRR                  ;  a  U R                  R                  SU5        M  [        U5      S:  a(  US   R                  S5      (       a	  US   SS  nOUS   nOSnUS:X  a  UR                  U==   US-   -  ss'   M  XbR                  U'   GM     UR                  (       d  GM8  UR                  R                  S5      (       a  UR                  SS Ul        UR                  =(       d    S	Ul        U R                  R                  S
U5        Uv   GM     g 7f)N   r   z4Saw invalid field %s while parsing Server Side Event  r   
messagezDispatching %s...)r   Eventr   decoder   strip
startswith_FIELD_SEPARATORsplit__dict__r   r   lenr   r   event)r   r   r.   r   r   fieldvalues          r   eventsSSEClient.events>   sx    ZZ\EGE((*{{4>>2 zz||t7G'H'Hzz"2A6Q .LL&& (;<ACt9q= Aw))#.. $Q $Q E F?NN5)UT\9),1NN5)I +N :: zz""4(("ZZ"-
  ++2EK LL2E:Km "s   F=F?c                 8    U R                   R                  5         g)z'Manually close the event source stream.N)r   close)r   s    r   r4   SSEClient.closew   s      "r   )r   r   r   N)zutf-8)
__name__r   __qualname____firstlineno____doc__r   r   r1   r4   __static_attributes__ r   r   r   r      s    ""7r#r   c                   (    \ rS rSrSrSS jrS rSrg)r&   |   z1Representation of an event from the event stream.Nc                 4    Xl         X l        X0l        X@l        g )N)idr.   r   retry)r   r?   r.   r   r@   s        r   r   Event.__init__   s    
	
r   c                 h   U R                    S3nU R                  (       a  USU R                   3-  nU R                  (       aE  USR                  [	        U R                  5      [	        U R                  5      (       a  SOS5      -  nOUS-  nU R
                  (       a  USU R
                   S3-  nU$ )	Nz eventz #z, {} byte{}sr"   z	, no dataz, retry in ms)r.   r?   r   formatr-   r@   )r   rC   s     r   __str__Event.__str__   s    zzl&!772dggYA99%%c$))n/2499~~2G GA A::;tzzl"--Ar   )r   r.   r?   r@   )Nr%   r"   N)r6   r   r7   r8   r9   r   rF   r:   r;   r   r   r&   r&   |   s    ;r   r&   )r9   r   
__author__	__email____all__r*   r   r&   r;   r   r   <module>rK      s=    <
(	- a# a#H r   