
    jjv                        d Z ddlmZ ddlZddlZddlZddlZej                  r8ddlZddl	m
Z
 ddlmZmZ ddlmZ ddlmZ  ej$                  d      Z ed	      Zd
Z G d de      Z G d dej0                        Zy)z8Abstract shared code for urwid EventLoop implementation.    )annotationsN)Callable)ExecutorFuture)	FrameType)	ParamSpec_T_Spec)	EventLoopExitMainLoopc                      e Zd ZdZy)r   z_
    When this exception is raised within a main loop the main loop
    will exit cleanly.
    N)__name__
__module____qualname____doc__     g/home/ubuntu/.cache/pipx/cdb5059130eadca/lib/python3.12/site-packages/urwid/event_loop/abstract_loop.pyr   r   -   s    r   r   c                  T   e Zd ZdZdZddZ	 	 	 	 	 	 	 	 	 	 ddZej                  dd       Z	ej                  d        Z
ej                  dd       Zej                  dd       Zej                  dd	       Zej                  dd
       Zej                  dd       Z	 	 	 	 	 	 ddZy)r   zT
    Abstract class representing an event loop to be used by :class:`MainLoop`.
    )loggerc                    t        j                  t              j                  | j                  j                        | _        y )N)logging	getLoggerr   getChild	__class__r   selfs    r   __init__zEventLoop.__init__;   s)    ''1::4>>;R;RSr   c                    t         )a_  Run callable in executor if supported.

        :param executor: Executor to use for running the function
        :type executor: concurrent.futures.Executor
        :param func: function to call
        :type func: Callable
        :param args: arguments to function (positional only)
        :type args: object
        :param kwargs: keyword arguments to function (keyword only)
        :type kwargs: object
        :return: future object for the function call outcome.
                 (exact future type depends on the event loop type)
        :rtype: concurrent.futures.Future | asyncio.Future
        )NotImplementedError)r   executorfuncargskwargss        r   run_in_executorzEventLoop.run_in_executor>   s
    * "!r   c                     y)aW  
        Call callback() a given time from now.  No parameters are
        passed to callback.

        This method has no default implementation.

        Returns a handle that may be passed to remove_alarm()

        seconds -- floating point time to wait before calling callback
        callback -- function to call from event loop
        Nr   )r   secondscallbacks      r   alarmzEventLoop.alarmU       r   c                     y)z
        Add a callback for entering idle.

        This method has no default implementation.

        Returns a handle that may be passed to remove_idle()
        Nr   )r   r(   s     r   
enter_idlezEventLoop.enter_idlec   r*   r   c                     y)z
        Remove an alarm.

        This method has no default implementation.

        Returns True if the alarm exists, False otherwise
        Nr   r   handles     r   remove_alarmzEventLoop.remove_alarmm   r*   r   c                     y)z
        Remove an idle callback.

        This method has no default implementation.

        Returns True if the handle was removed.
        Nr   r.   s     r   remove_enter_idlezEventLoop.remove_enter_idlew   r*   r   c                     y)z
        Remove an input file.

        This method has no default implementation.

        Returns True if the input file exists, False otherwise
        Nr   r.   s     r   remove_watch_filezEventLoop.remove_watch_file   r*   r   c                     y)z
        Start the event loop.  Exit the loop when any callback raises
        an exception.  If ExitMainLoop is raised, exit cleanly.

        This method has no default implementation.
        Nr   r   s    r   runzEventLoop.run   r*   r   c                     y)aV  
        Call callback() when fd has some data to read.  No parameters
        are passed to callback.

        This method has no default implementation.

        Returns a handle that may be passed to remove_watch_file()

        fd -- file descriptor to watch for input
        callback -- function to call when input is available
        Nr   )r   fdr(   s      r   
watch_filezEventLoop.watch_file   r*   r   c                .    t        j                   ||      S )a  
        Sets the signal handler for signal signum.

        The default implementation of :meth:`set_signal_handler`
        is simply a proxy function that calls :func:`signal.signal()`
        and returns the resulting value.

        signum -- signal number
        handler -- function (taking signum as its single argument),
        or `signal.SIG_IGN`, or `signal.SIG_DFL`
        )signal)r   signumhandlers      r   set_signal_handlerzEventLoop.set_signal_handler   s      }}VW--r   N)returnNone)
r!   r   r"   zCallable[_Spec, _T]r#   z
_Spec.argsr$   z_Spec.kwargsr?   zFuture[_T] | asyncio.Future[_T])r'   floatr(   Callable[[], typing.Any]r?   z
typing.Any)r?   bool)r8   intr(   rB   )r<   rD   r=   zECallable[[int, FrameType | None], typing.Any] | int | signal.Handlersr?   zLCallable[[int, FrameType | None], typing.Any] | int | signal.Handlers | None)r   r   r   r   	__slots__r   r%   abcabstractmethodr)   r,   r0   r2   r4   r6   r9   r>   r   r   r   r   r   4   s"    IT"" "" 	"
 " 
)". 	  	  	  	  	  	  	 .. W. 
V	.r   r   )r   
__future__r   rF   r   r;   typingTYPE_CHECKINGasynciocollections.abcr   concurrent.futuresr   r   typesr   typing_extensionsr   TypeVarr	   r
   __all__	Exceptionr   ABCr   r   r   r   <module>rT      sn   , ? " 
   	(3+		BgE
'9 ~. ~.r   