Ë
    ojŠ	  ã                   óâ   — d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
 ddlmZmZmZmZ  ed«      Z G d„ de«      Z G d	„ d
e«      Ze
 G d„ d«      «       Zdededee   fd„Zdedee   defd„Zy)z
Buffer byte streams.
é    )Úcount)ÚDictÚIteratorÚListÚTypeVar)ÚFactoryÚdefine)ÚAMPÚCommandÚIntegerÚStringÚTc                   ó$   — e Zd ZdZd e«       fgZy)Ú
StreamOpenz
    Open a new stream.
    ó   streamIdN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úresponse© ó    ú</usr/lib/python3/dist-packages/twisted/trial/_dist/stream.pyr   r      s   „ ñð ™g›iÐ(Ð)�Hr   r   c                   ó4   — e Zd ZdZd e«       fd e«       fgZy)ÚStreamWritez,
    Write a chunk of data to a stream.
    r   s   dataN)r   r   r   r   r   ÚBytesÚ	argumentsr   r   r   r   r      s$   „ ñð
 
‘g“iÐ Ø	‘%“'Ðð�Ir   r   c                   ó�   — e Zd ZU dZ e«       Zee   ed<    e	e
«      Zeeee   f   ed<   defd„Zdededdfd	„Zdedee   fd
„Zy)ÚStreamReceiverz9
    Buffering de-multiplexing byte stream receiver.
    Ú_counterÚ_streamsÚreturnc                 óN   — t        | j                  «      }g | j                  |<   |S )zE
        Open a new stream and return its unique identifier.
        )Únextr    r!   )ÚselfÚnewIds     r   ÚopenzStreamReceiver.open+   s%   € ô �T—]‘]Ó#ˆØ!ˆ�‰�eÑØˆr   ÚstreamIdÚchunkNc                 ó@   — | j                   |   j                  |«       y)z�
        Write to an open stream using its unique identifier.

        @raise KeyError: If there is no such open stream.
        N)r!   Úappend)r%   r(   r)   s      r   ÚwritezStreamReceiver.write3   s   € ð 	�‰�hÑ×&Ñ& uÕ-r   c                 ó8   — | j                   j                  |«      S )z°
        Indicate an open stream may receive no further data and return all of
        its current contents.

        @raise KeyError: If there is no such open stream.
        )r!   Úpop)r%   r(   s     r   ÚfinishzStreamReceiver.finish;   s   € ð �}‰}× Ñ  Ó*Ð*r   )r   r   r   r   r   r    r   ÚintÚ__annotations__r   Údictr!   r   r   Úbytesr'   r,   r/   r   r   r   r   r   "   sr   … ññ $›g€Hˆh�s‰mÓ%Ù'.¨t£}€Hˆd�3˜˜U™Ð#Ñ$Ó4ð�có ð.˜cð .¨%ð .°Dó .ð+˜sð + t¨E¡{ô +r   r   ÚdataÚ	chunkSizer"   c              #   ój   K  — d}|t        | «      k  r| |||z    –— ||z  }|t        | «      k  rŒyy­w)a  
    Break a byte string into pieces of no more than ``chunkSize`` length.

    @param data: The byte string.

    @param chunkSize: The maximum length of the resulting pieces.  All pieces
        except possibly the last will be this length.

    @return: The pieces.
    r   N)Úlen)r4   r5   Úposs      r   r)   r)   E   s@   è ø€ ð €CØ
”�D“	Š/Ø�3˜˜y™Ð)Ò)ØˆyÑˆð ”�D“	�/ùs   ‚.3±3ÚampÚchunksc              ƒ   óÈ   K  — | j                  t        «      ƒ d{  –—† d   }t        |t        «      sJ ‚|D ]"  }| j                  t        ||¬«      ƒ d{  –—†  Œ$ |S 7 ŒB7 Œ
­w)zö
    Send the given stream chunks, one by one, over the given connection.

    The chunks are sent using L{StreamWrite} over a stream opened using
    L{StreamOpen}.

    @return: The identifier of the stream over which the chunks were sent.
    Nr(   )r(   r4   )Ú
callRemoter   Ú
isinstancer0   r   )r9   r:   r(   ÚoneChunks       r   Ústreamr?   V   sh   è ø€ ð —n‘n¤ZÓ0×0°*Ñ=€HÜ�h¤Ô$Ð$Ð$àò LˆØ�n‰nœ[°8À(ˆnÓK×KÑKðLà€Oð 1øð 	Lús!   ‚A"›Aœ9A"ÁA Á	A"Á A"N)r   Ú	itertoolsr   Útypingr   r   r   r   Úattrsr   r	   Útwisted.protocols.ampr
   r   r   r   r   r   r   r   r   r3   r0   r)   r?   r   r   r   ú<module>rD      s•   ðñõ ß 0Ó 0ç !ç HÓ HáˆCƒL€ô*�ô *ô�'ô ð ÷+ð +ó ð+ðD�ð  #ð ¨(°5©/ó ð"�cð  8¨E¡?ð °sô r   