
    h                    $   S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	J
r
  SSKJr  SSKJr  \" 5       r\" \R                   5       " S S	5      5       r\" \R$                  \R&                  \R(                  \R*                  5       " S
 S5      5       rg)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                      \ rS rSrSrg)PipeAddress    N)__name__
__module____qualname____firstlineno____static_attributes__r       c/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/internet/_posixstdio.pyr   r      s    r   r   c                      \ rS rSrSrSrSrSr   S       SS jjrS r	S r
S rS rS	 rS
 rSS jrSS jrS rSS jrSS jrS rS rS rS rS rS rS rS rS rSrg)
StandardIO   NFc                    Uc  SSK Jn  Xl        [        R                  " X@SU5      U l        [        R                  " X@SU5      U l        U R                  R                  5         U R                  R                  U 5        g )Nr   )reactorwriteread)
twisted.internetr   protocolr   ProcessWriter_writerProcessReader_readerstartReadingmakeConnection)selfprotostdinstdoutr   s        r   __init__StandardIO.__init__*   s_     ?0#(,,WGVL,,WFEJ!!#$$T*r   c                T    U R                   b  U R                   R                  5         g g N)r    loseConnectionr%   s    r   loseWriteConnectionStandardIO.loseWriteConnection=   !    <<#LL'') $r   c                V    U R                   b  U R                   R                  U5        g g r,   )r    r   r%   datas     r   r   StandardIO.writeA   s#    <<#LLt$ $r   c                V    U R                   b  U R                   R                  U5        g g r,   )r    writeSequencer3   s     r   r7   StandardIO.writeSequenceE   s#    <<#LL&&t, $r   c                    SU l         U R                  b  U R                  R                  5         U R                  b  U R                  R	                  5         g g )NT)disconnectingr    r-   r"   stopReadingr.   s    r   r-   StandardIO.loseConnectionI   sC    !<<#LL'')<<#LL$$& $r   c                    [        5       $ r,   r   r.   s    r   getPeerStandardIO.getPeerR   
    }r   c                    [        5       $ r,   r>   r.   s    r   getHostStandardIO.getHostU   rA   r   c                :    U R                   R                  U5        g r,   )r   dataReceived)r%   fdr4   s      r   childDataReceivedStandardIO.childDataReceivedY   s    ""4(r   c                z    U R                   (       a  g US:X  a  U R                  U5        g U R                  U5        g )Nr   )disconnected_readConnectionLost_writeConnectionLost)r%   rG   reasons      r   childConnectionLostStandardIO.childConnectionLost\   s1    <$$V,%%f-r   c                   SU l         U R                  nU R                  nU R                  nS =U l        U l        S U l        Ub"  UR                   (       d  UR	                  U5        Ub"  UR                   (       d  UR	                  U5        [
        R                  S5         UR	                  U5        S S S 5        g ! , (       d  f       g = f)NTz#while calling stdio connectionLost:)rK   r"   r    r   connectionLost_logfailuresHandled)r%   rN   r"   r    r   s        r   rR   StandardIO.connectionLostd   s      ,,,,==&**t|w';';""6*w';';""6*!!"GH##F+ IHHs    B;;
C	c                   S U l         U R                  (       a  U R                  U5        g [        R                  " U R
                  S 5      nU(       a\  [        R                  S5       nUR                  5         S S S 5        WR                  (       a  U R                  UR                  5        g g g ! , (       d  f       N== f)Nz(while calling stdio writeConnectionLost:)r    r:   rR   r   IHalfCloseableProtocolr   rS   rT   writeConnectionLostfailedfailure)r%   rN   pwcls       r   rM   StandardIO._writeConnectionLostw   s    '--dmmTB%%:%%' zz##CKK0   s   (B00
B>c                ^   S U l         [        R                  " U R                  S 5      nU(       a\  [        R                  S5       nUR                  5         S S S 5        WR                  (       a  U R                  UR                  5        g g U R                  U5        g ! , (       d  f       NN= f)Nz'while calling stdio readConnectionLost:)
r"   r   rW   r   rS   rT   readConnectionLostrY   rR   rZ   )r%   rN   r[   rcls       r   rL   StandardIO._readConnectionLost   s~    --dmmTB%%&OPTW$$& Qzz##CKK0  ' QPs   B
B,c                v    U R                   c  UR                  5         g U R                   R                  X5        g r,   )r    stopProducingregisterProducer)r%   producer	streamings      r   rd   StandardIO.registerProducer   s*    <<""$LL))(>r   c                T    U R                   b  U R                   R                  5         g g r,   )r    unregisterProducerr.   s    r   ri   StandardIO.unregisterProducer   s!    <<#LL++- $r   c                $    U R                  5         g r,   )r-   r.   s    r   rc   StandardIO.stopProducing   s    r   c                T    U R                   b  U R                   R                  5         g g r,   )r"   pauseProducingr.   s    r   rn   StandardIO.pauseProducing   r1   r   c                T    U R                   b  U R                   R                  5         g g r,   )r"   resumeProducingr.   s    r   rq   StandardIO.resumeProducing   s!    <<#LL((* $r   c                $    U R                  5         g)z3Compatibility only, don't use. Call pauseProducing.N)rn   r.   s    r   r;   StandardIO.stopReading   s    r   c                $    U R                  5         g)z4Compatibility only, don't use. Call resumeProducing.N)rq   r.   s    r   r#   StandardIO.startReading   s    r   c                    [        5       er,   NotImplementedErrorr%   rN   s     r   r_   StandardIO.readConnectionLost       !##r   c                    [        5       er,   rx   rz   s     r   rX   StandardIO.writeConnectionLost   r|   r   )r"   r    rK   r:   r   )r      N)r&   r   r'   intr(   r   r   zIReactorFDSet | None)rG   strr4   bytesreturnNone)rG   r   rN   r
   r   r   )rN   r
   r   r   )r   r   r   r   r"   r    rK   r:   r)   r/   r   r7   r-   r?   rC   rH   rO   rR   rM   rL   rd   ri   rc   rn   rq   r;   r#   r_   rX   r   r   r   r   r   r      s     GGLM
 (,++ + 	+
 &+&*%-').,&1	(?.
*+$$r   r   N)__doc__
__future__r   zope.interfacer   r   r   r   twisted.internet.interfacesr   r   twisted.loggerr	   twisted.python.failurer
   rS   IAddressr   
ITransport	IProducer	IConsumerIHalfCloseableDescriptorr   r   r   r   <module>r      s   	 # & 0 @ ! *x Z  !	 	 "	 ''	R$ R$R$r   