a °…bVã@s`dZddlZddlZddlZdd„ZGdd„deƒZGdd„deƒZGd d „d eƒZd d „Z dS) a Abstraction of a one-way pipe where the read end can be used in `select.select`. Normally this is trivial, but Windows makes it nearly impossible. The pipe acts like an Event, which can be set or cleared. When set, the pipe will trigger as readable in `select `. éNcCs$tjdd…dkrtƒ}ntƒ}|S)NéÚwin)ÚsysÚplatformÚ PosixPipeÚ WindowsPipe)Úp©r ú4/tmp/pip-target-98j97qn4/lib/python/paramiko/pipe.pyÚ make_pipe!sr c@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)rcCs&t ¡\|_|_d|_d|_d|_dS©NF)ÚosÚpipeÚ_rfdÚ_wfdÚ_setÚ_foreverÚ_closed©Úselfr r r Ú__init__*szPosixPipe.__init__cCs"t |j¡t |j¡d|_dS©NT)r Úcloserrrrr r r r0s  zPosixPipe.closecCs|jS©N)rrr r r Úfileno6szPosixPipe.filenocCs(|jr |jrdSt |jd¡d|_dS©NéF)rrr Úreadrrr r r Úclear9s zPosixPipe.clearcCs(|js |jrdSd|_t |jd¡dS©NTó*)rrr Úwriterrr r r Úset?s z PosixPipe.setcCsd|_| ¡dSr©rr"rr r r Ú set_foreverEszPosixPipe.set_foreverN) Ú__name__Ú __module__Ú __qualname__rrrrr"r$r r r r r)s rc@s@eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dS)rz‡ On Windows, only an OS-level "WinSock" may be used in select(), but reads and writes must be to the actual socket object. cCszt tjtj¡}| d¡| d¡t tjtj¡|_|j d| ¡df¡| ¡\|_ }|  ¡d|_ d|_ d|_ dS)N)ú 127.0.0.1rrr(F)ÚsocketÚAF_INETÚ SOCK_STREAMÚbindÚlistenÚ_rsockÚconnectÚ getsocknameÚacceptÚ_wsockrrrr)rZservÚaddrr r r rPs  zWindowsPipe.__init__cCs|j ¡|j ¡d|_dSr)r.rr2rrr r r r_s  zWindowsPipe.closecCs |j ¡Sr)r.rrr r r reszWindowsPipe.filenocCs&|jr |jrdS|j d¡d|_dSr)rrr.Úrecvrr r r rhs  zWindowsPipe.clearcCs&|js |jrdSd|_|j d¡dSr)rrr2Úsendrr r r r"ns zWindowsPipe.setcCsd|_| ¡dSrr#rr r r r$tszWindowsPipe.set_foreverN) r%r&r'Ú__doc__rrrrr"r$r r r r rJsrc@s$eZdZdd„Zdd„Zdd„ZdS)ÚOrPipecCsd|_d|_||_dSr )rÚ_partnerÚ_pipe)rrr r r rzszOrPipe.__init__cCsd|_|jjs|j ¡dSr)rr8r9r"rr r r r"sz OrPipe.setcCsd|_|jjs|j ¡dSr )rr8r9rrr r r r„sz OrPipe.clearN)r%r&r'rr"rr r r r r7ysr7cCs$t|ƒ}t|ƒ}||_||_||fS)zØ wraps a pipe into two pipe-like objects which are "or"d together to affect the real pipe. if either returned pipe is set, the wrapped pipe is set. when both are cleared, the wrapped pipe is cleared. )r7r8)rÚp1Úp2r r r Ú make_or_pipeŠs r<) r6rr r)r Úobjectrrr7r<r r r r Ús !/