B
    od:                 @   s  d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ d dl	m
Z
mZ d dl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mZ d dlmZmZmZ d dlmZ d dlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ej0dkr&d dlm1Z1 nd dl2m1Z1 ddl3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZD ddlEmFZF ddlGmHZHmIZI ddlJmKZKmLZL e(deMZNe.dZOe g ePf ZQe.de+eZRG dd deZSde/e*eO e%eO f eTe)eP eUe)e7 eUe)e g ePf  ePeFeFeFeFePeUeUe%eO d)d*d+ZVG d,d- d-eeZWG d.d/ d/e!eR e$eR ZXd0d!dd"dd#d$d%d&d'd"d1eeMeTeUe)e7 eUe)e g ePf  ePeFeFeFeFeUe!e d2d3d4ZYejZddd0d!dd"dd#d$d%d&d'd"d6e/eTd7e[f e/e1d8 e1d9 f eMe)eT e)eT e)eT e)eM eTeUe)e7 eUe)e g ePf  ePeFeFeFeFeUe!e+ d:d;d<Z\ejZddd0d!dd"dd#d$d%d&d'd"d6e/eTd7e[f e1d= eMe)eT e)eT e)eT e)eM eTeUe)e7 eUe)e g ePf  ePeFeFeFeFeUe!e d:d>d<Z\ddd0d!dd"dd#d$d%d&d'd"d6e/eTd7e[f e/e1d= e1d8 e1d9 f eMe)eT e)eT e)eT e)eM eTeUe)e7 eUe)e g ePf  ePeFeFeFeFeUe/e!e e!e+ f d:d?d<Z\G d@dA dAeZ]G dBdC dCe]Z^G dDdE dEe]Z_G dFdG dGe]Z`G dHdI dIe]ZaG dJdK dKe]ZbG dLdM dMe`ZcG dNdO dOe]ZdG dPdQ dQe]ZeG dRdS dSe]ZfG dTdU dUe]ZgG dVdW dWe]ZhG dXdY dYe]ZiG dZd[ d[e'Zje
G d\d] d]ZkG d^d_ d_e>Zlemd`krd dlnZnd dloZoddalpmqZq ddblrmsZs ddcltmuZu dddlGmIZI eudedfd!dgZteIdhdidjZGeGvdkdldm dneqdodpeGdqdrdsdtduetesdvg	Zwd dwlxmyZy eyewZze7d!dxZ6ele_ fel{ eb fe6d"dyZ|e|j}dzd{d|Z~e|j}d}d{d|Ze|j}d~dd|ZxTe|jse|je~dd e|jedd eod end ddk re|eez qW W dQ R X dS )    N)ABCabstractmethod)deque)	dataclassfield)	timedelta)	RawIOBaseUnsupportedOperation)ceil)mmap)length_hint)PathLikestat)EventRLockThread)TracebackType)AnyBinaryIOCallableContextManagerDequeDictGenericIterableList
NamedTupleNewTypeOptionalSequenceTextIOTupleTypeTypeVarUnion)      )Literal   )filesizeget_console)ConsoleGroupJustifyMethodRenderableType)Highlighter)JupyterMixin)Live)ProgressBar)Spinner)	StyleType)ColumnTable)TextTextTypeTaskIDProgressType_Ic                   sj   e Zd ZdZdded fddZddd	d
Zd dddZee	e
  ee
 ee ddddZ  ZS )_TrackThreadz)A thread to periodically update progress.Progressr9   )progresstask_idupdate_periodc                s.   || _ || _|| _t | _d| _t   d S )Nr   )r>   r?   r@   r   done	completedsuper__init__)selfr>   r?   r@   )	__class__ K/var/www/html/venv/lib/python3.7/site-packages/pip/_vendor/rich/progress.pyrD   B   s    z_TrackThread.__init__N)returnc             C   sh   | j }| jj}| j}d}| jj}x,||sL| j}||kr"||||  |}q"W | jj| j | jdd d S )Nr   T)rB   refresh)r?   r>   advancer@   rA   waitrB   update)rE   r?   rK   r@   last_completedrL   rB   rG   rG   rH   runK   s    
z_TrackThread.runc             C   s   |    | S )N)start)rE   rG   rG   rH   	__enter__Y   s    z_TrackThread.__enter__)exc_typeexc_valexc_tbrI   c             C   s   | j   |   d S )N)rA   setjoin)rE   rR   rS   rT   rG   rG   rH   __exit__]   s    
z_TrackThread.__exit__)__name__
__module____qualname____doc__floatrD   rO   rQ   r   r"   BaseExceptionr   rW   __classcell__rG   rG   )rF   rH   r<   ?   s   	
r<   
Working...TF
   bar.backbar.completebar.finished	bar.pulse皙?)sequencedescriptiontotalauto_refreshconsole	transientget_timerefresh_per_secondstylecomplete_stylefinished_stylepulse_styler@   disable
show_speedrI   c          	   c   s   |rt dgng }|t||	|
|dt|dtddf t||||||pLd|d}| |j| |||dE d	H  W d	Q R X d	S )
a  Track progress by iterating over a sequence.

    Args:
        sequence (Iterable[ProgressType]): A sequence (must support "len") you wish to iterate over.
        description (str, optional): Description of task show next to progress bar. Defaults to "Working".
        total: (float, optional): Total number of steps. Default is len(sequence).
        auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
        transient: (bool, optional): Clear the progress on exit. Defaults to False.
        console (Console, optional): Console to write to. Default creates internal Console instance.
        refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
        style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
        complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
        finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
        update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1.
        disable (bool, optional): Disable display of progress.
        show_speed (bool, optional): Show speed if total isn't known. Defaults to True.
    Returns:
        Iterable[ProgressType]: An iterable of the values in the sequence.

    z([progress.description]{task.description})rn   ro   rp   rq   )rs   T)elapsed_when_finishedr`   )ri   rj   rk   rl   rm   rr   )rh   rg   r@   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnr=   track)rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   r@   rr   rs   columnsr>   rG   rG   rH   rz   g   s(    (
rz   c               @   s  e Zd ZdZd9edeeddddZd dd	d
Ze	e
e  e	e e	e ddddZedddZedddZeedddZedddZedddZeedddZeedddZedddZedddZedd d!Zd:eed#d$d%Zeeee f d&d'd(Z!d;eed#d)d*Z"d<ee#e d+d,d-Z$ddd.d/Z%d=eeed1d2d3Z&edd4d5Z'e(ed6d7d8Z)dS )>_Readerz9A reader that tracks progress while it's being read from.Tr=   N)handler>   taskclose_handlerI   c             C   s"   || _ || _|| _|| _d| _d S )NF)r}   r>   r~   r   _closed)rE   r}   r>   r~   r   rG   rG   rH   rD      s
    z_Reader.__init__)rI   c             C   s   | j   | S )N)r}   rQ   )rE   rG   rG   rH   rQ      s    
z_Reader.__enter__)rR   rS   rT   rI   c             C   s   |    d S )N)close)rE   rR   rS   rT   rG   rG   rH   rW      s    z_Reader.__exit__c             C   s   | S )NrG   )rE   rG   rG   rH   __iter__   s    z_Reader.__iter__c             C   s$   t | j}| jj| jt|d |S )N)rK   )nextr}   r>   rK   r~   len)rE   linerG   rG   rH   __next__   s    
z_Reader.__next__c             C   s   | j S )N)r   )rE   rG   rG   rH   closed   s    z_Reader.closedc             C   s
   | j  S )N)r}   fileno)rE   rG   rG   rH   r      s    z_Reader.filenoc             C   s
   | j  S )N)r}   isatty)rE   rG   rG   rH   r      s    z_Reader.isattyc             C   s   | j jS )N)r}   mode)rE   rG   rG   rH   r      s    z_Reader.modec             C   s   | j jS )N)r}   name)rE   rG   rG   rH   r      s    z_Reader.namec             C   s
   | j  S )N)r}   readable)rE   rG   rG   rH   r      s    z_Reader.readablec             C   s
   | j  S )N)r}   seekable)rE   rG   rG   rH   r      s    z_Reader.seekablec             C   s   dS )NFrG   )rE   rG   rG   rH   writable   s    z_Reader.writable)sizerI   c             C   s&   | j |}| jj| jt|d |S )N)rK   )r}   readr>   rK   r~   r   )rE   r   blockrG   rG   rH   r      s    z_Reader.read)bc             C   s"   | j |}| jj| j|d |S )N)rK   )r}   readintor>   rK   r~   )rE   r   nrG   rG   rH   r      s    z_Reader.readintoc             C   s&   | j |}| jj| jt|d |S )N)rK   )r}   readliner>   rK   r~   r   )rE   r   r   rG   rG   rH   r      s    z_Reader.readline)hintrI   c             C   s,   | j |}| jj| jttt|d |S )N)rK   )r}   	readlinesr>   rK   r~   summapr   )rE   r   linesrG   rG   rH   r      s    z_Reader.readlinesc             C   s   | j r| j  d| _d S )NT)r   r}   r   r   )rE   rG   rG   rH   r      s    
z_Reader.closer   )offsetwhencerI   c             C   s$   | j ||}| jj| j|d |S )N)rB   )r}   seekr>   rM   r~   )rE   r   r   posrG   rG   rH   r     s    z_Reader.seekc             C   s
   | j  S )N)r}   tell)rE   rG   rG   rH   r   
  s    z_Reader.tell)srI   c             C   s   t dd S )Nwrite)r	   )rE   r   rG   rG   rH   r     s    z_Reader.write)T)r   )r   )r   )r   )*rX   rY   rZ   r[   r   r9   boolrD   rQ   r   r"   r]   r   rW   r   bytesr   propertyr   intr   r   strr   r   r   r   r   r   r$   	bytearray
memoryviewr   r   r   r   r   r   r   r   r   r   rG   rG   rG   rH   r|      s:   

r|   c               @   sT   e Zd ZdZdeddddZeddd	Zeee	  ee	 ee
 dd
ddZdS )_ReadContextzEA utility class to handle a context for both a reader and a progress.r=   N)r>   readerrI   c             C   s   || _ || _d S )N)r>   r   )rE   r>   r   rG   rG   rH   rD     s    z_ReadContext.__init__)rI   c             C   s   | j   | j S )N)r>   rP   r   rQ   )rE   rG   rG   rH   rQ     s    
z_ReadContext.__enter__)rR   rS   rT   rI   c             C   s   | j   | j||| d S )N)r>   stopr   rW   )rE   rR   rS   rT   rG   rG   rH   rW     s    
z_ReadContext.__exit__)rX   rY   rZ   r[   r;   rD   rQ   r   r"   r]   r   rW   rG   rG   rG   rH   r     s   
r   z
Reading...)rg   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   )filerh   rg   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rI   c         	   C   sh   |rt dgng }|t||	|
|dt t f t||||||pDd|d}|j| ||d}t||S )a  Read bytes from a file while tracking progress.

    Args:
        file (Union[str, PathLike[str], BinaryIO]): The path to the file to read, or a file-like object in binary mode.
        total (int): Total number of bytes to read.
        description (str, optional): Description of task show next to progress bar. Defaults to "Reading".
        auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
        transient: (bool, optional): Clear the progress on exit. Defaults to False.
        console (Console, optional): Console to write to. Default creates internal Console instance.
        refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
        style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
        complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
        finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
        disable (bool, optional): Disable display of progress.
    Returns:
        ContextManager[BinaryIO]: A context manager yielding a progress reader.

    z([progress.description]{task.description})rn   ro   rp   rq   r`   )ri   rj   rk   rl   rm   rr   )rh   rg   )ru   rv   rw   DownloadColumnry   r=   	wrap_filer   )r   rh   rg   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   r{   r>   r   rG   rG   rH   r   &  s&    %

r   r   )rh   rg   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   zPathLike[str]rtr)r   r   	bufferingencodingerrorsnewlinerh   rg   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rI   c            C   s   d S )NrG   )r   r   r   r   r   r   rh   rg   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rG   rG   rH   openg  s    r   rbc            C   s   d S )NrG   )r   r   r   r   r   r   rh   rg   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rG   rG   rH   r     s    c         
   C   sr   |rt dgng }|t||||dt t f t|||	|
||pDd|d}|j| |||||||d}t||S )a  Read bytes from a file while tracking progress.

    Args:
        path (Union[str, PathLike[str], BinaryIO]): The path to the file to read, or a file-like object in binary mode.
        mode (str): The mode to use to open the file. Only supports "r", "rb" or "rt".
        buffering (int): The buffering strategy to use, see :func:`io.open`.
        encoding (str, optional): The encoding to use when reading in text mode, see :func:`io.open`.
        errors (str, optional): The error handling strategy for decoding errors, see :func:`io.open`.
        newline (str, optional): The strategy for handling newlines in text mode, see :func:`io.open`
        total: (int, optional): Total number of bytes to read. Must be provided if reading from a file handle. Default for a path is os.stat(file).st_size.
        description (str, optional): Description of task show next to progress bar. Defaults to "Reading".
        auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
        transient: (bool, optional): Clear the progress on exit. Defaults to False.
        console (Console, optional): Console to write to. Default creates internal Console instance.
        refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
        style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
        complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
        finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
        disable (bool, optional): Disable display of progress.
        encoding (str, optional): The encoding to use when reading in text mode.

    Returns:
        ContextManager[BinaryIO]: A context manager yielding a progress reader.

    z([progress.description]{task.description})rn   ro   rp   rq   r`   )ri   rj   rk   rl   rm   rr   )r   r   r   r   r   rh   rg   )ru   rv   rw   r   ry   r=   r   r   )r   r   r   r   r   r   rh   rg   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   r{   r>   r   rG   rG   rH   r     s6    1

c               @   sj   e Zd ZU dZdZee ed< dee ddddZ	eddd	Z
d
edddZed
edddZdS )ProgressColumnz3Base class for a widget to use in progress display.Nmax_refresh)table_columnrI   c             C   s   || _ i | _d | _d S )N)_table_column_renderable_cache_update_time)rE   r   rG   rG   rH   rD     s    zProgressColumn.__init__)rI   c             C   s   | j p
t S )z.Get a table column, used to build tasks table.)r   r5   )rE   rG   rG   rH   get_table_column  s    zProgressColumn.get_table_columnTask)r~   rI   c             C   sr   |  }| jdk	rT|jsTy| j|j \}}W n tk
r@   Y nX || j |krT|S | |}||f| j|j< |S )a  Called by the Progress object to return a renderable for the given task.

        Args:
            task (Task): An object containing information regarding the task.

        Returns:
            RenderableType: Anything renderable (including str).
        N)rl   r   rB   r   idKeyErrorrender)rE   r~   current_time	timestamp
renderablerG   rG   rH   __call__  s    	
zProgressColumn.__call__c             C   s   dS )z"Should return a renderable object.NrG   )rE   r~   rG   rG   rH   r     s    zProgressColumn.render)N)rX   rY   rZ   r[   r   r   r\   __annotations__r5   rD   r   r.   r   r   r   rG   rG   rG   rH   r     s   
r   c                   sD   e Zd ZdZdddeee d fddZded	d
dZ  Z	S )RenderableColumnzA column to insert an arbitrary column.

    Args:
        renderable (RenderableType, optional): Any renderable. Defaults to empty string.
     N)r   )r   r   c               s   || _ t j|d d S )N)r   )r   rC   rD   )rE   r   r   )rF   rG   rH   rD      s    zRenderableColumn.__init__r   )r~   rI   c             C   s   | j S )N)r   )rE   r~   rG   rG   rH   r   &  s    zRenderableColumn.render)r   )
rX   rY   rZ   r[   r.   r   r5   rD   r   r^   rG   rG   )rF   rH   r     s    r   c                   sb   e Zd ZdZdeee eeee	 d fdd	Z
deee edd
ddZdedddZ  ZS )SpinnerColumna  A column with a 'spinner' animation.

    Args:
        spinner_name (str, optional): Name of spinner animation. Defaults to "dots".
        style (StyleType, optional): Style of spinner. Defaults to "progress.spinner".
        speed (float, optional): Speed factor of spinner. Defaults to 1.0.
        finished_text (TextType, optional): Text used when task is finished. Defaults to " ".
    dotsprogress.spinner      ? N)spinner_namern   speedfinished_textr   c                s<   t |||d| _t|tr$t|n|| _t j|d d S )N)rn   r   )r   )	r3   spinner
isinstancer   r7   from_markupr   rC   rD   )rE   r   rn   r   r   r   )rF   rG   rH   rD   4  s    zSpinnerColumn.__init__)r   spinner_styler   rI   c             C   s   t |||d| _dS )a-  Set a new spinner.

        Args:
            spinner_name (str): Spinner name, see python -m rich.spinner.
            spinner_style (Optional[StyleType], optional): Spinner style. Defaults to "progress.spinner".
            speed (float, optional): Speed factor of spinner. Defaults to 1.0.
        )rn   r   N)r3   r   )rE   r   r   r   rG   rG   rH   set_spinnerD  s    zSpinnerColumn.set_spinnerr   )r~   rI   c             C   s    |j r| jn| j| }|S )N)finishedr   r   r   rl   )rE   r~   textrG   rG   rH   r   S  s    zSpinnerColumn.render)r   r   r   r   N)r   r   )rX   rY   rZ   r[   r   r   r4   r\   r8   r5   rD   r   r.   r   r^   rG   rG   )rF   rH   r   *  s       $ 
r   c            	       sL   e Zd ZdZdeeeeee	 ee
 dd fddZd	ed
ddZ  ZS )ru   zA column containing text.noneleftTN)text_formatrn   justifymarkuphighlighterr   rI   c                s:   || _ || _|| _|| _|| _t j|p0tddd d S )NT)no_wrap)r   )r   r   rn   r   r   rC   rD   r5   )rE   r   rn   r   r   r   r   )rF   rG   rH   rD   _  s    	zTextColumn.__init__r   )r~   rI   c             C   sR   | j j|d}| jr*tj|| j| jd}nt|| j| jd}| jrN| j| |S )N)r~   )rn   r   )	r   formatr   r7   r   rn   r   r   	highlight)rE   r~   _textr   rG   rG   rH   r   o  s    zTextColumn.render)r   r   TNN)rX   rY   rZ   r[   r   r4   r-   r   r   r/   r5   rD   r7   r   r^   rG   rG   )rF   rH   ru   \  s       ru   c            	       sL   e Zd ZdZdee eeeeee dd fd	d
Zde	dddZ
  ZS )rw   a  Renders a visual progress bar.

    Args:
        bar_width (Optional[int], optional): Width of bar or None for full width. Defaults to 40.
        style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
        complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
        finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
    (   bar.backbar.completebar.finished	bar.pulseN)	bar_widthrn   ro   rp   rq   r   rI   c                s0   || _ || _|| _|| _|| _t j|d d S )N)r   )r   rn   ro   rp   rq   rC   rD   )rE   r   rn   ro   rp   rq   r   )rF   rG   rH   rD     s    	zBarColumn.__init__r   )r~   rI   c             C   s^   t |jdk	rtd|jndtd|j| jdkr2dn
td| j|j | | j| j| j	| j
d	S )z&Gets a progress bar widget for a task.Nr   r(   )	rh   rB   widthpulseanimation_timern   ro   rp   rq   )r2   rh   maxrB   r   startedrl   rn   ro   rp   rq   )rE   r~   rG   rG   rH   r     s    
zBarColumn.render)r   r   r   r   r   N)rX   rY   rZ   r[   r   r   r4   r5   rD   r2   r   r^   rG   rG   )rF   rH   rw   z  s   	     rw   c               @   s    e Zd ZdZdedddZdS )TimeElapsedColumnzRenders time elapsed.r   )r~   rI   c             C   sD   |j r|jn|j}|dkr&tdddS tt|d}tt|ddS )zShow time elapsed.Nz-:--:--zprogress.elapsed)rn   )seconds)r   finished_timeelapsedr7   r   r   r   )rE   r~   r   deltarG   rG   rH   r     s
    zTimeElapsedColumn.renderN)rX   rY   rZ   r[   r7   r   rG   rG   rG   rH   r     s   r   c                   sh   e Zd ZdZdeeeeeee	 ee
 edd		 fd
dZeee edddZdedddZ  ZS )rx   a  Show task progress as a percentage.

    Args:
        text_format (str, optional): Format for percentage display. Defaults to "[progress.percentage]{task.percentage:>3.0f}%".
        text_format_no_percentage (str, optional): Format if percentage is unknown. Defaults to "".
        style (StyleType, optional): Style of output. Defaults to "none".
        justify (JustifyMethod, optional): Text justification. Defaults to "left".
        markup (bool, optional): Enable markup. Defaults to True.
        highlighter (Optional[Highlighter], optional): Highlighter to apply to output. Defaults to None.
        table_column (Optional[Column], optional): Table Column to use. Defaults to None.
        show_speed (bool, optional): Show speed if total is unknown. Defaults to False.
    -[progress.percentage]{task.percentage:>3.0f}%r   r   r   TNF)	r   text_format_no_percentagern   r   r   r   r   rs   rI   c	       	         s(   || _ || _t j||||||d d S )N)r   rn   r   r   r   r   )r   rs   rC   rD   )	rE   r   r   rn   r   r   r   r   rs   )rF   rG   rH   rD     s    zTaskProgressColumn.__init__)r   rI   c             C   sT   |dkrt dddS tt|dddddgd	\}}|| }t |d
| dddS )zRender the speed in iterations per second.

        Args:
            task (Task): A Task object.

        Returns:
            Text: Text object containing the task speed.
        Nr   zprogress.percentage)rn   u   ×10³u   ×10⁶u   ×10⁹u   ×10¹²i  z.1fz it/s)r7   r)   pick_unit_and_suffixr   )clsr   unitsuffix
data_speedrG   rG   rH   render_speed  s    

zTaskProgressColumn.render_speedr   )r~   rI   c             C   s   |j d kr"| jr"| |jp|jS |j d kr2| jn| j}|j|d}| jr`t	j
|| j| jd}nt	|| j| jd}| jr| j| |S )N)r~   )rn   r   )rh   rs   r   finished_speedr   r   r   r   r   r7   r   rn   r   r   r   )rE   r~   r   r   r   rG   rG   rH   r     s    zTaskProgressColumn.render)r   r   r   r   TNNF)rX   rY   rZ   r[   r   r4   r-   r   r   r/   r5   rD   classmethodr\   r7   r   r   r^   rG   rG   )rF   rH   rx     s          rx   c                   sD   e Zd ZdZdZdeeee d fddZde	d	d
dZ
  ZS )ry   a  Renders estimated time remaining.

    Args:
        compact (bool, optional): Render MM:SS when time remaining is less than an hour. Defaults to False.
        elapsed_when_finished (bool, optional): Render time elapsed when the task is finished. Defaults to False.
    g      ?FN)compactrt   r   c                s   || _ || _t j|d d S )N)r   )r   rt   rC   rD   )rE   r   rt   r   )rF   rG   rH   rD     s    zTimeRemainingColumn.__init__r   )r~   rI   c             C   s   | j r|jr|j}d}n
|j}d}|jdkr8td|dS |dkrVt| jrLdnd|dS tt|d\}}t|d\}}| jr|s|d	d
|d	}n|dd
|d	d
|d	}t||dS )zShow time remaining.zprogress.elapsedzprogress.remainingNr   )rn   z--:--z-:--:--<   02d:d)	rt   r   r   time_remainingrh   r7   r   divmodr   )rE   r~   	task_timern   minutesr   hours	formattedrG   rG   rH   r     s    

zTimeRemainingColumn.render)FFN)rX   rY   rZ   r[   r   r   r   r5   rD   r7   r   r^   rG   rG   )rF   rH   ry     s     ry   c               @   s    e Zd ZdZdedddZdS )FileSizeColumnzRenders completed filesize.r   )r~   rI   c             C   s   t t|j}t|ddS )zShow data completed.zprogress.filesize)rn   )r)   decimalr   rB   r7   )rE   r~   	data_sizerG   rG   rH   r   ,  s    zFileSizeColumn.renderN)rX   rY   rZ   r[   r7   r   rG   rG   rG   rH   r  )  s   r  c               @   s    e Zd ZdZdedddZdS )TotalFileSizeColumnzRenders total filesize.r   )r~   rI   c             C   s*   |j dk	rtt|j nd}t|ddS )zShow data completed.Nr   zprogress.filesize.total)rn   )rh   r)   r	  r   r7   )rE   r~   r
  rG   rG   rH   r   5  s    zTotalFileSizeColumn.renderN)rX   rY   rZ   r[   r7   r   rG   rG   rG   rH   r  2  s   r  c                   s>   e Zd ZdZdeee d fddZdedd	d
Z	  Z
S )MofNCompleteColumnaH  Renders completed count/total, e.g. '  10/1000'.

    Best for bounded tasks with int quantities.

    Space pads the completed count so that progress length does not change as task progresses
    past powers of 10.

    Args:
        separator (str, optional): Text to separate completed and total values. Defaults to "/".
    /N)	separatorr   c                s   || _ t j|d d S )N)r   )r  rC   rD   )rE   r  r   )rF   rG   rH   rD   G  s    zMofNCompleteColumn.__init__r   )r~   rI   c             C   sP   t |j}|jdk	rt |jnd}tt|}t|| d| j | ddS )zShow completed/total.N?r  zprogress.download)rn   )r   rB   rh   r   r   r7   r  )rE   r~   rB   rh   total_widthrG   rG   rH   r   K  s    
zMofNCompleteColumn.render)r  N)rX   rY   rZ   r[   r   r   r5   rD   r7   r   r^   rG   rG   )rF   rH   r  ;  s   
r  c                   s@   e Zd ZdZdeee dd fddZdedd	d
Z	  Z
S )r   zRenders file size downloaded and total, e.g. '0.5/2.3 GB'.

    Args:
        binary_units (bool, optional): Use binary units, KiB, MiB etc. Defaults to False.
    FN)binary_unitsr   rI   c                s   || _ t j|d d S )N)r   )r  rC   rD   )rE   r  r   )rF   rG   rH   rD   ]  s    zDownloadColumn.__init__r   )r~   rI   c             C   s   t |j}|jdk	rt |jn|}| jrNt|dddddddd	d
g	d\}}n$t|dddddddddg	d\}}|dkr~dnd}|| }|d| d}|jdk	rt |j}	|	| }
|
d| d}nd}| d| d| }t|dd}|S )z.Calculate common unit for completed and total.Nr   KiBMiBGiBTiBPiBEiBZiBYiBi   kBMBGBTBPBEBZBYBi  r(   r   z,.fr  r  r   zprogress.download)rn   )r   rB   rh   r  r)   r   r7   )rE   r~   rB    unit_and_suffix_calculation_baser   r   	precisioncompleted_ratiocompleted_strrh   total_ratio	total_strdownload_statusdownload_textrG   rG   rH   r   c  s,    



zDownloadColumn.render)FN)rX   rY   rZ   r[   r   r   r5   rD   r7   r   r^   rG   rG   )rF   rH   r   V  s   
r   c               @   s    e Zd ZdZdedddZdS )TransferSpeedColumnz&Renders human readable transfer speed.r   )r~   rI   c             C   s@   |j p
|j}|dkr tdddS tt|}t| dddS )zShow data transfer speed.Nr  zprogress.data.speed)rn   z/s)r   r   r7   r)   r	  r   )rE   r~   r   r   rG   rG   rH   r     s
    zTransferSpeedColumn.renderN)rX   rY   rZ   r[   r7   r   rG   rG   rG   rH   r+    s   r+  c               @   s"   e Zd ZU dZeed< eed< dS )ProgressSamplez$Sample of progress for a given time.r   rB   N)rX   rY   rZ   r[   r\   r   rG   rG   rG   rH   r,    s   
r,  c               @   s  e Zd ZU dZeed< eed< ee ed< eed< e	ed< dZ
ee ed< d	Zeed
< eedZeeef ed< eddddZee ed< eddddZee ed< dZee ed< edd dddZee ed< ededZeed< edddZeedddZeee dddZeee ddd Zeedd!d"Zeedd#d$Z eee dd%d&Z!eee dd'd(Z"ddd)d*Z#dS )+r   zInformation regarding a progress task.

    This object should be considered read-only outside of the :class:`~Progress` class.

    r   rg   rh   rB   	_get_timeNr   Tvisible)default_factoryfieldsF)defaultinitrepr
start_time	stop_timer   c               C   s
   t ddS )Ni  )maxlen)r   rG   rG   rG   rH   <lambda>      zTask.<lambda>)r/  r2  r3  	_progress)r3  r/  _lock)rI   c             C   s   |   S )z(float: Get the current time, in seconds.)r-  )rE   rG   rG   rH   rl     s    zTask.get_timec             C   s
   | j dk	S )z#bool: Check if the task as started.N)r4  )rE   rG   rG   rH   r     s    zTask.startedc             C   s   | j dkrdS | j | j S )zPOptional[float]: Get the number of steps remaining, if a non-None total was set.N)rh   rB   )rE   rG   rG   rH   	remaining  s    
zTask.remainingc             C   s2   | j dkrdS | jdk	r$| j| j  S |  | j  S )z]Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started.N)r4  r5  rl   )rE   rG   rG   rH   r     s
    

zTask.elapsedc             C   s
   | j dk	S )zCheck if the task has finished.N)r   )rE   rG   rG   rH   r     s    zTask.finishedc             C   s.   | j s
dS | j| j  d }tdtd|}|S )zOfloat: Get progress of task as a percentage. If a None total was set, returns 0g        g      Y@)rh   rB   minr   )rE   rB   rG   rG   rH   
percentage  s
    zTask.percentagec          	   C   s|   | j dkrdS | j^ | j}|s$dS |d j|d j }|dkrDdS t|}t| tdd |D }|| }|S Q R X dS )z=Optional[float]: Get the estimated speed in steps per second.Nr   r   c             s   s   | ]}|j V  qd S )N)rB   ).0samplerG   rG   rH   	<genexpr>  s    zTask.speed.<locals>.<genexpr>)r4  r:  r9  r   iterr   r   )rE   r>   
total_timeiter_progresstotal_completedr   rG   rG   rH   r     s    
z
Task.speedc             C   s:   | j r
dS | j}|sdS | j}|dkr*dS t|| }|S )zJOptional[float]: Get estimated time to completion, or ``None`` if no data.g        N)r   r   r;  r
   )rE   r   r;  estimaterG   rG   rH   r    s    zTask.time_remainingc             C   s   | j   d| _d| _dS )zReset progress.N)r9  clearr   r   )rE   rG   rG   rH   _reset  s    
zTask._reset)$rX   rY   rZ   r[   r9   r   r   r   r\   GetTimeCallabler   r.  r   r   dictr0  r   r   r4  r5  r   r9  r   r,  r   r:  rl   r   r   r;  r   r   r=  r   r  rG  rG   rG   rG   rH   r     s>   
r   c               @   s  e Zd ZdZddddddddddd
eeef ee e	e
e
e	e	e	ee e	e	ddd	d
Zeeedf dddZeedddZeee dddZeee dddZee	dddZddddZddddZd dddZeee  ee ee ddddZdXeee  e!e  f ee
 ee ee
ee  d"d#d$Z"dYdd%d&e#ee$ ee ee#d'd(d)Z%e&j'dZddd%d+eed,e(f e)d- e$ee ee ee ee$ ee ee#d.
d/d0Z*e&j'd[ddd%d+eed,e(f ee)d1 e)d2 f e$ee ee ee ee$ ee ee+d.
d3d0Z*d\ddd%d+eed,e(f ee)d- e)d2 e)d1 f e$ee ee ee ee$ ee eee#e+f d.
d4d0Z*edd5d6d7Z,edd5d8d9Z-ddddddd:eee
 ee
 ee
 ee ee	 e	e.dd;	d<d=Z/ddd>ddd?ee	ee
 e$ee	 ee e.dd@dAdBZ0d]ee
ddDdEdFZ1dddGdHZ2e3ddIdJZ4ee3 ddKdLZ5ee e6dMdNdOZ7e3ddPdQZ8d^ee	ee
 e$e	e.edSdTdUZ9edd5dVdWZ:dS )_r=   a  Renders an auto-updating progress bar(s).

    Args:
        console (Console, optional): Optional Console instance. Default will an internal Console instance writing to stdout.
        auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()`.
        refresh_per_second (Optional[float], optional): Number of times per second to refresh the progress information or None to use default (10). Defaults to None.
        speed_estimate_period: (float, optional): Period (in seconds) used to calculate the speed estimate. Defaults to 30.
        transient: (bool, optional): Clear the progress on exit. Defaults to False.
        redirect_stdout: (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True.
        redirect_stderr: (bool, optional): Enable redirection of stderr. Defaults to True.
        get_time: (Callable, optional): A callable that gets the current time, or None to use Console.get_time. Defaults to None.
        disable (bool, optional): Disable progress display. Defaults to False
        expand (bool, optional): Expand tasks table to fit width. Defaults to False.
    NTr`   g      >@F)
rj   ri   rm   speed_estimate_periodrk   redirect_stdoutredirect_stderrrl   rr   expand)r{   rj   ri   rm   rJ  rk   rK  rL  rl   rr   rM  rI   c   
      	   G   s   |dkst dt | _|p"|  | _|| _|	| _|
| _i | _t	d| _
t|pRt |||||| jd| _|pr| jj| _| jj| _| jj| _d S )Nr   zrefresh_per_second must be > 0)rj   ri   rm   rk   rK  rL  get_renderable)AssertionErrorr   r:  get_default_columnsr{   rJ  rr   rM  _tasksr9   _task_indexr1   r*   rN  liverj   rl   printlog)rE   rj   ri   rm   rJ  rk   rK  rL  rl   rr   rM  r{   rG   rG   rH   rD   *  s&    

zProgress.__init__.)rI   c             C   s   t dt t t fS )a  Get the default columns used for a new Progress instance:
           - a text column for the description (TextColumn)
           - the bar itself (BarColumn)
           - a text column showing completion percentage (TextColumn)
           - an estimated-time-remaining column (TimeRemainingColumn)
        If the Progress instance is created without passing a columns argument,
        the default columns defined here will be used.

        You can also create a Progress instance using custom columns before
        and/or after the defaults, as in this example:

            progress = Progress(
                SpinnerColumn(),
                *Progress.default_columns(),
                "Elapsed:",
                TimeElapsedColumn(),
            )

        This code shows the creation of a Progress display, containing
        a spinner to the left, the default columns, and a labeled elapsed
        time column.
        z([progress.description]{task.description})ru   rw   rx   ry   )r   rG   rG   rH   rP  N  s    zProgress.get_default_columnsc             C   s   | j jS )N)rS  rj   )rE   rG   rG   rH   rj   m  s    zProgress.consolec          	   C   s    | j  t| j S Q R X dS )zGet a list of Task instances.N)r:  listrQ  values)rE   rG   rG   rH   tasksq  s    zProgress.tasksc          	   C   s    | j  t| j S Q R X dS )zA list of task IDs.N)r:  rV  rQ  keys)rE   rG   rG   rH   task_idsw  s    zProgress.task_idsc          	   C   s4   | j $ | jsdS tdd | j D S Q R X dS )z'Check if all tasks have been completed.Tc             s   s   | ]}|j V  qd S )N)r   )r>  r~   rG   rG   rH   r@    s    z$Progress.finished.<locals>.<genexpr>N)r:  rQ  allrW  )rE   rG   rG   rH   r   }  s    zProgress.finishedc             C   s   | j s| jjdd dS )zStart the progress display.T)rJ   N)rr   rS  rP   )rE   rG   rG   rH   rP     s    zProgress.startc             C   s    | j   | jjs| j  dS )zStop the progress display.N)rS  r   rj   is_interactiverT  )rE   rG   rG   rH   r     s    
zProgress.stopc             C   s   |    | S )N)rP   )rE   rG   rG   rH   rQ     s    zProgress.__enter__)rR   rS   rT   rI   c             C   s   |    d S )N)r   )rE   rR   rS   rT   rG   rG   rH   rW     s    zProgress.__exit__
Working...皙?)rf   rh   r?   rg   r@   rI   c       
   	   c   s   |dkrt t|pd}|dkr0| j||d}n| j||d | jjrt| ||(}x |D ]}|V  | jd7  _qZW W dQ R X n0| j}| j	}	x"|D ]}|V  ||d |	  qW dS )a  Track progress by iterating over a sequence.

        Args:
            sequence (Sequence[ProgressType]): A sequence of values you want to iterate over and track progress.
            total: (float, optional): Total number of steps. Default is len(sequence).
            task_id: (TaskID): Task to track. Default is new task.
            description: (str, optional): Description of task, if new task is created.
            update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1.

        Returns:
            Iterable[ProgressType]: An iterable of values taken from the provided sequence.
        N)rh   r(   )
r\   r   add_taskrM   rS  ri   r<   rB   rK   rJ   )
rE   rf   rh   r?   rg   r@   track_threadvaluerK   rJ   rG   rG   rH   rz     s     


zProgress.trackz
Reading...)r?   rg   )r   rh   r?   rg   rI   c         	   C   s~   d}|dk	r|}n&|dk	r8| j  | j| j}W dQ R X |dkrHtd|dkr`| j||d}n| j||d t|| |ddS )aj  Track progress file reading from a binary file.

        Args:
            file (BinaryIO): A file-like object opened in binary mode.
            total (int, optional): Total number of bytes to read. This must be provided unless a task with a total is also given.
            task_id (TaskID): Task to track. Default is new task.
            description (str, optional): Description of task, if new task is created.

        Returns:
            BinaryIO: A readable file-like object in binary mode.

        Raises:
            ValueError: When no total value can be extracted from the arguments or the task.
        Nz?unable to get the total number of bytes, please specify 'total')rh   F)r   )r:  rQ  rh   
ValueErrorr_  rM   r|   )rE   r   rh   r?   rg   total_bytesrG   rG   rH   r     s    zProgress.wrap_filer   )rh   r?   rg   zPathLike[str]r   )
r   r   r   r   r   r   rh   r?   rg   rI   c      
      C   s   d S )NrG   )
rE   r   r   r   r   r   r   rh   r?   rg   rG   rG   rH   r     s    zProgress.openr   r   c      
      C   s   d S )NrG   )
rE   r   r   r   r   r   r   rh   r?   rg   rG   rG   rH   r     s    c            C   s   d t|dd}
|
dkr(td||dk}|
dkrR|dkrRtdt d	}n&|
d
krx|dkrltdn|dkrxd	}|dkrt|j}|dkr| j	|	|d}n| j
||d tj|d|d}t|| |dd}|dkrtj|||||dS |S )a#  Track progress while reading from a binary file.

        Args:
            path (Union[str, PathLike[str]]): The path to the file to read.
            mode (str): The mode to use to open the file. Only supports "r", "rb" or "rt".
            buffering (int): The buffering strategy to use, see :func:`io.open`.
            encoding (str, optional): The encoding to use when reading in text mode, see :func:`io.open`.
            errors (str, optional): The error handling strategy for decoding errors, see :func:`io.open`.
            newline (str, optional): The strategy for handling newlines in text mode, see :func:`io.open`.
            total (int, optional): Total number of bytes to read. If none given, os.stat(path).st_size is used.
            task_id (TaskID): Task to track. Default is new task.
            description (str, optional): Description of task, if new task is created.

        Returns:
            BinaryIO: A readable file-like object in binary mode.

        Raises:
            ValueError: When an invalid mode is given.
        r   F)reverse)brr   r   zinvalid mode {!r}r(   re  zaline buffering (buffering=1) isn't supported in binary mode, the default buffer size will be usedr   )r   r   r   zcan't have unbuffered text I/ON)rh   r   )r   T)r   )r   r   )r   r   r   line_buffering)rV   sortedrb  r   warningswarnRuntimeWarningr   st_sizer_  rM   ior   r|   TextIOWrapper)rE   r   r   r   r   r   r   rh   r?   rg   _moderf  r}   r   rG   rG   rH   r     s:    !

)r?   rI   c          	   C   s4   | j $ | j| }|jdkr&|  |_W dQ R X dS )zStart a task.

        Starts a task (used when calculating elapsed time). You may need to call this manually,
        if you called ``add_task`` with ``start=False``.

        Args:
            task_id (TaskID): ID of task.
        N)r:  rQ  r4  rl   )rE   r?   r~   rG   rG   rH   
start_task\  s    	

zProgress.start_taskc          	   C   s>   | j . | j| }|  }|jdkr*||_||_W dQ R X dS )zStop a task.

        This will freeze the elapsed time on the task.

        Args:
            task_id (TaskID): ID of task.
        N)r:  rQ  rl   r4  r5  )rE   r?   r~   r   rG   rG   rH   	stop_taskj  s    

zProgress.stop_task)rh   rB   rK   rg   r.  rJ   )	r?   rh   rB   rK   rg   r.  rJ   r0  rI   c         	   K   s.  | j  | j| }	|	j}
|dk	r:||	jkr:||	_|	  |dk	rP|	 j|7  _|dk	r^||	_|dk	rl||	_|dk	rz||	_|	j| |	j|
 }| 	 }|| j
 }|	j}|j}x|r|d j|k r|  qW |dkr|t|| |	jdk	r|	j|	jkr|	jdkr|	j|	_W dQ R X |r*|   dS )a  Update information associated with a task.

        Args:
            task_id (TaskID): Task id (returned by add_task).
            total (float, optional): Updates task.total if not None.
            completed (float, optional): Updates task.completed if not None.
            advance (float, optional): Add a value to task.completed if not None.
            description (str, optional): Change task description if not None.
            visible (bool, optional): Set visible flag if not None.
            refresh (bool): Force a refresh of progress information. Default is False.
            **fields (Any): Additional data fields required for rendering.
        Nr   )r:  rQ  rB   rh   rG  rg   r.  r0  rM   rl   rJ  r9  popleftr   appendr,  r   r   rJ   )rE   r?   rh   rB   rK   rg   r.  rJ   r0  r~   completed_startupdate_completedr   old_sample_timer9  rq  rG   rG   rH   rM   y  s<    




zProgress.updater   )rP   rh   rB   r.  rg   )r?   rP   rh   rB   r.  rg   r0  rI   c      
   	   K   s   |   }| jf | j| }	|	  |r*|nd|	_|dk	r>||	_||	_|dk	rR||	_|r\||	_|dk	rj||	_	d|	_
W dQ R X |   dS )a  Reset a task so completed is 0 and the clock is reset.

        Args:
            task_id (TaskID): ID of task.
            start (bool, optional): Start the task after reset. Defaults to True.
            total (float, optional): New total steps in task, or None to use current total. Defaults to None.
            completed (int, optional): Number of steps completed. Defaults to 0.
            visible (bool, optional): Enable display of the task. Defaults to True.
            description (str, optional): Change task description if not None. Defaults to None.
            **fields (str): Additional data fields required for rendering.
        N)rl   r:  rQ  rG  r4  rh   rB   r.  r0  rg   r   rJ   )
rE   r?   rP   rh   rB   r.  rg   r0  r   r~   rG   rG   rH   reset  s     
zProgress.resetr(   )r?   rK   rI   c       
   	   C   s   |   }| j | j| }|j}| j|7  _|j| }|| j }|j}|j}	x|rj|d j|k rj|	  qPW xt|dkr|	  qnW |	t
|| |jdk	r|j|jkr|jdkr|j|_|j|_W dQ R X dS )zAdvance task by a number of steps.

        Args:
            task_id (TaskID): ID of task.
            advance (float): Number of steps to advance. Default is 1.
        r   i  N)rl   r:  rQ  rB   rJ  r9  rq  r   r   rr  r,  rh   r   r   r   r   )
rE   r?   rK   r   r~   rs  rt  ru  r9  rq  rG   rG   rH   rK     s&    






zProgress.advancec             C   s   | j s| jjr| j  dS )z*Refresh (render) the progress information.N)rr   rS  
is_startedrJ   )rE   rG   rG   rH   rJ     s    zProgress.refreshc             C   s   t |   }|S )z*Get a renderable for the progress display.)r,   get_renderables)rE   r   rG   rG   rH   rN     s    zProgress.get_renderablec             c   s   |  | j}|V  dS )z5Get a number of renderables for the progress display.N)make_tasks_tablerX  )rE   tablerG   rG   rH   rx    s    zProgress.get_renderables)rX  rI   c                sV   dd | j D }tj|d| jd}x,|D ]$  jr*|j fdd| j D   q*W |S )zGet a table to render the Progress display.

        Args:
            tasks (Iterable[Task]): An iterable of Task instances, one per row of the table.

        Returns:
            Table: A table instance.
        c             s   s.   | ]&}t |trtd dn
|  V  qdS )T)r   N)r   r   r5   r   copy)r>  _columnrG   rG   rH   r@    s   z,Progress.make_tasks_table.<locals>.<genexpr>)r   r(   )paddingrM  c             3   s,   | ]$}t |tr|j d n| V  qdS ))r~   N)r   r   r   )r>  column)r~   rG   rH   r@  !  s   )r{   r6   gridrM  r.  add_row)rE   rX  table_columnsrz  rG   )r~   rH   ry  
  s    



zProgress.make_tasks_tablec          	   C   s   | j 
 |  S Q R X dS )z+Makes the Progress class itself renderable.N)r:  rN  )rE   rG   rG   rH   __rich__+  s    zProgress.__rich__      Y@)rg   rP   rh   rB   r.  r0  rI   c       	      K   sr   | j Z t| j|||||| j| j d}|| j| j< |rB| | j | j}tt| jd | _W dQ R X |   |S )a  Add a new 'task' to the Progress display.

        Args:
            description (str): A description of the task.
            start (bool, optional): Start the task immediately (to calculate elapsed time). If set to False,
                you will need to call `start` manually. Defaults to True.
            total (float, optional): Number of total steps in the progress if known.
                Set to None to render a pulsing animation. Defaults to 100.
            completed (int, optional): Number of steps completed so far. Defaults to 0.
            visible (bool, optional): Enable display of the task. Defaults to True.
            **fields (str): Additional data fields required for rendering.

        Returns:
            TaskID: An ID you can use when calling `update`.
        )r.  r0  r-  r:  r(   N)	r:  r   rR  rl   rQ  ro  r9   r   rJ   )	rE   rg   rP   rh   rB   r.  r0  r~   new_task_indexrG   rG   rH   r_  0  s"    
zProgress.add_taskc          	   C   s   | j  | j|= W dQ R X dS )z]Delete a task if it exists.

        Args:
            task_id (TaskID): A task ID.

        N)r:  rQ  )rE   r?   rG   rG   rH   remove_task[  s    zProgress.remove_task)NNr]  r^  )N)r   NNN)r   NNN)r   r   NNN)r(   )Tr  r   T);rX   rY   rZ   r[   r$   r   r   r   r+   r   r\   rH  rD   r   r!   rP  r   rj   r   r   rX  r9   rZ  r   rP   r   rQ   r"   r]   r   rW   r   r:   r   rz   r   r   r   typingoverloadr   r'   r   r    ro  rp  r   rM   rv  rK   rJ   r.   rN  rx  r6   ry  r  r_  r  rG   rG   rG   rH   r=     s   ,
   $%#   :   F    LA(6!   #r=   __main__)Panel)Rule)Syntax)r6   a~  def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
    """Iterate and generate a tuple with a flag for last value."""
    iter_values = iter(values)
    try:
        previous_value = next(iter_values)
    except StopIteration:
        return
    for value in iter_values:
        yield False, previous_value
        previous_value = value
    yield True, previous_valuepython)line_numbersZfoobarZbaz123z:Text may be printed while the progress bars are rendering.z(In fact, [i]any[/i] renderable will workzSuch as [magenta]tables[/]...zPretty printed structures...ZexamplezPretty printed)typer   z	Syntax...zGive it a try!)cycle)record)rj   rk   z[red]Downloadingi  )rh   z[green]Processingz[yellow]Thinkingg      ?)rK   g333333?g{Gz?d   )r_   NTNFNr`   ra   rb   rc   rd   re   FT)r   NNN)r   NNN)r   r   NNN)rl  sysr  rh  abcr   r   collectionsr   dataclassesr   r   datetimer   r   r	   mathr
   r   operatorr   osr   r   	threadingr   r   r   typesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   version_infor'   pip._vendor.typing_extensionsr   r)   r*   rj   r+   r,   r-   r.   r   r/   jupyterr0   rS  r1   progress_barr2   r   r3   rn   r4   rz  r5   r6   r   r7   r8   r   r9   r:   r\   rH  r;   r<   r   r   rz   r|   r   r   r  r   r   r   r   r   ru   rw   r   rx   ry   r  r  r  r   r+  r,  r   r=   rX   randomtimepanelr  ruler  syntaxr  r  Zprogress_renderables	itertoolsr  ZexamplesrP  r>   r_  Ztask1Ztask2Ztask3r   rM   sleeprandintrU  r   rG   rG   rG   rH   <module>   sb  P
*             D6d02   d   X    jB*2*I0		1	~    P





