ok

Mini Shell

Direktori : /opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/streams.cpython-38.pyc

U

'�7`2P�@s8ddlZddlZddlZddlmZmZmZmZmZm	Z	m
Z
ddlmZddl
mZmZmZddlmZzddlmZWn 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/python38/lib64/python3.8/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|Srr�r rrr�	__aiter__"szAsyncStreamIterator.__aiter__c�s<z|��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
||_dSr)�_stream)r r,rrrr!0sz&ChunkTupleAsyncStreamIterator.__init__r"cCs|Srrr#rrrr$3sz'ChunkTupleAsyncStreamIterator.__aiter__c�s |j��IdH}|dkrt�|S)N�r&F)r-�	readchunkr'r(rrrr*6sz'ChunkTupleAsyncStreamIterator.__anext__)	rrrr!r$r�bytes�boolr*rrrrr+/sr+c@sReZdZeed�dd�Zeeed�dd�Zeed�dd�Ze	d�d	d
�Z
dS)�AsyncStreamReaderMixinr"cCs
t|j�Sr)r�readliner#rrrr$>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
����Sr)�readr�r5r rr�<lambda>Fr&z5AsyncStreamReaderMixin.iter_chunked.<locals>.<lambda>)r�r r5rr7r�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�readanyr#rrr�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+r#rrr�iter_chunksPsz"AsyncStreamReaderMixin.iter_chunksN)rrrrr0r$�intr:r<r+r=rrrrr2=sr2c@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�limitr?r@rcCsv||_||_|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)r rArBr?r@rrrr!js"

zStreamReader.__init__r"cCs�|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__rrI�appendrPrErFrQrS�join)r �inforrr�__repr__�s


zStreamReader.__repr__cCs|j|jfSr)rErFr#rrr�get_read_buffer_limits�sz#StreamReader.get_read_buffer_limitscCs|jSr�rSr#rrr�	exception�szStreamReader.exception��excrcCsP||_|j��|j}|dk	r.d|_t||�|j}|dk	rLd|_t||�dSr)rSrU�clearrQrrR�r ra�waiterrrrr�s

zStreamReader.set_exception��callbackrcCsB|jr2z
|�Wq>tk
r.t�d�Yq>Xn|j�|�dS�N�Exception in eof callback)rP�	Exceptionrr_rUrY�r rfrrr�on_eof�s
zStreamReader.on_eofc	Cs�d|_|j}|dk	r$d|_t|d�|j}|dk	rBd|_t|d�|jD].}z
|�WqHtk
rtt�d�YqHXqH|j��dS)NTrh)	rPrQr
rRrUrirr_rb)r rd�cbrrr�feed_eof�s



zStreamReader.feed_eofcCs|jS)z&Return True if  'feed_eof' was called.�rPr#rrr�is_eof�szStreamReader.is_eofcCs|jo|jS)z=Return True if the buffer is empty and 'feed_eof' was called.�rPrNr#rrr�at_eof�szStreamReader.at_eofc�sB|jr
dS|jdkst�|j��|_z|jIdHW5d|_XdSr)rPrR�AssertionErrorrH�
create_futurer#rrr�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)rC)�
stacklevelNr)
�warnings�warn�DeprecationWarningrOrNrI�lenrJ�
appendleft�_eof_counter)r rurrr�unread_data�s�zStreamReader.unread_data�ru�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)
rPrrrIrzrNrY�total_bytesrQr
rFrD�_reading_paused�
pause_reading�r rurrdrrr�	feed_data�s
zStreamReader.feed_datacCs"|jdkr|jrtd��g|_dS)Nz?Called begin_http_chunk_receiving whensome data was already fed)rKr��RuntimeErrorr#rrr�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)rKr�r�rYrQr
)r �posrdrrr�end_http_chunk_receivings
�

z%StreamReader.end_http_chunk_receiving)�	func_namerc	�sf|jdk	rtd|��|j��}|_z2|jrL|j�|IdHW5QRXn
|IdHW5d|_XdS)NzH%s() called while another coroutine is already waiting for incoming data)rQr�rHrsrT)r r�rdrrr�_wait#s
��zStreamReader._waitc�s�|jdk	r|j�g}d}d}|r�|jr�|r�|j}|jd�d|�d}|�|rV||nd�}|�|�|t|�7}|rzd}||jkr td��q |j	r�q�|r|�
d�IdHqd	�|�S)
NrT�
r	r�FzLine is too longr3r&)rSrNrO�find�_read_nowait_chunkrYrzrF�
ValueErrorrPr�rZ)r �lineZ	line_sizeZ
not_enough�offsetZicharrurrrr38s*




zStreamReader.readliner�r4c�s�|jdk	r|j�|jrF|jsFt|dd�d|_|jdkrFtjddd�|sNdS|dkr�g}|��IdH}|snqz|�|�qZd�	|�S|js�|js�|�
d	�IdHq�|�|�S)
Nr|rr	�zEMultiple access to StreamReader in eof state, might be infinite loop.T)Z
stack_infor&r6)rSrPrN�getattrr|r�warningr;rYrZr��_read_nowait)r r5�blocks�blockrrrr6Vs*

�
zStreamReader.readc�s8|jdk	r|j�|js.|js.|�d�IdHq|�d�S)Nr;r�)rSrNrPr�r�r#rrrr;�s

zStreamReader.readanyc�s�|jdk	r|j�|jrZ|j�d�}||jkr0dS||jkrN|�||j�dfSt�d�q|jrn|�d�dfS|j	rxdS|�
d	�IdHqdS)
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 boundaryr�Fr.r/)rSrK�poprJr�rr�rNr�rPr�)r r�rrrr/�s 


�zStreamReader.readchunkc�sp|jdk	r|j�g}|dkrf|�|�IdH}|sNd�|�}t�|t|�|��|�|�|t|�8}qd�|�S)Nrr&)rSr6rZrG�IncompleteReadErrorrzrY)r r5r�r��partialrrr�readexactly�s


zStreamReader.readexactlycCs2|jdk	r|j�|jr(|j��s(td��|�|�S)Nz9Called while some coroutine is waiting for incoming data.)rSrQZdoner�r�r9rrr�read_nowait�s
�zStreamReader.read_nowaitcCs�|jd}|j}|dkrHt|�||krH||||�}|j|7_n,|rj|j��||d�}d|_n
|j��}|jt|�8_|jt|�7_|j}|r�|d|jkr�|�d�q�|j|jkr�|j	j
r�|j	��|S)Nrr�)rNrOrz�popleftrIrJrKr�rErDr��resume_reading)r r5Zfirst_bufferr�ruZchunk_splitsrrrr��s$



zStreamReader._read_nowait_chunkcCsPg}|jr>|�|�}|�|�|dkr|t|�8}|dkrq>q|rLd�|�SdS)z8 Read not more than n bytes, or whole buffer if n == -1 r�rr&)rNr�rYrzrZ)r r5Zchunks�chunkrrrr��s

zStreamReader._read_nowait)r)r�)r�)(rrrrr�r
r>rrrG�AbstractEventLoopr!�strr\rr]�
BaseExceptionr_rrrkrmr1rorqrtr0r}r�r�r�r�r3r6r;r/r�r�r�r�rrrrrZsB
��	* 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)'�EmptyStreamReaderr"cCsdSrrr#rrrr_�szEmptyStreamReader.exceptionNr`cCsdSrr)r rarrrr�szEmptyStreamReader.set_exceptionrecCs.z
|�Wntk
r(t�d�YnXdSrg)rirr_rjrrrrk�s
zEmptyStreamReader.on_eofcCsdSrrr#rrrrmszEmptyStreamReader.feed_eofcCsdS�NTrr#rrrroszEmptyStreamReader.is_eofcCsdSr�rr#rrrrqszEmptyStreamReader.at_eofc�sdSrrr#rrrrt
szEmptyStreamReader.wait_eofr)rur5rcCsdSrr)r rur5rrrr�
szEmptyStreamReader.feed_datac�sdSr%rr#rrrr3szEmptyStreamReader.readliner�r4c�sdSr%rr9rrrr6szEmptyStreamReader.readc�sdSr%rr#rrrr;szEmptyStreamReader.readanyc�sdS)Nr�rr#rrrr/szEmptyStreamReader.readchunkc�st�d|��dSr%)rGr�r9rrrr�szEmptyStreamReader.readexactlycCsdSr%rr#rrrr�szEmptyStreamReader.read_nowait)r)r�)rrrrr�r_rrrkrmr1rorqrtr0r>r�r3r6r;rr/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)r@rcCs,||_d|_d|_d|_d|_t��|_dS)NFr)rHrPrQrSrIrLrMrN)r r@rrrr!)szDataQueue.__init__r"cCs
t|j�Sr)rzrNr#rrr�__len__1szDataQueue.__len__cCs|jSrrnr#rrrro4szDataQueue.is_eofcCs|jo|jSrrpr#rrrrq7szDataQueue.at_eofcCs|jSrr^r#rrrr_:szDataQueue.exceptionr`cCs.d|_||_|j}|dk	r*d|_t||�dSr�)rPrSrQrrcrrrr=szDataQueue.set_exceptionrr~cCs@|j|7_|j�||f�|j}|dk	r<d|_t|d�dSr)rIrNrYrQr
r�rrrr�FszDataQueue.feed_datacCs(d|_|j}|dk	r$d|_t|d�dSr�)rPrQr
)r rdrrrrmOs
zDataQueue.feed_eofc	�s�|jsX|jsX|jrt�|j��|_z|jIdHWn$tjtjfk
rVd|_�YnX|jr~|j�	�\}}|j
|8_
|S|jdk	r�|j�nt�dSr)
rNrPrQrrrHrsrGZCancelledError�TimeoutErrorr�rIrSr�r rurrrrr6Ws

zDataQueue.readcCs
t|j�Sr)rr6r#rrrr$kszDataQueue.__aiter__)r)rrrrrGr�r!r>r�r1rorqrr�r_rrr�rmr6rr$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)rArBr@rcs"t�j|d�||_|d|_dS)N)r@rC)�superr!rD�_limit)r rArBr@�rXrrr!tszFlowControlDataQueue.__init__rr~cs0t��||�|j|jkr,|jjs,|j��dSr)r�r�rIr�rDr�r�r�r�rrr�|szFlowControlDataQueue.feed_datar"c�s:zt���IdHW�S|j|jkr4|jjr4|j��XdSr)rIr�rDr�r�r�r6r#r�rrr6�szFlowControlDataQueue.read)r)
rrrrr
r>rGr�r!rr�r6�
__classcell__rrr�rros�r)"rGrLrw�typingrrrrrrrZ
base_protocolr
Zhelpersrrr
�logrr�ImportErrorZtyping_extensions�__all__rrirrr+r2rr�rrrrrrr�<module>s0$/I

Zerion Mini Shell 1.0