
    AHj&
                        d dl mZ d dlmZmZ d dlmZmZmZm	Z	 d dl
Zd dlmZ d dlmZ d dlmZ erd dlmZ ej(                  j+                  d	
       G d d             Zy)    )annotations)Futuregather)TYPE_CHECKINGAny	Awaitable	GeneratorN)Self)get_caller_file_and_line)MessagePump)CallbackTypeT)angularc                      e Zd ZdZdd	 	 	 	 	 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        Zy)AwaitCompletezfAn 'optionally-awaitable' object which runs one or more coroutines (or other awaitables) concurrently.N)	pre_awaitc               X    || _         t        | | _        || _        t	               | _        y)ztCreate an AwaitComplete.

        Args:
            awaitables: One or more awaitables to run concurrently.
        N)_awaitablesr   _future
_pre_awaitr   _caller)selfr   
awaitabless      N/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/await_complete.py__init__zAwaitComplete.__init__   s)     &$*J$7/8/1    c              #  l   K   | j                    d| j                  d f d| j                  d f y w)Nr   caller)r   r   r   r   s    r   __rich_repr__zAwaitComplete.__rich_repr__!   s4     4??D00d**s   24c                    || _         y)zSet a callback to run prior to awaiting.

        This is used by Textual, mainly to check for possible deadlocks.
        You are unlikely to need to call this method in an app.

        Args:
            pre_await: A callback.
        N)r   )r   r   s     r   set_pre_await_callbackz$AwaitComplete.set_pre_await_callback&   s     $r   c                (    |j                  |        | S )zjAwait after the next message.

        Args:
            node: The node which created the object.
        )	call_next)r   nodes     r   r#   zAwaitComplete.call_next1   s     	tr   c                "   K   |  d {   S 7 w)N r   s    r   __call__zAwaitComplete.__call__:   s     zzs   c                r    d}| j                   | j                          | j                  j                         S )NT)r   r   	__await__)r   _rich_traceback_omits     r   r)   zAwaitComplete.__await__=   s/    #??&OO||%%''r   c                6    | j                   j                         S )z!`True` if the task has completed.)r   doner   s    r   is_donezAwaitComplete.is_doneC   s     ||  ""r   c                l    | j                   j                         r| j                   j                         S y)z&An exception if the awaitables failed.N)r   r,   	exceptionr   s    r   r/   zAwaitComplete.exceptionH   s*     <<<<))++r   c                h     |        }t               |_        |j                  j                  d       |S )z7Returns an already completed instance of AwaitComplete.N)r   r   
set_result)clsinstances     r   nothingzAwaitComplete.nothingO   s.     5!8##D)r   )r   r   r   CallbackType | NonereturnNone)r6   zrich.repr.Result)r   r5   r6   r7   )r$   r   r6   r
   )r6   r   )r6   zGenerator[Any, None, Any])r6   bool)r6   zBaseException | None)__name__
__module____qualname____doc__r   r   r!   r#   r'   r)   propertyr-   r/   classmethodr4   r&   r   r   r   r      s~    p HL2$21D2	2+
	$( # #    r   r   )
__future__r   asyncior   r   typingr   r   r   r	   	rich.reprrichtyping_extensionsr
   textual._debugr   textual.message_pumpr   textual.typesr   reprautor   r&   r   r   <module>rJ      sN    " " ; ;  " 3 ,* D D Dr   