
    <fh                    H   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
mZmZ d dlmZ d dlZd dlZd dlZd dlmZ  G d dej(                  ej*                        Z ee      ej0                  j2                  dd	              Ze G d
 de             ZddZddZy)    )annotationsN)InteractiveConsole)CodeType	FrameTypeFunctionType)Callable)finalc                      e Zd Zy)SuppressDecoratorN)__name__
__module____qualname__     =/var/www/zara/venv/lib/python3.12/site-packages/trio/_repl.pyr   r      s    r   r   c                     dd l } dd l}	 | j                  t        j                  |j
                  d       y # t        $ r}t        d| dd       Y d }~y d }~ww xY w)Nr      
z(
Press enter! Newline injection failed:  T)endflush)fcntltermiosioctlsysstdinTIOCSTIOSErrorprint)r   r   es      r   terminal_newliner       sQ     SCIIw6 S9!=2TRRSs   +6 	AAAc                  l     e Zd Zdd fdZd	dZej                  dk(  r	d
ddZ xZ	S d
ddZddZ xZ	S )TrioInteractiveConsolec                    t         |   |       d | _        | j                  j                  xj
                  t        j                  z  c_        d| _        y )N)localsF)	super__init__tokencompilecompilerflagsastPyCF_ALLOW_TOP_LEVEL_AWAITinterrupted)selfrepl_locals	__class__s     r   r&   zTrioInteractiveConsole.__init__&   sC    ,59
##s'E'EE# r   c                z   t        || j                        }t        j                  |      r/t        j
                  j                  t        j                  |      }n.t        j
                  j                  t        j                  |      }t        |t        j                        rt        |j                  t              r|j                  t        |j                        |j                  ct         _        t         _        |j                  j&                  t         _        t         j*                  dk\  r|j                  t         _        t!        j.                  t         j"                  t         j$                  t         j(                         t        j
                  j                  t        j0                  j2                         y )N)      )r   r$   inspectiscoroutinefunctiontriofrom_threadrunoutcomeacapturerun_synccapture
isinstanceErrorerror
SystemExittyper   	last_type
last_value__traceback__last_tracebackversion_infolast_exc
excepthooklowlevelcheckpoint_if_cancelled)r.   codefuncresults       r   runcodezTrioInteractiveConsole.runcode,   s
   D$++.&&t,%%))'*:*:DAF%%..wEFfgmm, &,,
3ll"
 15V\\0BFLL-s~%+\\%?%?"##w.#)<<CL s}}cnnc>P>PQT]]BBCr   win32c                    	 t        |      S # t        $ r9 t        j                  j	                  t        j
                  j                          w xY wN)inputEOFErrorr6   r7   r8   rI   rJ   )r.   prompts     r   	raw_inputz TrioInteractiveConsole.raw_inputM   sA    V}$   $$T]]%J%JKs
   
 AAc                t    ddl mm   j                  rJ 	 	 d fd}t        j                  j                  |      }	 t        |      t        j                  j                  |        j                  rt        S # t        j                  j                  |        j                  rt        w xY w)Nr   )SIGINTsignalc                 n    	 	 	 	 	 	 dfd} t         j                  j                          |       S )Nc                B    d_         j                  t        d       y )NT)
idempotent)r-   run_sync_soonr    )sigframer.   r'   s     r   handlerzJTrioInteractiveConsole.raw_input.<locals>.install_handler.<locals>.handler_   s!     (,D$''(8T'Jr   )r]   intr^   zFrameType | NonereturnNone)r6   rI   current_trio_token)r_   r'   rW   r.   rX   s    @r   install_handlerz9TrioInteractiveConsole.raw_input.<locals>.install_handler\   sE    KK%5KK 88:fg..r   )ra   z4Callable[[int, FrameType | None], None] | int | None)rX   rW   r-   r6   r7   r;   rR   KeyboardInterrupt)r.   rT   rd   prev_handlerrW   rX   s   `   @@r   rU   z TrioInteractiveConsole.raw_inputW   s    -''''/D/  ++44_EL,V}  ))&&,G##++ $   ))&&,G##++ $s   
B 5B7c                    | j                   r1|dk(  sJ t        j                  j                  |dd         d| _         y t        j                  j                  |       y )Nz
KeyboardInterrupt
   F)r-   r   stderrwrite)r.   outputs     r   rj   zTrioInteractiveConsole.writeq   sL    !8888

  ,#( 

  (r   rQ   )r/   zdict[str, object] | Nonera   rb   )rK   r   ra   rb   )r   )rT   strra   rl   )rk   rl   ra   rb   )
r   r   r   r&   rN   r   platformrU   rj   __classcell__)r0   s   @r   r"   r"   $   s0    !D> ||w	 		,4	)r   r"   c           
     ^  K   dt         j                   dt         j                   dt        t         dd       d}	 t        j
                  j                  | j                  |       d {    t        j                  ddt        	       y 7 !# t        j                  ddt        	       w xY ww)
Nz
trio REPL z on zv
Use "await" directly instead of "trio.run()".
Type "help", "copyright", "credits" or "license" for more information.
ps1z>>> zimport trioignorez ^coroutine .* was never awaited$)messagecategory)r   versionrm   getattrr6   	to_threadr;   interactwarningsfilterwarningsRuntimeWarning)consolebanners     r   run_replr}   z   s     
S[[Mcll^ 4" 3v&
'{		4 
nn%%g&6&6???7#	
 	@7#	
s.   8B--B (B
)B -B-
B B**B-c                    t        j                  t              5  dd l}d d d        dt        i}dD ]
  }| |   ||<    t        |      }t	        j                  t        |       y # 1 sw Y   FxY w)Nr   r6   >   __file__r   __spec__
__loader____package____builtins__)
contextlibsuppressImportErrorreadliner6   r"   r8   r}   )original_localsr   r/   keyr{   s        r   mainr      so    			[	)  '-d^K 0 +3/C0 %[1GHHXw s   A$$A-)ra   rb   )r{   r"   ra   rb   )r   zdict[str, object]ra   rb   )
__future__r   r+   r   r4   r   rx   rK   r   typesr   r   r   typingr   r9   r6   trio.lowlevel
trio._utilr	   ContextDecoratorr   r   re   rI   disable_ki_protectionr    r"   r}   r   r   r   r   <module>r      s    " 
   
  # 3 3     	
33Z5H5H 	 $%$$S % &S R)/ R) R)j
$ r   