o
    >h                     @  s   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZ e ZeejG dd	 d	ZeejejejejG d
d dZdS )zStandard input/out/err support.

Future Plans::

    support for stderr, perhaps
    Rewrite to use the reactor instead of an ad-hoc mechanism for connecting
        protocols to transport.

Maintainer: James Y Knight
    )annotations)implementer)
interfacesprocess)	IProtocolIReactorFDSet)Logger)Failurec                   @  s   e Zd ZdS )PipeAddressN)__name__
__module____qualname__ r   r   |/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/internet/_posixstdio.pyr
      s    r
   c                   @  s   e Zd ZdZdZdZdZ			d>d?ddZdd Zdd Z	dd Z
dd Zdd Zdd Zd@d d!ZdAd$d%Zd&d' ZdBd(d)ZdBd*d+Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= ZdS )C
StandardIONFr      protor   stdinintstdoutreactorIReactorFDSet | Nonec                 C  sX   |d u r
ddl m} || _t|| d|| _t|| d|| _| j  | j	|  d S )Nr   )r   writeread)
twisted.internetr   protocolr   ProcessWriter_writerProcessReader_readerstartReadingmakeConnection)selfr   r   r   r   r   r   r   __init__*   s   
zStandardIO.__init__c                 C     | j d ur| j   d S d S N)r   loseConnectionr"   r   r   r   loseWriteConnection=      
zStandardIO.loseWriteConnectionc                 C     | j d ur| j | d S d S r%   )r   r   r"   datar   r   r   r   A      
zStandardIO.writec                 C  r*   r%   )r   writeSequencer+   r   r   r   r.   E   r-   zStandardIO.writeSequencec                 C  s6   d| _ | jd ur| j  | jd ur| j  d S d S )NT)disconnectingr   r&   r   stopReadingr'   r   r   r   r&   I   s   


zStandardIO.loseConnectionc                 C     t  S r%   r
   r'   r   r   r   getPeerR      zStandardIO.getPeerc                 C  r1   r%   r2   r'   r   r   r   getHostU   r4   zStandardIO.getHostfdstrr,   bytesreturnNonec                 C  s   | j | d S r%   )r   dataReceived)r"   r6   r,   r   r   r   childDataReceivedY   s   zStandardIO.childDataReceivedreasonr	   c                 C  s.   | j rd S |dkr| | d S | | d S )Nr   )disconnected_readConnectionLost_writeConnectionLost)r"   r6   r=   r   r   r   childConnectionLost\   s
   zStandardIO.childConnectionLostc                 C  s   d| _ | j}| j}| j}d  | _| _d | _|d ur!|j s!|| |d ur-|j s-|| td || W d    d S 1 sCw   Y  d S )NTz#while calling stdio connectionLost:)r>   r   r   r   connectionLost_logfailuresHandled)r"   r=   r   r   r   r   r   r   rB   d   s   

"zStandardIO.connectionLostc                 C  s|   d | _ | jr| | d S t| jd }|r:td}|  W d    n1 s*w   Y  |j	r<| |j
 d S d S d S )Nz(while calling stdio writeConnectionLost:)r   r/   rB   r   IHalfCloseableProtocolr   rC   rD   writeConnectionLostfailedfailure)r"   r=   pwclr   r   r   r@   w   s    

zStandardIO._writeConnectionLostc                 C  sr   d | _ t| jd }|r2td}|  W d    n1 s w   Y  |jr0| |j	 d S d S | | d S )Nz'while calling stdio readConnectionLost:)
r   r   rE   r   rC   rD   readConnectionLostrG   rB   rH   )r"   r=   rI   rclr   r   r   r?      s   
zStandardIO._readConnectionLostc                 C  s(   | j d u r|  d S | j || d S r%   )r   stopProducingregisterProducer)r"   producer	streamingr   r   r   rN      s   
zStandardIO.registerProducerc                 C  r$   r%   )r   unregisterProducerr'   r   r   r   rQ      r)   zStandardIO.unregisterProducerc                 C  s   |    d S r%   )r&   r'   r   r   r   rM      s   zStandardIO.stopProducingc                 C  r$   r%   )r   pauseProducingr'   r   r   r   rR      r)   zStandardIO.pauseProducingc                 C  r$   r%   )r   resumeProducingr'   r   r   r   rS      r)   zStandardIO.resumeProducingc                 C     |    dS )z3Compatibility only, don't use. Call pauseProducing.N)rR   r'   r   r   r   r0         zStandardIO.stopReadingc                 C  rT   )z4Compatibility only, don't use. Call resumeProducing.N)rS   r'   r   r   r   r       rU   zStandardIO.startReadingc                 C     t  r%   NotImplementedErrorr"   r=   r   r   r   rK         zStandardIO.readConnectionLostc                 C  rV   r%   rW   rY   r   r   r   rF      rZ   zStandardIO.writeConnectionLost)r   r   N)r   r   r   r   r   r   r   r   )r6   r7   r,   r8   r9   r:   )r6   r7   r=   r	   r9   r:   )r=   r	   r9   r:   )r   r   r   r   r   r>   r/   r#   r(   r   r.   r&   r3   r5   r<   rA   rB   r@   r?   rN   rQ   rM   rR   rS   r0   r    rK   rF   r   r   r   r   r      s:    	



r   N)__doc__
__future__r   zope.interfacer   r   r   r   twisted.internet.interfacesr   r   twisted.loggerr   twisted.python.failurer	   rC   IAddressr
   
ITransport	IProducer	IConsumerIHalfCloseableDescriptorr   r   r   r   r   <module>   s"   
