%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib64/python3.7/site-packages/aiohttp/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/aiohttp/__pycache__/streams.cpython-37.pyc

B

�Z�_2P�@s8ddlZddlZddlZddlmZmZmZmZmZm	Z	m
Z
ddlmZddl
mZmZmZddlmZyddlmZWn ek
r�ddlmZYnXdZe
d	�ZGd
d�de�ZGdd
�d
ee�ZGdd�d�ZGdd�d�ZGdd�de�ZGdd�de�Ze�ZGdd�dee�Z Gdd�de e�Z!dS)�N)�	Awaitable�Callable�Generic�List�Optional�Tuple�TypeVar�)�BaseProtocol)�BaseTimerContext�
set_exception�
set_result)�internal_logger)�Deque)�
EMPTY_PAYLOAD�	EofStream�StreamReader�	DataQueue�FlowControlDataQueue�_Tc@seZdZdZdS)rzeof stream indication.N)�__name__�
__module__�__qualname__�__doc__�rr�B/opt/alt/python37/lib64/python3.7/site-packages/aiohttp/streams.pyrsrc@sDeZdZegeefdd�dd�Zdd�dd�Zed�d	d
�ZdS)�AsyncStreamIteratorN)�	read_func�returncCs
||_dS)N)r)�selfrrrr�__init__szAsyncStreamIterator.__init__zAsyncStreamIterator[_T])rcCs|S)Nr)rrrr�	__aiter__"szAsyncStreamIterator.__aiter__c�s<y|��IdH}Wntk
r*t�YnX|dkr8t�|S)N�)rr�StopAsyncIteration)r�rvrrr�	__anext__%s
zAsyncStreamIterator.__anext__)	rrrrrrr r!r%rrrrrsrc@s@eZdZddd�dd�Zdd�dd�Zeeefd�d	d
�ZdS)�ChunkTupleAsyncStreamIteratorrN)�streamrcCs
||_dS)N)�_stream)rr'rrrr 0sz&ChunkTupleAsyncStreamIterator.__init__)rcCs|S)Nr)rrrrr!3sz'ChunkTupleAsyncStreamIterator.__aiter__c�s |j��IdH}|dkrt�|S)N)r"F)r(�	readchunkr#)rr$rrrr%6sz'ChunkTupleAsyncStreamIterator.__anext__)	rrrr r!r�bytes�boolr%rrrrr&/sr&c@sReZdZeed�dd�Zeeed�dd�Zeed�dd�Ze	d�d	d
�Z
dS)�AsyncStreamReaderMixin)rcCs
t|j�S)N)r�readline)rrrrr!>sz AsyncStreamReaderMixin.__aiter__)�nrcst��fdd��S)zzReturns an asynchronous iterator that yields chunks of size n.

        Python-3.5 available for Python 3.5+ only
        cs
����S)N)�readr)r.rrr�<lambda>Fr"z5AsyncStreamReaderMixin.iter_chunked.<locals>.<lambda>)r)rr.r)r.rr�iter_chunkedAsz#AsyncStreamReaderMixin.iter_chunkedcCs
t|j�S)z�Returns an asynchronous iterator that yields all the available
        data as soon as it is received

        Python-3.5 available for Python 3.5+ only
        )r�readany)rrrr�iter_anyHszAsyncStreamReaderMixin.iter_anycCst|�S)a
Returns an asynchronous iterator that yields chunks of data
        as they are received by the server. The yielded objects are tuples
        of (bytes, bool) as returned by the StreamReader.readchunk method.

        Python-3.5 available for Python 3.5+ only
        )r&)rrrr�iter_chunksPsz"AsyncStreamReaderMixin.iter_chunksN)rrrrr*r!�intr1r3r&r4rrrrr,=sr,c@s�eZdZdZdZddd�eeeeee	j
dd�dd�Zed�d	d
�Z
eeefd�dd�Zeed�d
d�Zedd�dd�Zegdfdd�dd�Zdd�dd�Zed�dd�Zed�dd�Zdd�dd�Zedd�dd�Zd<eedd �d!d"�Zdd�d#d$�Zdd�d%d&�Zedd'�d(d)�Zed�d*d+�Z d=eed-�d.d/�Z!ed�d0d1�Z"eeefd�d2d3�Z#eed-�d4d5�Z$d>eed-�d6d7�Z%eed-�d8d9�Z&eed-�d:d;�Z'dS)?ra*An enhancement of asyncio.StreamReader.

    Supports asynchronous iteration by line, chunk or as available::

        async for line in reader:
            ...
        async for chunk in reader.iter_chunked(1024):
            ...
        async for slice in reader.iter_any():
            ...

    rN)�timer�loop)�protocol�limitr6r7rcCsv||_||_|d|_|dkr&t��}||_d|_d|_d|_t	�
�|_d|_d|_
d|_d|_d|_||_g|_dS)N�rF)�	_protocol�
_low_water�_high_water�asyncioZget_event_loop�_loop�_size�_cursor�_http_chunk_splits�collections�deque�_buffer�_buffer_offset�_eof�_waiter�_eof_waiter�
_exception�_timer�_eof_callbacks)rr8r9r6r7rrrr js"

zStreamReader.__init__)rcCs�|jjg}|jr |�d|j�|jr0|�d�|jdkrP|�d|j|jf�|jrf|�d|j�|jr||�d|j�dd�	|�S)	Nz%d bytes�eofizlow=%d high=%dzw=%rze=%rz<%s>� )
�	__class__rr@�appendrGr<r=rHrJ�join)r�inforrr�__repr__�s


zStreamReader.__repr__cCs|j|jfS)N)r<r=)rrrr�get_read_buffer_limits�sz#StreamReader.get_read_buffer_limitscCs|jS)N)rJ)rrrr�	exception�szStreamReader.exception)�excrcCsP||_|j��|j}|dk	r.d|_t||�|j}|dk	rLd|_t||�dS)N)rJrL�clearrHrrI)rrV�waiterrrrr�s

zStreamReader.set_exception)�callbackrcCsB|jr2y
|�Wq>tk
r.t�d�Yq>Xn|j�|�dS)NzException in eof callback)rG�	ExceptionrrUrLrP)rrYrrr�on_eof�s
zStreamReader.on_eofc	Cs�d|_|j}|dk	r$d|_t|d�|j}|dk	rBd|_t|d�x8|jD].}y
|�WqJtk
rvt�d�YqJXqJW|j��dS)NTzException in eof callback)	rGrHr
rIrLrZrrUrW)rrX�cbrrr�feed_eof�s


zStreamReader.feed_eofcCs|jS)z&Return True if  'feed_eof' was called.)rG)rrrr�is_eof�szStreamReader.is_eofcCs|jo|jS)z=Return True if the buffer is empty and 'feed_eof' was called.)rGrE)rrrr�at_eof�szStreamReader.at_eofc�sB|jr
dS|jdkst�|j��|_z|jIdHWdd|_XdS)N)rGrI�AssertionErrorr?�
create_future)rrrr�wait_eof�szStreamReader.wait_eof)�datarcCsxtjdtdd�|sdS|jr>|jd|jd�|jd<d|_|jt|�7_|jt|�8_|j�|�d|_	dS)zDrollback reading some data from stream, inserting it to buffer head.zJunread_data() is deprecated and will be removed in future releases (#3260)r:)�
stacklevelNr)
�warnings�warn�DeprecationWarningrFrEr@�lenrA�
appendleft�_eof_counter)rrcrrr�unread_data�szStreamReader.unread_data)rc�sizercCs�|jrtd��|sdS|jt|�7_|j�|�|jt|�7_|j}|dk	rdd|_t|d�|j|j	kr�|j
js�|j
��dS)Nzfeed_data after feed_eof)
rGr`r@rhrErP�total_bytesrHr
r=r;�_reading_paused�
pause_reading)rrcrlrXrrr�	feed_data�s
zStreamReader.feed_datacCs"|jdkr|jrtd��g|_dS)Nz?Called begin_http_chunk_receiving whensome data was already fed)rBrm�RuntimeError)rrrr�begin_http_chunk_receiving�s

z'StreamReader.begin_http_chunk_receivingcCsd|jdkrtd��|jr"|jdnd}|j|kr4dS|j�|j�|j}|dk	r`d|_t|d�dS)NzFCalled end_chunk_receiving without calling begin_chunk_receiving first���r)rBrqrmrPrHr
)r�posrXrrr�end_http_chunk_receivings
	
z%StreamReader.end_http_chunk_receiving)�	func_namerc	�sf|jdk	rtd|��|j��}|_z2|jrL|j�|IdHWdQRXn
|IdHWdd|_XdS)NzH%s() called while another coroutine is already waiting for incoming data)rHrqr?rarK)rrvrXrrr�_wait#s
zStreamReader._waitc�s�|jdk	r|j�g}d}d}x�|r�xp|jr�|r�|j}|jd�d|�d}|�|rZ||nd�}|�|�|t|�7}|r~d}||jkr$td��q$W|j	r�P|r|�
d�IdHqWd	�|�S)
NrT�
r	rsFzLine is too longr-r")rJrErF�find�_read_nowait_chunkrPrhr=�
ValueErrorrGrwrQ)r�lineZ	line_sizeZ
not_enough�offsetZicharrcrrrr-8s*


zStreamReader.readliners)r.rc�s�|jdk	r|j�|jrF|jsFt|dd�d|_|jdkrFtjddd�|sNdS|dkr�g}x"|��IdH}|spP|�|�q\Wd�	|�Sx |js�|js�|�
d	�IdHq�W|�|�S)
Nrjrr	�zEMultiple access to StreamReader in eof state, might be infinite loop.T)Z
stack_infor"r/)rJrGrE�getattrrjr�warningr2rPrQrw�_read_nowait)rr.�blocks�blockrrrr/Vs*


zStreamReader.readc�s<|jdk	r|j�x |js0|js0|�d�IdHqW|�d�S)Nr2rs)rJrErGrwr�)rrrrr2�s

zStreamReader.readanyc�s�x�|jdk	r|j�xL|jr^|j�d�}||jkr4dS||jkrR|�||j�dfSt�d�qW|jrt|�d�dfS|j	r~dS|�
d	�IdHqWdS)
z�Returns a tuple of (data, end_of_http_chunk). When chunked transfer
        encoding is used, end_of_http_chunk is a boolean indicating if the end
        of the data corresponds to the end of a HTTP chunk , otherwise it is
        always False.
        Nr)r"TTzESkipping HTTP chunk end due to data consumption beyond chunk boundaryrsF)r"Fr))rJrB�poprAr�rr�rErzrGrw)rrtrrrr)�s 



zStreamReader.readchunkc�st|jdk	r|j�g}xT|dkrh|�|�IdH}|sPd�|�}t�|t|�|��|�|�|t|�8}qWd�|�S)Nrr")rJr/rQr>�IncompleteReadErrorrhrP)rr.r�r��partialrrr�readexactly�s



zStreamReader.readexactlycCs2|jdk	r|j�|jr(|j��s(td��|�|�S)Nz9Called while some coroutine is waiting for incoming data.)rJrHZdonerqr�)rr.rrr�read_nowait�s
zStreamReader.read_nowaitcCs�|jd}|j}|dkrHt|�||krH||||�}|j|7_n,|rj|j��||d�}d|_n
|j��}|jt|�8_|jt|�7_|j}x |r�|d|jkr�|�d�q�W|j|jkr�|j	j
r�|j	��|S)Nrrs)rErFrh�popleftr@rArBr�r<r;rn�resume_reading)rr.Zfirst_bufferr}rcZchunk_splitsrrrrz�s$



zStreamReader._read_nowait_chunkcCsTg}x<|jr@|�|�}|�|�|dkr|t|�8}|dkrPqW|rPd�|�SdS)z8 Read not more than n bytes, or whole buffer if n == -1 rsrr")rErzrPrhrQ)rr.Zchunks�chunkrrrr��s

zStreamReader._read_nowait)r)rs)rs)(rrrrrmr
r5rrr>�AbstractEventLoopr �strrSrrT�
BaseExceptionrUrrr[r]r+r^r_rbr*rkrprrrurwr-r/r2r)r�r�rzr�rrrrrZs6	* rc@s�eZdZeed�dd�Zedd�dd�Zegdfdd�d	d
�Zdd�dd�Z	e
d�d
d�Ze
d�dd�Zdd�dd�Z
d%eedd�dd�Zed�dd�Zd&eed�dd�Zed�dd�Zeee
fd�dd �Zeed�d!d"�Zed�d#d$�ZdS)'�EmptyStreamReader)rcCsdS)Nr)rrrrrU�szEmptyStreamReader.exceptionN)rVrcCsdS)Nr)rrVrrrr�szEmptyStreamReader.set_exception)rYrcCs.y
|�Wntk
r(t�d�YnXdS)NzException in eof callback)rZrrU)rrYrrrr[�s
zEmptyStreamReader.on_eofcCsdS)Nr)rrrrr]szEmptyStreamReader.feed_eofcCsdS)NTr)rrrrr^szEmptyStreamReader.is_eofcCsdS)NTr)rrrrr_szEmptyStreamReader.at_eofc�sdS)Nr)rrrrrb
szEmptyStreamReader.wait_eofr)rcr.rcCsdS)Nr)rrcr.rrrrp
szEmptyStreamReader.feed_datac�sdS)Nr"r)rrrrr-szEmptyStreamReader.readliners)r.rc�sdS)Nr"r)rr.rrrr/szEmptyStreamReader.readc�sdS)Nr"r)rrrrr2szEmptyStreamReader.readanyc�sdS)N)r"Tr)rrrrr)szEmptyStreamReader.readchunkc�st�d|��dS)Nr")r>r�)rr.rrrr�szEmptyStreamReader.readexactlycCsdS)Nr"r)rrrrr�szEmptyStreamReader.read_nowait)r)rs)rrrrr�rUrrr[r]r+r^r_rbr*r5rpr-r/r2rr)r�r�rrrrr��sr�c@s�eZdZdZejdd�dd�Zed�dd�Ze	d�d	d
�Z
e	d�dd�Zee
d�d
d�Ze
dd�dd�Zdeedd�dd�Zdd�dd�Zed�dd�Zeed�dd�ZdS)rz>DataQueue is a general-purpose blocking queue with one reader.N)r7rcCs,||_d|_d|_d|_d|_t��|_dS)NFr)r?rGrHrJr@rCrDrE)rr7rrrr )szDataQueue.__init__)rcCs
t|j�S)N)rhrE)rrrr�__len__1szDataQueue.__len__cCs|jS)N)rG)rrrrr^4szDataQueue.is_eofcCs|jo|jS)N)rGrE)rrrrr_7szDataQueue.at_eofcCs|jS)N)rJ)rrrrrU:szDataQueue.exception)rVrcCs.d|_||_|j}|dk	r*d|_t||�dS)NT)rGrJrHr)rrVrXrrrr=szDataQueue.set_exceptionr)rcrlrcCs@|j|7_|j�||f�|j}|dk	r<d|_t|d�dS)N)r@rErPrHr
)rrcrlrXrrrrpFszDataQueue.feed_datacCs(d|_|j}|dk	r$d|_t|d�dS)NT)rGrHr
)rrXrrrr]Os
zDataQueue.feed_eofc	�s�|jsX|jsX|jrt�|j��|_y|jIdHWn$tjtjfk
rVd|_�YnX|jr~|j�	�\}}|j
|8_
|S|jdk	r�|j�nt�dS)N)
rErGrHr`r?rar>ZCancelledError�TimeoutErrorr�r@rJr)rrcrlrrrr/Ws

zDataQueue.readcCs
t|j�S)N)rr/)rrrrr!kszDataQueue.__aiter__)r)rrrrr>r�r r5r�r+r^r_rr�rUrrrpr]r/rr!rrrrr&s		rcsXeZdZdZeeejdd��fdd�Zd
e	edd��fdd	�
Z
e	d
��fdd�Z�ZS)rzgFlowControlDataQueue resumes and pauses an underlying stream.

    It is a destination for parsed data.N)r8r9r7rcs"t�j|d�||_|d|_dS)N)r7r:)�superr r;�_limit)rr8r9r7)rOrrr tszFlowControlDataQueue.__init__r)rcrlrcs0t��||�|j|jkr,|jjs,|j��dS)N)r�rpr@r�r;rnro)rrcrl)rOrrrp|szFlowControlDataQueue.feed_data)rc�s6zt���IdHS|j|jkr0|jjr0|j��XdS)N)r�r/r@r�r;rnr�)r)rOrrr/�szFlowControlDataQueue.read)r)
rrrrr
r5r>r�r rrpr/�
__classcell__rr)rOrros
r)"r>rCre�typingrrrrrrrZ
base_protocolr
Zhelpersrrr
�logrr�ImportErrorZtyping_extensions�__all__rrZrrr&r,rr�rrrrrrr�<module>s0$/I

Zerion Mini Shell 1.0