o
    ¯bD  ã                   @   s˜   d Z ddlZddlZddlmZ ddlZddlmZmZ ddl	m
Z
mZmZmZmZ ddlmZ ee
ƒG dd„ dƒƒZeeeeƒG d	d
„ d
ejƒƒZdS )zM
Windows-specific implementation of the L{twisted.internet.stdio} interface.
é    N)Úimplementer)Ú_pollingfileÚmain)ÚIAddressÚ	IConsumerÚIHalfCloseableProtocolÚIPushProducerÚ
ITransport)ÚFailurec                   @   s   e Zd ZdS )ÚWin32PipeAddressN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú>/usr/lib/python3/dist-packages/twisted/internet/_win32stdio.pyr      s    r   c                   @   s’   e Zd ZdZdZd"dd„Zdd„ Zdd„ Zd	d
„ ZdZ	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ ZdS )#Ú
StandardIOFNc                 C   s¬   |du r
ddl m} tdddƒD ]	}t |tj¡ qtj 	| |¡ || _
t tj¡}t tj¡}t || j| j¡| _t || j¡| _|  | j¡ |  | j¡ | j
 | ¡ dS )zƒ
        Start talking to standard IO with the given protocol.

        Also, put it stdin/stdout/stderr into binary mode.
        Nr   )Úreactoré   é   )Útwisted.internetr   ÚrangeÚmsvcrtÚsetmodeÚosÚO_BINARYr   Ú_PollingTimerÚ__init__ÚprotoÚwin32apiÚGetStdHandleÚSTD_INPUT_HANDLEÚSTD_OUTPUT_HANDLEÚ_PollableReadPipeÚdataReceivedÚreadConnectionLostÚstdinÚ_PollableWritePipeÚwriteConnectionLostÚstdoutÚ_addPollableResourceÚmakeConnection)Úselfr   r   ÚstdfdÚhstdinÚhstdoutr   r   r   r   %   s   
ÿzStandardIO.__init__c                 C   ó   | j  |¡ d S ©N)r   r#   ©r+   Údatar   r   r   r#   B   ó   zStandardIO.dataReceivedc                 C   ó"   t  | j¡r| j ¡  |  ¡  d S r0   )r   Ú
providedByr   r$   ÚcheckConnLost©r+   r   r   r   r$   E   ó   
zStandardIO.readConnectionLostc                 C   r4   r0   )r   r5   r   r'   r6   r7   r   r   r   r'   J   r8   zStandardIO.writeConnectionLostr   c                 C   s>   |  j d7  _ | j dkrd| _d| _| j ttjƒ¡ d S d S )Nr   r   T)Ú	connsLostÚdisconnectingÚdisconnectedr   ÚconnectionLostr
   r   ÚCONNECTION_DONEr7   r   r   r   r6   Q   s   
ýzStandardIO.checkConnLostc                 C   r/   r0   )r(   Úwriter1   r   r   r   r>   Z   r3   zStandardIO.writec                 C   s   | j  d |¡¡ d S )Nó    )r(   r>   Újoin)r+   Úseqr   r   r   ÚwriteSequence]   s   zStandardIO.writeSequencec                 C   s   d| _ | j ¡  | j ¡  d S )NT)r:   r%   Úcloser(   r7   r   r   r   ÚloseConnection`   s   
zStandardIO.loseConnectionc                 C   ó   t ƒ S r0   ©r   r7   r   r   r   ÚgetPeere   ó   zStandardIO.getPeerc                 C   rE   r0   rF   r7   r   r   r   ÚgetHosth   rH   zStandardIO.getHostc                 C   s   | j  ||¡S r0   )r(   ÚregisterProducer)r+   ÚproducerÚ	streamingr   r   r   rJ   m   ó   zStandardIO.registerProducerc                 C   s
   | j  ¡ S r0   )r(   ÚunregisterProducerr7   r   r   r   rN   p   s   
zStandardIO.unregisterProducerc                 C   ó   | j  ¡  d S r0   )r%   ÚstopProducingr7   r   r   r   rP   w   rM   zStandardIO.stopProducingc                 C   rO   r0   )r%   ÚpauseProducingr7   r   r   r   rQ   |   rM   zStandardIO.pauseProducingc                 C   rO   r0   )r%   ÚresumeProducingr7   r   r   r   rR      rM   zStandardIO.resumeProducingr0   )r   r   r   r:   r;   r   r#   r$   r'   r9   r6   r>   rB   rD   rG   rI   rJ   rN   rP   rQ   rR   r   r   r   r   r      s&    
	r   )Ú__doc__r   r   Úzope.interfacer   r   r   r   r   Útwisted.internet.interfacesr   r   r   r   r	   Útwisted.python.failurer
   r   r   r   r   r   r   r   Ú<module>   s   
