MINI MINI MANI MO

Path : /lib64/python3.6/asyncio/__pycache__/
File Upload :
Current File : //lib64/python3.6/asyncio/__pycache__/streams.cpython-36.pyc

3


 \_@sLdZdddddddgZdd	lZeed
r6ejddgd
dlmZd
dlmZd
dlmZd
dlm	Z	d
dlm
Z
d
dlmZd"Z
GdddeZGdddeZe
d#d	e
dddZe
d$d	e
dddZeed
re
d%d	e
dddZe
d&d	e
dddZGddde	jZGdddee	jZGd ddZGd!ddZd	S)'zStream-related things.StreamReaderStreamWriterStreamReaderProtocolopen_connectionstart_serverIncompleteReadErrorLimitOverrunErrorNZAF_UNIXopen_unix_connectionstart_unix_server)
coroutines)compat)events)	protocols)	coroutine)loggercs(eZdZdZfddZddZZS)rz
    Incomplete read error. Attributes:

    - partial: read bytes string before the end of stream was reached
    - expected: total number of expected bytes (or None if unknown)
    cs(tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr)	__class__'/usr/lib64/python3.6/asyncio/streams.pyr szIncompleteReadError.__init__cCst||j|jffS)N)typerr)rrrr
__reduce__&szIncompleteReadError.__reduce__)__name__
__module____qualname____doc__rr
__classcell__rr)rrrscs(eZdZdZfddZddZZS)rzReached the buffer limit while looking for a separator.

    Attributes:
    - consumed: total number of to be consumed bytes.
    cstj|||_dS)N)rrconsumed)rmessager$)rrrr0szLimitOverrunError.__init__cCst||jd|jffS)Nr)rargsr$)rrrrr4szLimitOverrunError.__reduce__)rr r!r"rrr#rr)rrr*s)looplimitc	+sb|dkrtj}t||d}t||d|jfdd||f|EdH\}}t|||}||fS)aA wrapper for create_connection() returning a (reader, writer) pair.

    The reader returned is a StreamReader instance; the writer is a
    StreamWriter instance.

    The arguments are all the usual arguments to create_connection()
    except protocol_factory; most common are positional host and port,
    with various optional keyword arguments following.

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    (If you want to customize the StreamReader and/or
    StreamReaderProtocol classes, just copy the code -- there's
    really nothing special here except some convenience.)
    N)r(r')r'csS)Nrr)protocolrr<lambda>Qsz!open_connection.<locals>.<lambda>)rget_event_looprrZcreate_connectionr)	hostportr'r(kwdsreader	transport_writerr)r)rr8s c+s8dkrtjfdd}j|||f|EdHS)aStart a socket server, call back for each client connected.

    The first parameter, `client_connected_cb`, takes two parameters:
    client_reader, client_writer.  client_reader is a StreamReader
    object, while client_writer is a StreamWriter object.  This
    parameter can either be a plain callback function or a coroutine;
    if it is a coroutine, it will be automatically converted into a
    Task.

    The rest of the arguments are all the usual arguments to
    loop.create_server() except protocol_factory; most common are
    positional host and port, with various optional keyword arguments
    following.  The return value is the same as loop.create_server().

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    The return value is the same as loop.create_server(), i.e. a
    Server object which can be used to stop the service.
    Ncstd}t|d}|S)N)r(r')r')rr)r/r))client_connected_cbr(r'rrfactoryqszstart_server.<locals>.factory)rr+Z
create_server)r3r,r-r'r(r.r4r)r3r(r'rrVsc+s`|dkrtj}t||d}t||d|jfdd|f|EdH\}}t|||}||fS)z@Similar to `open_connection` but works with UNIX Domain Sockets.N)r(r')r'csS)Nrr)r)rrr*sz&open_unix_connection.<locals>.<lambda>)rr+rrZcreate_unix_connectionr)pathr'r(r.r/r0r1r2r)r)rr	}sc+s6dkrtjfdd}j||f|EdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Ncstd}t|d}|S)N)r(r')r')rr)r/r))r3r(r'rrr4sz"start_unix_server.<locals>.factory)rr+Zcreate_unix_server)r3r5r'r(r.r4r)r3r(r'rr
sc@s>eZdZdZd
ddZddZddZd	d
ZeddZ	dS)FlowControlMixina)Reusable flow control logic for StreamWriter.drain().

    This implements the protocol methods pause_writing(),
    resume_reading() and connection_lost().  If the subclass overrides
    these it must call the super methods.

    StreamWriter.drain() must wait for _drain_helper() coroutine.
    NcCs0|dkrtj|_n||_d|_d|_d|_dS)NF)rr+_loop_paused
_drain_waiter_connection_lost)rr'rrrrszFlowControlMixin.__init__cCs,|jstd|_|jjr(tjd|dS)NTz%r pauses writing)r8AssertionErrorr7	get_debugrdebug)rrrr
pause_writings
zFlowControlMixin.pause_writingcCsP|js
td|_|jjr&tjd||j}|dk	rLd|_|jsL|jddS)NFz%r resumes writing)	r8r;r7r<rr=r9done
set_result)rwaiterrrrresume_writings

zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|jr4dS|dkrH|jdn
|j|dS)NT)r:r8r9r?r@
set_exception)rexcrArrrconnection_lostsz FlowControlMixin.connection_lostccsP|jrtd|jsdS|j}|dks2|js2t|jj}||_|EdHdS)NzConnection lost)r:ConnectionResetErrorr8r9	cancelledr;r7
create_future)rrArrr
_drain_helpers
zFlowControlMixin._drain_helper)N)
rr r!r"rr>rBrErrIrrrrr6s
	r6csFeZdZdZd
fdd	ZddZfddZd	d
ZddZZ	S)ra=Helper class to adapt between Protocol and StreamReader.

    (This is a helper class instead of making StreamReader itself a
    Protocol subclass, because the StreamReader has other potential
    uses, and to prevent the user of the StreamReader to accidentally
    call inappropriate methods of the protocol.)
    Ncs*tj|d||_d|_||_d|_dS)N)r'F)rr_stream_reader_stream_writer_client_connected_cb	_over_ssl)rZ
stream_readerr3r')rrrrs
zStreamReaderProtocol.__init__cCsd|jj||jddk	|_|jdk	r`t|||j|j|_|j|j|j}tj	|r`|jj
|dS)NZ
sslcontext)rJ
set_transportget_extra_inforMrLrr7rKrZiscoroutineZcreate_task)rr0resrrrconnection_mades


z$StreamReaderProtocol.connection_madecsF|jdk	r*|dkr|jjn|jj|tj|d|_d|_dS)N)rJfeed_eofrCrrErK)rrD)rrrrEs
z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rJ	feed_data)rdatarrr
data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rJrRrM)rrrreof_receiveds
z!StreamReaderProtocol.eof_received)NN)
rr r!r"rrQrErUrVr#rr)rrrs
c@sjeZdZdZddZddZeddZdd	Zd
dZ	dd
Z
ddZddZdddZ
eddZdS)ra'Wraps a Transport.

    This exposes write(), writelines(), [can_]write_eof(),
    get_extra_info() and close().  It adds drain() which returns an
    optional Future on which you can wait for flow control.  It also
    adds a transport property which references the Transport
    directly.
    cCs2||_||_|dks"t|ts"t||_||_dS)N)
_transport	_protocol
isinstancerr;_readerr7)rr0r)r/r'rrrrs
zStreamWriter.__init__cCs:|jjd|jg}|jdk	r,|jd|jddj|S)Nztransport=%rz	reader=%rz<%s> )rrrWrZappendjoin)rinforrr__repr__!s
zStreamWriter.__repr__cCs|jS)N)rW)rrrrr0'szStreamWriter.transportcCs|jj|dS)N)rWwrite)rrTrrrr`+szStreamWriter.writecCs|jj|dS)N)rW
writelines)rrTrrrra.szStreamWriter.writelinescCs
|jjS)N)rW	write_eof)rrrrrb1szStreamWriter.write_eofcCs
|jjS)N)rW
can_write_eof)rrrrrc4szStreamWriter.can_write_eofcCs
|jjS)N)rWclose)rrrrrd7szStreamWriter.closeNcCs|jj||S)N)rWrO)rnamedefaultrrrrO:szStreamWriter.get_extra_infoccsN|jdk	r |jj}|dk	r ||jdk	r:|jjr:dV|jjEdHdS)z~Flush the write buffer.

        The intended use is to write

          w.write(data)
          yield from w.drain()
        N)rZ	exceptionrWZ
is_closingrXrI)rrDrrrdrain=s	



zStreamWriter.drain)N)rr r!r"rr_propertyr0r`rarbrcrdrOrrhrrrrrs
c@seZdZedfddZddZddZdd	Zd
dZdd
Z	ddZ
ddZddZddZ
eddZeddZed'ddZed)ddZed d!Zejred"d#Zed$d%Zejrd&d#ZdS)*rNcCsZ|dkrtd||_|dkr*tj|_n||_t|_d|_d|_d|_	d|_
d|_dS)NrzLimit cannot be <= 0F)
ValueError_limitrr+r7	bytearray_buffer_eof_waiter
_exceptionrWr8)rr(r'rrrrXszStreamReader.__init__cCsdg}|jr |jdt|j|jr0|jd|jtkrJ|jd|j|jr`|jd|j|jrv|jd|j|jr|jd|j|j	r|jdd	d
j
|S)Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>r[)rmr\rrnrk_DEFAULT_LIMITrorprWr8r])rr^rrrr_ks 


zStreamReader.__repr__cCs|jS)N)rp)rrrrrg}szStreamReader.exceptioncCs0||_|j}|dk	r,d|_|js,|j|dS)N)rprorGrC)rrDrArrrrCszStreamReader.set_exceptioncCs*|j}|dk	r&d|_|js&|jddS)z1Wakeup read*() functions waiting for data or EOF.N)rorGr@)rrArrr_wakeup_waiters
zStreamReader._wakeup_waitercCs|jdkstd||_dS)NzTransport already set)rWr;)rr0rrrrNszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jjdS)NF)r8rrmrkrWresume_reading)rrrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rnrs)rrrrrRszStreamReader.feed_eofcCs|jo|jS)z=Return True if the buffer is empty and 'feed_eof' was called.)rnrm)rrrrat_eofszStreamReader.at_eofcCs|jstd|sdS|jj||j|jdk	r|jrt|jd|jkry|jj	Wnt
k
rzd|_YnXd|_dS)Nzfeed_data after feed_eofrT)rnr;rmextendrsrWr8rrkZ
pause_readingNotImplementedError)rrTrrrrSs
zStreamReader.feed_dataccsf|jdk	rtd||js&td|jr<d|_|jj|jj|_z|jEdHWdd|_XdS)zpWait until feed_data() or feed_eof() is called.

        If stream was paused, automatically resume it.
        NzH%s() called while another coroutine is already waiting for incoming dataz_wait_for_data after EOFF)	roRuntimeErrorrnr;r8rWrtr7rH)rZ	func_namerrr_wait_for_datas


zStreamReader._wait_for_dataccsd}t|}y|j|EdH}Wntk
rB}z|jSd}~Xnftk
r}zJ|jj||jrv|jd|j|=n
|jj|j	t
|jdWYdd}~XnX|S)aRead chunk of data from the stream until newline (b'
') is found.

        On success, return chunk that ends with newline. If only partial
        line can be read due to EOF, return incomplete line without
        terminating newline. When EOF was reached while no bytes read, empty
        bytes object is returned.

        If limit is reached, ValueError will be raised. In that case, if
        newline was found, complete line including newline will be removed
        from internal buffer. Else, internal buffer will be cleared. Limit is
        compared against part of the line without newline.

        If stream was paused, this function will automatically resume it if
        needed.
        
Nr)r	readuntilrrrrm
startswithr$clearrurjr&)rsepseplenlineerrrreadlines
 zStreamReader.readliner{ccst|}|dkrtd|jdk	r(|jd}xt|j}|||kr||jj||}|dkr\P|d|}||jkr|td||jrt|j}|jj	t
|d|jdEdHq.W||jkrtd||jd||}|jd||=|jt|S)	aVRead data from the stream until ``separator`` is found.

        On success, the data and separator will be removed from the
        internal buffer (consumed). Returned data will include the
        separator at the end.

        Configured stream limit is used to check result. Limit sets the
        maximal length of data that can be returned, not counting the
        separator.

        If an EOF occurs and the complete separator is still not found,
        an IncompleteReadError exception will be raised, and the internal
        buffer will be reset.  The IncompleteReadError.partial attribute
        may contain the separator partially.

        If the data cannot be read because of over limit, a
        LimitOverrunError exception  will be raised, and the data
        will be left in the internal buffer, so it can be read again.
        rz,Separator should be at least one-byte stringNrz2Separator is not found, and chunk exceed the limitr|z2Separator is found, but chunk is longer than limit)
rrjrprmfindrkrrnbytesr~rrzru)rZ	separatorroffsetZbuflenZisepchunkrrrr|s:






zStreamReader.readuntilrccs|jdk	r|j|dkrdS|dkrZg}x&|j|jEdH}|sBP|j|q*Wdj|S|jrz|jrz|jdEdHt|jd|}|jd|=|j	|S)aRead up to `n` bytes from the stream.

        If n is not provided, or set to -1, read until EOF and return all read
        bytes. If the EOF was received and the internal buffer is empty, return
        an empty bytes object.

        If n is zero, return empty bytes object immediately.

        If n is positive, this function try to read `n` bytes, and may return
        less or equal bytes than requested, but at least one byte. If EOF was
        received before any byte is read, this function returns empty byte
        object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        Nrread)
rprrkr\r]rmrnrzrru)rnZblocksblockrTrrrrPs$

zStreamReader.readccs|dkrtd|jdk	r |j|dkr,dSxFt|j|krr|jr`t|j}|jjt|||jdEdHq.Wt|j|krt|j}|jjnt|jd|}|jd|=|j	|S)aRead exactly `n` bytes.

        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.

        if n is zero, return empty bytes object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        rz*readexactly size can not be less than zeroNrreadexactly)
rjrprrmrnrr~rrzru)rrZ
incompleterTrrrrs&




zStreamReader.readexactlycCs|S)Nr)rrrr	__aiter__szStreamReader.__aiter__ccs|jEdH}|dkrt|S)Nr)rStopAsyncIteration)rvalrrr	__anext__szStreamReader.__anext__cCs|S)Nr)rrrrrs)r{r)r)rr r!rrrr_rgrCrsrNrurRrvrSrrzrr|rrr
ZPY35rrZPY352rrrrrVs,	 [2*i)NN)NN)N)N)r"__all__Zsockethasattrrwrr
rrrlogrrrEOFErrorr	Exceptionrrrr	r
ZProtocolr6rrrrrrr<module>sB
"B3G

OHA YOOOO