
    AHj                        d dl mZ d dlmZ d dlmZ d dlZej                  j                  d       G d d             Z
 G d	 d
e
      Zy)    )annotations)	monotonic)CallableNT)angularc                  H    e Zd ZdZedd	dZd
dZddZddZe	dd       Z
y)ClockzAn object to get relative time.

    The `time` attribute of clock will return the time in seconds since the
    Clock was created or reset.

    get_timec               <    || _         | j                         | _        y)zCreate a clock.

        Args:
            get_time: A callable to get time in seconds.
            start: Start the clock (time is 0 unless clock has been started).
        N	_get_time_start_time)selfr
   s     E/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/clock.py__init__zClock.__init__   s     ">>+    c              #  (   K   | j                    y wN)timer   s    r   __rich_repr__zClock.__rich_repr__   s     iis   c                .    t        | j                        S )z)Clone the Clock with an independent time.r	   )r   r   r   s    r   clonezClock.clone   s    dnn--r   c                .    | j                         | _        y)zReset the clock.Nr   r   s    r   resetzClock.reset#   s    >>+r   c                <    | j                         | j                  z
  S zTime since creation or reset.r   r   s    r   r   z
Clock.time'   s     ~~$"2"222r   N)r
   zCallable[[], float]returnNone)r   zrich.repr.Result)r   r   r   r   r   float)__name__
__module____qualname____doc__r   r   r   r   r   propertyr    r   r   r   r   	   s5     ;D ,., 3 3r   r   c                  P     e Zd ZdZdd fdZd	dZd
dZddZedd       Z	 xZ
S )	MockClockz9A mock clock object where the time may be explicitly set.c                <     | _         t         	   fd       y)zConstruct a mock clock.c                      j                   S r   _timer   s   r   <lambda>z$MockClock.__init__.<locals>.<lambda>3   s    $** r   r	   N)r.   superr   )r   r   	__class__s   ` r   r   zMockClock.__init__0   s    
"45r   c                t    t        | j                        }| j                  |_        | j                  |_        |S )zEClone the mocked clock (clone will return the same time as original).)r*   r.   r   )r   clocks     r   r   zMockClock.clone5   s+    $**%..jjr   c                     y)z@A null-op because it doesn't make sense to reset a mocked clock.Nr(   r   s    r   r   zMockClock.reset<   s    r   c                    || _         y)zRSet the time for the clock.

        Args:
            time: Time to set.
        Nr-   )r   r   s     r   set_timezMockClock.set_time?   s     
r   c                "    | j                         S r   )r   r   s    r   r   zMockClock.timeG   s     ~~r   )g        )r   r"   r   r   )r   r*   r    r!   )r#   r$   r%   r&   r   r   r   r6   r'   r   __classcell__)r1   s   @r   r*   r*   -   s/    C6
O    r   r*   )
__future__r   r   r   typingr   	rich.reprrichreprautor   r*   r(   r   r   <module>r?      sF    "     3  3  3F   r   