
    f                         d Z ddlZddlZddlZddlmZ ddlmZ edk\  rej                  Z
nej                  Z
d
dZddZ G d d	ej                        Zy)zImplementation of coroutines using ``async def``/``await`` keywords.

These keywords replaced ``@asyncio.coroutine`` and ``yield from`` from
Python 3.5 onwards.
    N)version_info)EOF)      c                 r  K   | j                         }||S | j                  j                  sat               j	                  |        t               j                  fd| j                         d {   \  }|f| j                  _        n:| j                  j                  \  }j	                  |        |j                          	 t        j                  j                  |       d {   S 7 ~7 # t        j                  $ r+}|j                          | j                  |      cY d }~S d }~ww xY ww)Nc                       S N )pattern_waiters   Q/var/www/cvtools/html/venv/lib/python3.12/site-packages/pexpect/_async_w_await.py<lambda>zexpect_async.<locals>.<lambda>   s    N     )existing_dataspawnasync_pw_transportPatternWaiterset_expecter_loop_getterconnect_read_piperesume_readingasynciowait_forfutTimeoutErrorpause_readingtimeout)expecterr   idx	transportexcr   s        @r   expect_asyncr!      s     
 
 
"C

>>,,&##H-*6.*J*J"HNN+
 %
!	> -;I,E)$,NN$E$E!	##H-  "%%%n&8&8'BBB%
 C %!$$%sU   A0D73C24AD7
#C6 -C4.C6 1D74C6 6D4	 D/)D4*D7/D44D7c                 P  K   g }| j                   j                  |d          |dd  D ]]  }| j                  |d       d {    |j                  | j                   j                         | j                   j                  |       _ | j                  |d       d {   }|dk(  rO| j                   j                  t        j                         | j                  dd       d {    t        d      dj                  || j                   j                  gz         S 7 7 7 <w)Nr      T)r   async_z1Continuation prompt found - input was incomplete: )
childsendline_expect_promptappendbeforekillsignalSIGINT
ValueErrorjoin)replcmdlinesr   resline
prompt_idxs         r   repl_run_command_asyncr5   -   s    
CJJ$ "!!'$!???

4::$$%

D!" **74*HHJQ

&!!!D!999LMM773$**++,,-- 	@
 I 	:s7   ?D&D AD&D"AD&'D$(9D&"D&$D&c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y)	r   Nc                 D    || _         t        j                         | _        y r	   )r   r   Futurer   )selfr   s     r   r   zPatternWaiter.set_expecterB   s     >>#r   c                     | j                   j                         s6| j                   j                  |       | j                  j	                          y y r	   )r   done
set_resultr   r   )r9   results     r   foundzPatternWaiter.foundF   s6    xx}}HH'NN((* r   c                     | j                   j                         s6| j                   j                  |       | j                  j	                          y y r	   )r   r;   set_exceptionr   r   r9   r    s     r   errorzPatternWaiter.errorK   s6    xx}}HH""3'NN((* r   c                     || _         y r	   )r   )r9   r   s     r   connection_madezPatternWaiter.connection_madeP   s	    "r   c                    | j                   j                  }|j                  j                  |      }|j	                  |d       | j
                  j                         r7|j                  j                  |       |j                  j                  |       y 	 | j                   j                  |      }|| j                  |       y y # t        $ r5}| j                   j                          | j                  |       Y d }~y d }~ww xY w)Nread)r   r   _decoderdecode_logr   r;   _beforewrite_buffernew_datar>   	ExceptionerroredrB   )r9   datar   sindexr    s         r   data_receivedzPatternWaiter.data_receivedS   s    ##NN!!$'

1f88==?MM"MM"	MM**1-E 

5! !  	MM!!#JJsOO	s   .C 	D+C??Dc                     	 d| j                   j                  _        | j                   j                         }| j	                  |       y # t
        $ r}| j                  |       Y d }~y d }~ww xY w)NT)r   r   flag_eofeofr>   r   rB   )r9   rR   r    s      r   eof_receivedzPatternWaiter.eof_receivedf   sX    	+/DMM(MM%%'E JJu  	JJsOO	s   5A	 		A-A((A-c                     t        |t              r.|j                  t        j                  k(  r| j	                          y || j                  |       y y r	   )
isinstanceOSErrorerrnoEIOrW   rB   rA   s     r   connection_lostzPatternWaiter.connection_lostq   s<    c7#		UYY(>_JJsO r   )__name__
__module____qualname__r   r   r>   rB   rD   rS   rW   r]   r
   r   r   r   r   ?   s*    I$+
+
#&	r   r   r	   ))__doc__r   r[   r,   sysr   py_version_infopexpectr   get_running_loopr   get_event_loopr!   r5   Protocolr   r
   r   r   <module>ri      sW   
    / f++L ))L%0.$7G$$ 7r   