<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>

j f]              	   @   s  d  Z  d d d d d d d g Z d d	 l Z e e d
  rR e j d d g  n  d d l m Z d d l m Z d d l m Z d d l m	 Z	 d d l m
 Z
 d d l m Z d d l m Z d$ Z Gd d   d e  Z Gd d   d e  Z e d	 d	 d d	 d e d d  Z e d	 d	 d d	 d e d d  Z e e d
  re d	 d d	 d e d d  Z e d	 d d	 d e d d  Z n  Gd d    d  e
 j  Z Gd! d   d e e
 j  Z Gd" d   d  Z Gd# d   d  Z d	 S)%zStream-related things.StreamReaderStreamWriterStreamReaderProtocolopen_connectionstart_serverIncompleteReadErrorLimitOverrunError    NZAF_UNIXopen_unix_connectionstart_unix_server   )
coroutines)compat)events)futures)	protocols)	coroutine)logger      c                   s(   e  Z d  Z d Z   f d d   Z   S)r   z
    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)
    c                s6   t    j d t |  | f  | |  _ | |  _ d  S)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfr   r   )	__class__ 4/opt/alt/python34/lib64/python3.4/asyncio/streams.pyr   !   s    	zIncompleteReadError.__init__)__name__
__module____qualname____doc__r   r   r   )r   r   r      s   c                   s(   e  Z d  Z d Z   f d d   Z   S)r   zReached buffer limit while looking for the separator.

    Attributes:
    - message: error message
    - consumed: total number of bytes that should be consumed
    c                s&   t    j |  | |  _ | |  _ d  S)N)r   r   messageconsumed)r   r"   r#   )r   r   r   r   /   s    	zLimitOverrunError.__init__)r   r   r    r!   r   r   r   )r   r   r   (   s   looplimitc      	      +   s   | d k r t  j   } n  t d | d |  } t | d |   | j   f d d   |  | |  Dd H\ } } t |   | |  } | | f S)a  A 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.)
    Nr%   r$   c                  s     S)Nr   r   )protocolr   r   <lambda>N   s    z!open_connection.<locals>.<lambda>)r   get_event_loopr   r   Zcreate_connectionr   )	hostportr$   r%   kwdsreader	transport_writerr   )r&   r   r   5   s    )c            +   sN    d k r t  j    n      f d d   }  j | | | |  Dd HS)a  Start 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.
    Nc                 s.   t  d  d   }  t |    d  } | S)Nr%   r$   )r   r   )r,   r&   )client_connected_cbr%   r$   r   r   factoryn   s    	zstart_server.<locals>.factory)r   r(   Zcreate_server)r0   r)   r*   r$   r%   r+   r1   r   )r0   r%   r$   r   r   S   s    c            +   s   | d k r t  j   } n  t d | d |  } t | d |   | j   f d d   |  |  Dd H\ } } t |   | |  } | | f S)z@Similar to `open_connection` but works with UNIX Domain Sockets.Nr%   r$   c                  s     S)Nr   r   )r&   r   r   r'      s    z&open_unix_connection.<locals>.<lambda>)r   r(   r   r   Zcreate_unix_connectionr   )pathr$   r%   r+   r,   r-   r.   r/   r   )r&   r   r	   z   s    &c            +   sK    d k r t  j    n      f d d   }  j | | |  Dd HS)z=Similar to `start_server` but works with UNIX Domain Sockets.Nc                 s.   t  d  d   }  t |    d  } | S)Nr%   r$   )r   r   )r,   r&   )r0   r%   r$   r   r   r1      s    	z"start_unix_server.<locals>.factory)r   r(   Zcreate_unix_server)r0   r2   r$   r%   r+   r1   r   )r0   r%   r$   r   r
      s    c               @   s[   e  Z d  Z d Z d d d  Z d d   Z d d   Z d	 d
   Z e d d    Z	 d S)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.
    Nc             C   sF   | d  k r t  j   |  _ n	 | |  _ d |  _ d  |  _ d |  _ d  S)NF)r   r(   _loop_paused_drain_waiter_connection_lost)r   r$   r   r   r   r      s    			zFlowControlMixin.__init__c             C   s?   |  j  s t  d |  _  |  j j   r; t j d |   n  d  S)NTz%r pauses writing)r5   AssertionErrorr4   	get_debugr   debug)r   r   r   r   pause_writing   s    	zFlowControlMixin.pause_writingc             C   s{   |  j  s t  d |  _  |  j j   r: t j d |   n  |  j } | d  k	 rw d  |  _ | j   sw | j d   qw n  d  S)NFz%r resumes writing)	r5   r8   r4   r9   r   r:   r6   done
set_result)r   waiterr   r   r   resume_writing   s    			zFlowControlMixin.resume_writingc             C   su   d |  _  |  j s d  S|  j } | d  k r/ d  Sd  |  _ | j   rH d  S| d  k rd | j d   n | j |  d  S)NT)r7   r5   r6   r<   r=   set_exception)r   excr>   r   r   r   connection_lost   s    				z FlowControlMixin.connection_lostc             c   sw   |  j  r t d   n  |  j s% d  S|  j } | d  k sL | j   sL t  t j d |  j  } | |  _ | Dd  Hd  S)NzConnection lostr$   )	r7   ConnectionResetErrorr5   r6   	cancelledr8   r   Futurer4   )r   r>   r   r   r   _drain_helper   s    				zFlowControlMixin._drain_helper)
r   r   r    r!   r   r;   r?   rB   r   rF   r   r   r   r   r3      s   	r3   c                   sd   e  Z d  Z d Z d d   f d d  Z d d   Z   f d d   Z d	 d
   Z d d   Z   S)r   a=  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.)
    Nc                s2   t    j d |  | |  _ d  |  _ | |  _ d  S)Nr$   )r   r   _stream_reader_stream_writer_client_connected_cb)r   Zstream_readerr0   r$   )r   r   r   r      s    		zStreamReaderProtocol.__init__c             C   s~   |  j  j |  |  j d  k	 rz t | |  |  j  |  j  |  _ |  j |  j  |  j  } t j |  rz |  j j |  qz n  d  S)N)	rG   set_transportrI   r   r4   rH   r   ZiscoroutineZcreate_task)r   r-   resr   r   r   connection_made   s    	z$StreamReaderProtocol.connection_madec                s@   | d  k r |  j  j   n |  j  j |  t   j |  d  S)N)rG   feed_eofr@   r   rB   )r   rA   )r   r   r   rB      s    z$StreamReaderProtocol.connection_lostc             C   s   |  j  j |  d  S)N)rG   	feed_data)r   datar   r   r   data_received   s    z"StreamReaderProtocol.data_receivedc             C   s   |  j  j   d S)NT)rG   rM   )r   r   r   r   eof_received   s    z!StreamReaderProtocol.eof_received)	r   r   r    r!   r   rL   rB   rP   rQ   r   r   )r   r   r      s   c               @   s   e  Z d  Z d Z d d   Z d d   Z e d d    Z d d	   Z d
 d   Z	 d d   Z
 d d   Z d d   Z d d d  Z e d d    Z d S)r   a'  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.
    c             C   sI   | |  _  | |  _ | d  k s3 t | t  s3 t  | |  _ | |  _ d  S)N)
_transport	_protocol
isinstancer   r8   _readerr4   )r   r-   r&   r,   r$   r   r   r   r     s
    		!	zStreamWriter.__init__c             C   sP   |  j  j d |  j g } |  j d  k	 r? | j d |  j  n  d d j |  S)Nztransport=%rz	reader=%rz<%s> )r   r   rR   rU   appendjoin)r   infor   r   r   __repr__  s    zStreamWriter.__repr__c             C   s   |  j  S)N)rR   )r   r   r   r   r-     s    zStreamWriter.transportc             C   s   |  j  j |  d  S)N)rR   write)r   rO   r   r   r   r[     s    zStreamWriter.writec             C   s   |  j  j |  d  S)N)rR   
writelines)r   rO   r   r   r   r\   "  s    zStreamWriter.writelinesc             C   s   |  j  j   S)N)rR   	write_eof)r   r   r   r   r]   %  s    zStreamWriter.write_eofc             C   s   |  j  j   S)N)rR   can_write_eof)r   r   r   r   r^   (  s    zStreamWriter.can_write_eofc             C   s   |  j  j   S)N)rR   close)r   r   r   r   r_   +  s    zStreamWriter.closeNc             C   s   |  j  j | |  S)N)rR   get_extra_info)r   namedefaultr   r   r   r`   .  s    zStreamWriter.get_extra_infoc             c   su   |  j  d k	 r6 |  j  j   } | d k	 r6 |  q6 n  |  j d k	 r_ |  j j   r_ d Vq_ n  |  j j   Dd Hd S)z~Flush the write buffer.

        The intended use is to write

          w.write(data)
          yield from w.drain()
        N)rU   	exceptionrR   Z
is_closingrS   rF   )r   rA   r   r   r   drain1  s    	zStreamWriter.drain)r   r   r    r!   r   rZ   propertyr-   r[   r\   r]   r^   r_   r`   r   rd   r   r   r   r   r     s   c               @   s  e  Z d  Z e d d d  Z d d   Z d d   Z d d	   Z d
 d   Z d d   Z	 d d   Z
 d d   Z d d   Z d d   Z e d d    Z e d d    Z e d d d   Z e d& d d   Z e d  d!    Z e j re d" d#    Z e d$ d%    Z n  d S)'r   Nc             C   s   | d k r t  d   n  | |  _ | d  k rB t j   |  _ n	 | |  _ t   |  _ d |  _ d  |  _ d  |  _	 d  |  _
 d |  _ d  S)Nr   zLimit cannot be <= 0F)
ValueError_limitr   r(   r4   	bytearray_buffer_eof_waiter
_exceptionrR   r5   )r   r%   r$   r   r   r   r   L  s    						zStreamReader.__init__c             C   s   d g } |  j  r/ | j d t |  j    n  |  j rH | j d  n  |  j t k rn | j d |  j  n  |  j r | j d |  j  n  |  j r | j d |  j  n  |  j r | j d |  j  n  |  j	 r | j d  n  d	 d
 j
 |  S)Nr   z%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rV   )ri   rW   r   rj   rg   _DEFAULT_LIMITrk   rl   rR   r5   rX   )r   rY   r   r   r   rZ   _  s     							zStreamReader.__repr__c             C   s   |  j  S)N)rl   )r   r   r   r   rc   q  s    zStreamReader.exceptionc             C   sJ   | |  _  |  j } | d  k	 rF d  |  _ | j   sF | j |  qF n  d  S)N)rl   rk   rD   r@   )r   rA   r>   r   r   r   r@   t  s    			zStreamReader.set_exceptionc             C   sA   |  j  } | d k	 r= d |  _  | j   s= | j d  q= n  d S)z1Wakeup read*() functions waiting for data or EOF.N)rk   rD   r=   )r   r>   r   r   r   _wakeup_waiter}  s
    		zStreamReader._wakeup_waiterc             C   s(   |  j  d  k s t d   | |  _  d  S)NzTransport already set)rR   r8   )r   r-   r   r   r   rJ     s    zStreamReader.set_transportc             C   s>   |  j  r: t |  j  |  j k r: d |  _  |  j j   n  d  S)NF)r5   r   ri   rg   rR   resume_reading)r   r   r   r   _maybe_resume_transport  s    !	z$StreamReader._maybe_resume_transportc             C   s   d |  _  |  j   d  S)NT)rj   ro   )r   r   r   r   rM     s    	zStreamReader.feed_eofc             C   s   |  j  o |  j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rj   ri   )r   r   r   r   at_eof  s    zStreamReader.at_eofc             C   s   |  j  s t d   | s  d  S|  j j |  |  j   |  j d  k	 r |  j r t |  j  d |  j k r y |  j j	   Wn t
 k
 r d  |  _ Yq Xd |  _ n  d  S)Nzfeed_data after feed_eofr   T)rj   r8   ri   extendro   rR   r5   r   rg   Zpause_readingNotImplementedError)r   rO   r   r   r   rN     s    

zStreamReader.feed_datac             c   s   |  j  d k	 r" t d |   n  |  j s8 t d   |  j rZ d |  _ |  j j   n  t j d |  j	  |  _  z |  j  Dd HWd d |  _  Xd S)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 EOFFr$   )
rk   RuntimeErrorrj   r8   r5   rR   rp   r   rE   r4   )r   Z	func_namer   r   r   _wait_for_data  s    
		zStreamReader._wait_for_datac             c   s   d } t  |  } y |  j |  Dd H} Wn t k
 rX } z | j SWYd d } ~ Xn t k
 r } za |  j j | | j  r |  j d | j |  =n |  j j   |  j	   t
 | j d   WYd d } ~ Xn X| S)a  Read 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.
        s   
Nr   )r   	readuntilr   r   r   ri   
startswithr#   clearrq   rf   args)r   sepseplenlineer   r   r   readline  s    
&zStreamReader.readlines   
c             c   sn  t  |  } | d k r' t d   n  |  j d k	 rB |  j  n  d } x t  |  j  } | | | k r |  j j | |  } | d k r Pn  | d | } | |  j k r t d |   q n  |  j r t |  j  } |  j j	   t
 | d   n  |  j d  Dd HqK W| |  j k r/t d |   n  |  j d | |  } |  j d | |  =|  j   t |  S)	au  Read chunk of data from the stream until `separator` is found.

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

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

        If EOF occurs and complete separator still not found,
        IncompleteReadError(<partial data>, None) will be raised and internal
        buffer becomes empty. This partial data may contain a partial separator.

        If chunk cannot be read due to overlimit, LimitOverrunError will be raised
        and data will be left in internal buffer, so it can be read again, in
        some different way.

        If stream was paused, this function will automatically resume it if
        needed.
        r   z,Separator should be at least one-byte stringNr   z2Separator is not found, and chunk exceed the limitrw   z2Separator is found, but chunk is longer than limit)r   rf   rl   ri   findrg   r   rj   bytesry   r   rv   rq   )r   Z	separatorr|   offsetZbuflenZisepchunkr   r   r   rw     s4    	
zStreamReader.readuntilr   c             c   s   |  j  d k	 r |  j   n  | d k r+ d S| d k  r g  } x2 |  j |  j  Dd H} | sa Pn  | j |  q@ Wd j |  S|  j r |  j r |  j d  Dd Hn  t |  j d |   } |  j d |  =|  j	   | S)a  Read 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 immediatelly.

        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.
        Nr       read)
rl   r   rg   rW   rX   ri   rj   rv   r   rq   )r   nblocksblockrO   r   r   r   r   @  s$    
zStreamReader.readc             c   s   | d k  r t  d   n  |  j d k	 r6 |  j  n  | d k rF d Sg  } xr | d k r |  j |  Dd H} | s d j |  } t | t |  |   n  | j |  | t |  8} qO W| d k s t  d j |  S)a  Read 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.
        r   z*readexactly size can not be less than zeroNr   )rf   rl   r   rX   r   r   rW   r8   )r   r   r   r   r   r   r   r   readexactlyr  s     	zStreamReader.readexactlyc             C   s   |  S)Nr   )r   r   r   r   	__aiter__  s    zStreamReader.__aiter__c             c   s*   |  j    Dd  H} | d k r& t  n  | S)Nr   )r   ZStopAsyncIteration)r   valr   r   r   	__anext__  s    	zStreamReader.__anext__r   )r   r   r    rn   r   rZ   rc   r@   ro   rJ   rq   rM   rr   rN   r   rv   r   rw   r   r   r   ZPY35r   r   r   r   r   r   r   J  s(   	 X1,	i   )r!   __all__Zsockethasattrrs    r   r   r   r   r   r   logr   rn   EOFErrorr   	Exceptionr   r   r   r	   r
   ZProtocolr3   r   r   r   r   r   r   r   <module>   sD   				"B)G