U
    祡cI                  	   @   s$  d dl mZ d dlmZmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ G d	d
 d
e	Zedkr d dlmZ ddlmZ e ZedrZed ed ed ed ed ejddd ed ed ed ejdddd ed W 5 Q R X ed dS )    )TracebackType)OptionalType   )ConsoleRenderableType)JupyterMixin)Live)Spinner)	StyleTypec                   @   s   e Zd ZdZddddddeee eee	e	dd	d
Z
eedddZeddddZd ddddee ee ee ee	 ddddZddddZddddZedddZd dddZeee  ee ee ddddZdS )!Statusa  Displays a status indicator with a 'spinner' animation.

    Args:
        status (RenderableType): A status renderable (str or Text typically).
        console (Console, optional): Console instance to use, or None for global console. Defaults to None.
        spinner (str, optional): Name of spinner animation (see python -m rich.spinner). Defaults to "dots".
        spinner_style (StyleType, optional): Style of spinner. Defaults to "status.spinner".
        speed (float, optional): Speed factor for spinner animation. Defaults to 1.0.
        refresh_per_second (float, optional): Number of refreshes per second. Defaults to 12.5.
    Ndotszstatus.spinnerg      ?g      )@)consolespinnerspinner_stylespeedrefresh_per_second)statusr   r   r   r   r   c                C   s<   || _ || _|| _t||||d| _t| j||dd| _d S )Ntextstyler   T)r   r   Z	transient)r   r   r   r
   _spinnerr	   
renderable_live)selfr   r   r   r   r   r    r   //tmp/pip-unpacked-wheel-qkhzhrww/rich/status.py__init__   s    
zStatus.__init__)returnc                 C   s   | j S N)r   r   r   r   r   r   ,   s    zStatus.renderabler   c                 C   s   | j jS )z+Get the Console used by the Status objects.)r   r   r    r   r   r   r   0   s    zStatus.console)r   r   r   )r   r   r   r   r   c                C   sz   |dk	r|| _ |dk	r|| _|dk	r*|| _|dk	r^t|| j | j| jd| _| jj| jdd n| jj| j | j| jd dS )a  Update status.

        Args:
            status (Optional[RenderableType], optional): New status renderable or None for no change. Defaults to None.
            spinner (Optional[str], optional): New spinner or None for no change. Defaults to None.
            spinner_style (Optional[StyleType], optional): New spinner style or None for no change. Defaults to None.
            speed (Optional[float], optional): Speed factor for spinner animation or None for no change. Defaults to None.
        Nr   T)Zrefresh)r   r   r   r
   r   r   updater   )r   r   r   r   r   r   r   r   r!   5   s&         zStatus.updatec                 C   s   | j   dS )zStart the status animation.N)r   startr    r   r   r   r"   U   s    zStatus.startc                 C   s   | j   dS )zStop the spinner animation.N)r   stopr    r   r   r   r#   Y   s    zStatus.stopc                 C   s   | j S r   )r   r    r   r   r   __rich__]   s    zStatus.__rich__c                 C   s   |    | S r   )r"   r    r   r   r   	__enter__`   s    zStatus.__enter__)exc_typeexc_valexc_tbr   c                 C   s   |    d S r   )r#   )r   r&   r'   r(   r   r   r   __exit__d   s    zStatus.__exit__)N)__name__
__module____qualname____doc__r   r   r   strr   floatr   propertyr
   r   r   r!   r"   r#   r$   r%   r   BaseExceptionr   r)   r   r   r   r   r      sN     
r   __main__)sleep)r   z"[magenta]Covid detector booting up   zImporting advanced AIzAdvanced Covid AI Readyz[bold blue] Scanning for CovidZearth)r   r   z*Found 10,000,000,000 copies of Covid32.exez%[bold red]Moving Covid32.exe to TrashZbouncingBallZyellow)r   r   r      z&[bold green]Covid deleted successfullyN)typesr   typingr   r   r   r   r   Zjupyterr   Zliver	   r   r
   r   r   r   r*   timer3   r   logr!   printr   r   r   r   <module>   s8   b



