
    !2i                       d dl m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/m0Z0m1Z1 erd dl2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZG ddlHmIZImJZJ ddlKmLZLmMZM  e+deN          ZO e0d          ZPe"g eQf         ZR ej0        de-e!          ZS G d de          ZT	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dddCZU G dD dEee!          ZV G dF dGe#eS         e&eS                   ZWdHd!dd"dd#d$d%d&d'd"dIddMZXejY        	 	 	 	 dddHd!dd"dd#d$d%d&d'd"dOddZ            ZZejY        	 	 	 	 dddHd!dd"dd#d$d%d&d'd"dOdd\            ZZ	 	 	 	 	 dddHd!dd"dd#d$d%d&d'd"dOdd`ZZ G da dbe          Z[ G dc dde[          Z\ G de dfe[          Z] G dg dhe[          Z^ G di dje[          Z_ G dk dle[          Z` G dm dne^          Za G do dpe[          Zb G dq dre[          Zc G ds dte[          Zd G du dve[          Ze G dw dxe[          Zf G dy dze[          Zg G d{ d|e*          Zhe G d} d~                      Zi G d de?          Zjekdk    rd dllZld dlmZmddlnmoZo ddlpmqZq ddlrmsZs ddlHmJZJ  esddd!          Zr eJddd          ZHeHt                    ddd           d eod          deHddddder eqd          g	Zud dlvmwZw  eweu          Zx e8d!          Z7 ej e]            gejy                                 e`            R e7d"d5 Zzez{                    dd          Z|ez{                    dd          Z}ez{                    dd          Z~ezj        sxez                    e|d           ez                    e}d            emj        d            elj        d d          dk     rez                     eex                     ezj        xddd           dS # 1 swxY w Y   dS dS )    )annotationsN)ABCabstractmethoddeque)	dataclassfield)	timedelta)	RawIOBaseUnsupportedOperation)ceil)mmap)length_hint)PathLikestat)EventRLockThread)TracebackType)TYPE_CHECKINGAnyBinaryIOCallableContextManagerDequeDictGenericIterableListLiteral
NamedTupleNewTypeOptionalTextIOTupleTypeTypeVarUnion)Self   )filesizeget_console)ConsoleGroupJustifyMethodRenderableType)Highlighter)JupyterMixin)Live)ProgressBar)Spinner)	StyleType)ColumnTable)TextTextTypeTaskIDProgressType_Ic                  <     e Zd ZdZd fdZddZddZddZ xZS )_TrackThreadz)A thread to periodically update progress.progress
'Progress'task_id'TaskID'update_periodfloatc                    || _         || _        || _        t                      | _        d| _        t                                          d           d S )Nr   T)daemon)r@   rB   rD   r   done	completedsuper__init__)selfr@   rB   rD   	__class__s       X/var/www/html/pixcura-vrs/venv/lib/python3.11/site-packages/pip/_vendor/rich/progress.pyrK   z_TrackThread.__init__C   sL     *GG	%%%%%    returnNonec                P   | j         }| j        j        }| j        }d}| j        j        } ||          sK| j        j        j        r:| j        }||k    r ||||z
             |} ||          s| j        j        j        :| j        	                    | j         | j        d           d S )Nr   T)rI   refresh)
rB   r@   advancerD   rH   waitlive
is_startedrI   update)rL   rB   rT   rD   last_completedrU   rI   s          rN   runz_TrackThread.runL   s    ,-'*y~$}%% 	+$-*<*G 	+I**^!;<<<!*	 $}%% 	+$-*<*G 	+ 	T\T^TRRRRRrO   '_TrackThread'c                .    |                                   | S NstartrL   s    rN   	__enter__z_TrackThread.__enter__Z       

rO   exc_typeOptional[Type[BaseException]]exc_valOptional[BaseException]exc_tbOptional[TracebackType]c                `    | j                                          |                                  d S r]   )rH   setjoinrL   rc   re   rg   s       rN   __exit__z_TrackThread.__exit__^   s$     				rO   )r@   rA   rB   rC   rD   rE   rP   rQ   )rP   r[   rc   rd   re   rf   rg   rh   rP   rQ   )	__name__
__module____qualname____doc__rK   rZ   ra   rm   __classcell__rM   s   @rN   r?   r?   @   s        33& & & & & &S S S S          rO   r?   
Working...TF
   bar.backbar.completebar.finished	bar.pulse皙?sequenceIterable[ProgressType]descriptionstrtotalOptional[float]rI   intauto_refreshboolconsoleOptional[Console]	transientget_timeOptional[Callable[[], float]]refresh_per_secondrE   styler6   complete_stylefinished_stylepulse_stylerD   disable
show_speedrP   c           
   #  X  K   |rt          d          gng }|                    t          |	|
||          t          |          t	          d          f           t          ||||||pd|d}|5  |                    | ||||          E d	{V  d	d	d	           d	S # 1 swxY w Y   d	S )
a  Track progress by iterating over a sequence.

    You can also track progress of an iterable, which might require that you additionally specify ``total``.

    Args:
        sequence (Iterable[ProgressType]): Values you wish to iterate over and track progress.
        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).
        completed (int, optional): Number of steps completed so far. Defaults to 0.
        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.

    ([progress.description]{task.description}r   r   r   r   )r   T)elapsed_when_finishedrw   r   r   r   r   r   r   )r   rI   r   rD   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnProgresstrack)r}   r   r   rI   r   r   r   r   r   r   r   r   r   rD   r   r   columnsr@   s                     rN   r   r   h   sg     X EPW>	?	?@@UW  NN--'	   *555d;;;		
   	!-3  H 
 
 
>>#' " 
 
 	
 	
 	
 	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   1!BB#&B#c                      e Zd ZdZ	 d;d<dZd=dZd>dZd?dZd@dZe	dAd            Z
dBdZdAdZe	dCd            Ze	dCd             ZdAd!ZdAd"ZdAd#ZdDdEd&ZdFd)ZdDdEd*ZdDdGd-ZdHd.ZdIdJd2ZdBd3ZdKd6ZdLd9Zd:S )M_Readerz9A reader that tracks progress while it's being read from.Thandler   r@   rA   taskr;   close_handler   rP   rQ   c                L    || _         || _        || _        || _        d| _        d S NF)r   r@   r   r   _closed)rL   r   r@   r   r   s        rN   rK   z_Reader.__init__   s,      	(rO   	'_Reader'c                8    | j                                          | S r]   )r   ra   r`   s    rN   ra   z_Reader.__enter__   s    rO   rc   rd   re   rf   rg   rh   c                .    |                                   d S r]   )closerl   s       rN   rm   z_Reader.__exit__   s     	

rO   c                    | S r]    r`   s    rN   __iter__z_Reader.__iter__   s    rO   bytesc                    t          | j                  }| j                            | j        t          |                     |S NrT   )nextr   r@   rT   r   len)rL   lines     rN   __next__z_Reader.__next__   s9    DK  diT;;;rO   c                    | j         S r]   )r   r`   s    rN   closedz_Reader.closed   s
    |rO   r   c                4    | j                                         S r]   )r   filenor`   s    rN   r   z_Reader.fileno       {!!###rO   c                4    | j                                         S r]   )r   isattyr`   s    rN   r   z_Reader.isatty   r   rO   r   c                    | j         j        S r]   )r   moder`   s    rN   r   z_Reader.mode       {rO   c                    | j         j        S r]   )r   namer`   s    rN   r   z_Reader.name   r   rO   c                4    | j                                         S r]   )r   readabler`   s    rN   r   z_Reader.readable       {##%%%rO   c                4    | j                                         S r]   )r   seekabler`   s    rN   r   z_Reader.seekable   r   rO   c                    dS r   r   r`   s    rN   writablez_Reader.writable   s    urO   sizec                    | j                             |          }| j                            | j        t          |                     |S r   )r   readr@   rT   r   r   )rL   r   blocks      rN   r   z_Reader.read   s?      &&diU<<<rO   b"Union[bytearray, memoryview, mmap]c                |    | j                             |          }| j                            | j        |           |S r   )r   readintor@   rT   r   )rL   r   ns      rN   r   z_Reader.readinto   s9    K  ##di333rO   c                    | j                             |          }| j                            | j        t          |                     |S r   )r   readliner@   rT   r   r   )rL   r   r   s      rN   r   z_Reader.readline   s?    {##D))diT;;;rO   hintList[bytes]c           	         | j                             |          }| j                            | j        t          t          t          |                               |S r   )r   	readlinesr@   rT   r   summapr   )rL   r   liness      rN   r   z_Reader.readlines  sI    %%d++diSe__1E1EFFFrO   c                T    | j         r| j                                         d| _        d S )NT)r   r   r   r   r`   s    rN   r   z_Reader.close	  s,     	 KrO   r   offsetwhencec                ~    | j                             ||          }| j                            | j        |           |S )NrI   )r   seekr@   rX   r   )rL   r   r   poss       rN   r   z_Reader.seek  s;    kvv..TY#666
rO   c                4    | j                                         S r]   )r   tellr`   s    rN   r   z_Reader.tell  s    {!!!rO   sr   c                     t          d          )Nwriter   )rL   r   s     rN   r   z_Reader.write  s    "7+++rO   r   Iterable[Any]c                     t          d          )N
writelinesr   )rL   r   s     rN   r   z_Reader.writelines  s    "<000rO   N)T)
r   r   r@   rA   r   r;   r   r   rP   rQ   )rP   r   ro   )rP   r   )rP   r   rP   r   )rP   r   )rP   r   )r   )r   r   rP   r   )r   r   )r   r   rP   r   rn   )r   )r   r   r   r   rP   r   )r   r   rP   r   )r   r   rP   rQ   )rp   rq   rr   rs   rK   ra   rm   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rO   rN   r   r      s       CC "                
    X$ $ $ $$ $ $ $       X        X & & & && & & &       
   
    
    
   
    
" " " ", , , ,1 1 1 1 1 1rO   r   c                  *    e Zd ZdZddZdd	ZddZdS )_ReadContextzEA utility class to handle a context for both a reader and a progress.r@   rA   readerr=   rP   rQ   c                "    || _         || _        d S r]   )r@   r   )rL   r@   r   s      rN   rK   z_ReadContext.__init__   s      rO   c                f    | j                                          | j                                        S r]   )r@   r_   r   ra   r`   s    rN   ra   z_ReadContext.__enter__$  s*    {$$&&&rO   rc   rd   re   rf   rg   rh   c                p    | j                                          | j                            |||           d S r]   )r@   stopr   rm   rl   s       rN   rm   z_ReadContext.__exit__(  s8     	Xw77777rO   N)r@   rA   r   r=   rP   rQ   )rP   r=   ro   )rp   rq   rr   rs   rK   ra   rm   r   rO   rN   r   r     sV        OO! ! ! !' ' ' '8 8 8 8 8 8rO   r   
Reading...)r   r   r   r   r   r   r   r   r   r   r   filer   ContextManager[BinaryIO]c          
     "   |rt          d          gng }|                    t          ||	|
|          t                      t	                      f           t          ||||||pd|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.

    r   r   rw   r   )r   r   )r   r   r   DownloadColumnr   r   	wrap_filer   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r@   r   s                   rN   r   r   2  s    J EPW>	?	?@@UW  NN--'	   !!		
   	!-3  H E{KKF&)))rO   r   )r   r   r   r   r   r   r   r   r   r   r   r   "Union[str, 'PathLike[str]', bytes]r   "Union[Literal['rt'], Literal['r']]	bufferingencodingOptional[str]errorsnewlineOptional[int]ContextManager[TextIO]c                   d S r]   r   r   r   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   s                     rN   openr  s  	    , 	DrO   Literal['rb']c                   d S r]   r   r  s                     rN   r  r    r  rO   r1Union[Literal['rb'], Literal['rt'], Literal['r']]7Union[ContextManager[BinaryIO], ContextManager[TextIO]]c          
     ,   |rt          d          gng }|                    t          ||||          t                      t	                      f           t          |||	|
||pd|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.

    r   r   rw   r   )r   r   r   r   r  r   r   )r   r   r   r   r   r   r  r   )r   r   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   r@   r   s                        rN   r  r    s    b EPW>	?	?@@UW  NN--'	   !!		
   	!-3  H ]]  	 	F &)))rO   c                  T    e Zd ZU dZdZded<   ddd	ZddZddZe	dd            Z
dS )ProgressColumnz3Base class for a widget to use in progress display.Nr   max_refreshtable_columnOptional[Column]rP   rQ   c                0    || _         i | _        d | _        d S r]   )_table_column_renderable_cache_update_time)rL   r  s     rN   rK   zProgressColumn.__init__   s     )MO-1rO   r7   c                ,    | j         pt                      S )z.Get a table column, used to build tasks table.)r  r7   r`   s    rN   get_table_columnzProgressColumn.get_table_column  s    !-VXX-rO   r   'Task'r0   c                   |                                 }| j        >|j        s7	 | j        |j                 \  }}|| j        z   |k    r|S n# t
          $ r Y nw xY w|                     |          }||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).
        )r   r  rI   r  idKeyErrorrender)rL   r   current_time	timestamp
renderables        rN   __call__zProgressColumn.__call__	  s     }}''&(,(>tw(G%	: t//,>>%% ?     [[&&
+7*Dtw's   A
 

AAc                    dS )z"Should return a renderable object.Nr   rL   r   s     rN   r  zProgressColumn.render   s      rO   r]   )r  r  rP   rQ   )rP   r7   r   r  rP   r0   )rp   rq   rr   rs   r  __annotations__rK   r  r!  r   r  r   rO   rN   r  r    s         ==#'K''''2 2 2 2 2
. . . .   . 1 1 1 ^1 1 1rO   r  c                  6     e Zd ZdZ	 dddd fd	ZddZ xZS )RenderableColumnzA column to insert an arbitrary column.

    Args:
        renderable (RenderableType, optional): Any renderable. Defaults to empty string.
     Nr  r   r0   r  r  c               Z    || _         t                                          |           d S Nr)  )r   rJ   rK   )rL   r   r  rM   s      rN   rK   zRenderableColumn.__init__,  s-     %l33333rO   r   r  rP   c                    | j         S r]   )r   r#  s     rN   r  zRenderableColumn.render2  s
    rO   )r(  )r   r0   r  r  r$  rp   rq   rr   rs   rK   r  rt   ru   s   @rN   r'  r'  %  sr          ,.4SW4 4 4 4 4 4 4 4       rO   r'  c                  F     e Zd ZdZ	 	 	 	 	 dd fdZ	 	 dddZddZ x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_namer   r   Optional[StyleType]speedrE   finished_textr:   r  r  c                    t          |||          | _        t          |t                    rt	          j        |          n|| _        t                                          |           d S )Nr   r6  r)  )	r5   spinner
isinstancer   r9   from_markupr7  rJ   rK   )rL   r4  r   r6  r7  r  rM   s         rN   rK   zSpinnerColumn.__init__@  sm     |5FFF ---D]+++ 	
 	l33333rO   spinner_stylerP   rQ   c                4    t          |||          | _        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.
        r9  N)r5   r:  )rL   r4  r=  r6  s       rN   set_spinnerzSpinnerColumn.set_spinnerP  s     |=NNNrO   r   r  r0   c                z    |j         r| j        n+| j                            |                                          }|S r]   )finishedr7  r:  r  r   )rL   r   texts      rN   r  zSpinnerColumn.render_  s=     }6D$$T]]__55 	
 rO   )r0  r1  r2  r3  N)
r4  r   r   r5  r6  rE   r7  r:   r  r  )r1  r2  )r4  r   r=  r5  r6  rE   rP   rQ   r$  )rp   rq   rr   rs   rK   r?  r  rt   ru   s   @rN   r/  r/  6  s          #%7"%)-4 4 4 4 4 4 4& .@	O O O O O       rO   r/  c                  8     e Zd ZdZ	 	 	 	 	 dd fdZddZ xZS )r   zA column containing text.noneleftTNtext_formatr   r   r6   justifyr/   markupr   highlighterOptional[Highlighter]r  r  rP   rQ   c                    || _         || _        || _        || _        || _        t                                          |pt          d                     d S )NTno_wrapr)  )rF  rG  r   rH  rI  rJ   rK   r7   )rL   rF  r   rG  rH  rI  r  rM   s          rN   rK   zTextColumn.__init__k  s[     '&-
&l&JfT6J6J6JKKKKKrO   r   r  r9   c                   | j                             |          }| j        r"t          j        || j        | j                  }nt          || j        | j                  }| j        r| j                            |           |S Nr   )r   rG  )	rF  formatrH  r9   r<  r   rG  rI  	highlight)rL   r   _textrB  s       rN   r  zTextColumn.render{  s     ''T'22; 	G#ET\RRRDDTZFFFD 	-&&t,,,rO   )rD  rE  TNN)rF  r   r   r6   rG  r/   rH  r   rI  rJ  r  r  rP   rQ   r   r  rP   r9   r-  ru   s   @rN   r   r   h  st        ##
 "!'-1)-L L L L L L L        rO   r   c                  :     e Zd ZdZ	 	 	 	 	 	 dd fdZddZ xZS )r   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".
    (   rx   ry   rz   r{   N	bar_widthr  r   r6   r   r   r   r  r  rP   rQ   c                    || _         || _        || _        || _        || _        t                                          |           d S r+  )rW  r   r   r   r   rJ   rK   )rL   rW  r   r   r   r   r  rM   s          rN   rK   zBarColumn.__init__  sL     #
,,&l33333rO   r   r  r4   c                    t          |j        t          d|j                  ndt          d|j                  | j        dnt          d| j                  |j         |                                | j        | j        | j	        | j
        	  	        S )z&Gets a progress bar widget for a task.Nr   r*   )	r   rI   widthpulseanimation_timer   r   r   r   )r4   r   maxrI   rW  startedr   r   r   r   r   r#  s     rN   r  zBarColumn.render  s    (,
(>#a$$$D!T^,,.0$$c!T^6L6Ll"==??*..(

 

 

 
	
rO   )rV  rx   ry   rz   r{   N)rW  r  r   r6   r   r6   r   r6   r   r6   r  r  rP   rQ   )r   r  rP   r4   r-  ru   s   @rN   r   r     st          $&%$2$2!,)-4 4 4 4 4 4 4 
 
 
 
 
 
 
 
rO   r   c                      e Zd ZdZddZdS )	TimeElapsedColumnzRenders time elapsed.r   r  rP   r9   c                    |j         r|j        n|j        }|t          dd          S t	          t          dt          |                              }t          t          |          d          S )zShow time elapsed.N-:--:--progress.elapsedr   r   )seconds)rA  finished_timeelapsedr9   r
   r]  r   r   )rL   r   rg  deltas       rN   r  zTimeElapsedColumn.render  sk    (,G$$$4<?	);<<<<#aW"6"6777CJJ&89999rO   NrT  rp   rq   rr   rs   r  r   rO   rN   r`  r`    s.        : : : : : :rO   r`  c                  V     e Zd ZdZ	 	 	 	 	 	 	 	 d!d" fdZed#d            Zd$d Z xZS )%r   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(  rD  rE  TNFrF  r   text_format_no_percentager   r6   rG  r/   rH  r   rI  rJ  r  r  r   rP   rQ   c	                r    || _         || _        t                                          ||||||           d S )N)rF  r   rG  rH  rI  r  )rl  r   rJ   rK   )
rL   rF  rl  r   rG  rH  rI  r  r   rM   s
            rN   rK   zTaskProgressColumn.__init__  sR     *C&$##% 	 	
 	
 	
 	
 	
rO   r6  r   r9   c                    |t          dd          S t          j        t          |          g dd          \  }}||z  }t          |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.percentagerd  )r(  u   ×10³u   ×10⁶u   ×10⁹u   ×10¹²  z.1fz it/s)r9   r+   pick_unit_and_suffixr   )clsr6  unitsuffix
data_speeds        rN   render_speedzTaskProgressColumn.render_speed  sx     ="788884JJ<<<
 
f
 T\
z44v444<QRRRRrO   r   r  c                   |j         (| j        r!|                     |j        p|j                  S |j         | j        n| j        }|                    |          }| j        r"t          j
        || j        | j                  }nt          || j        | j                  }| j        r| j                            |           |S rO  )r   r   ru  finished_speedr6  rl  rF  rQ  rH  r9   r<  r   rG  rI  rR  )rL   r   rF  rS  rB  s        rN   r  zTaskProgressColumn.render  s    :$/$$T%8%FDJGGG.2j.@D**dFV 	 """--; 	G#ET\RRRDDTZFFFD 	-&&t,,,rO   )rk  r(  rD  rE  TNNF)rF  r   rl  r   r   r6   rG  r/   rH  r   rI  rJ  r  r  r   r   rP   rQ   )r6  r   rP   r9   rT  )	rp   rq   rr   rs   rK   classmethodru  r  rt   ru   s   @rN   r   r     s          K)+!!'-1)- 
 
 
 
 
 
 
, S S S [S&       rO   r   c                  8     e Zd ZdZdZ	 	 	 dd fd
ZddZ xZS )r   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.
          ?FNcompactr   r   r  r  c                h    || _         || _        t                                          |           d S r+  )r{  r   rJ   rK   )rL   r{  r   r  rM   s       rN   rK   zTimeRemainingColumn.__init__  s5     %:"l33333rO   r   r  rP   r9   c                t   | j         r|j        r
|j        }d}n	|j        }d}|j        t          d|          S |t          | j        rdnd|          S t          t          |          d          \  }}t          |d          \  }}| j        r|s
|d	d
|d	}n|dd
|d	d
|d	}t          ||          S )zShow time remaining.rc  zprogress.remainingNr(  rd  z--:--rb  <   02d:d)	r   rA  rf  time_remainingr   r9   r{  divmodr   )rL   r   	task_timer   minutesre  hours	formatteds           rN   r  zTimeRemainingColumn.render  s   % 	)$- 	)*I&EE+I(E:%((((4<>YeLLLL "#i.."55,,w< 	A 	A"666666II @@@W@@@7@@@IIU++++rO   )FFN)r{  r   r   r   r  r  rT  )rp   rq   rr   rs   r  rK   r  rt   ru   s   @rN   r   r     sr          K &+)-	4 4 4 4 4 4 4, , , , , , , ,rO   r   c                      e Zd ZdZddZdS )	FileSizeColumnzRenders completed filesize.r   r  rP   r9   c                p    t          j        t          |j                            }t	          |d          S )Show data completed.zprogress.filesizerd  )r+   decimalr   rI   r9   rL   r   	data_sizes      rN   r  zFileSizeColumn.render7  s0    $S%8%899	I%89999rO   NrT  ri  r   rO   rN   r  r  4  s.        %%: : : : : :rO   r  c                      e Zd ZdZddZdS )	TotalFileSizeColumnzRenders total filesize.r   r  rP   r9   c                    |j         &t          j        t          |j                             nd}t	          |d          S )r  Nr(  zprogress.filesize.totalrd  )r   r+   r  r   r9   r  s      rN   r  zTotalFileSizeColumn.render@  s;    9=9OH$S__555UW	I%>????rO   NrT  ri  r   rO   rN   r  r  =  s4        !!@ @ @ @ @ @rO   r  c                  .     e Zd ZdZdd fdZddZ x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   r  r  c                Z    || _         t                                          |           d S r+  )r  rJ   rK   )rL   r  r  rM   s      rN   rK   zMofNCompleteColumn.__init__R  s+    "l33333rO   r   r  rP   r9   c                    t          |j                  }|j        t          |j                  nd}t          t	          |                    }t          || d| j         | d          S )zShow completed/total.N?r  progress.downloadrd  )r   rI   r   r   r   r9   r  )rL   r   rI   r   total_widths        rN   r  zMofNCompleteColumn.renderV  st    ''	#':#9DJs#e**oo+@@@@@@@%
 
 
 	
rO   )r  N)r  r   r  r  rT  r-  ru   s   @rN   r  r  F  s`        	 	4 4 4 4 4 4 4
 
 
 
 
 
 
 
rO   r  c                  0     e Zd ZdZ	 dd fd
ZddZ x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   r  r  rP   rQ   c                Z    || _         t                                          |           d S r+  )r  rJ   rK   )rL   r  r  rM   s      rN   rK   zDownloadColumn.__init__h  s.     )l33333rO   r   r  r9   c                   t          |j                  }|j        t          |j                  n|}| j        rt	          j        |g dd          \  }}nt	          j        |g dd          \  }}|dk    rdnd}||z  }|d| d	}|j        "t          |j                  }	|	|z  }
|
d| d	}nd
}| d| d| }t          |d          }|S )z.Calculate common unit for completed and total.N)	r   KiBMiBGiBTiBPiBEiBZiBYiBi   )	r   kBMBGBTBPBEBZBYBro  r*   r   z,.fr  r  r3  r  rd  )r   rI   r   r  r+   rp  r9   )rL   r   rI    unit_and_suffix_calculation_baserr  rs  	precisioncompleted_ratiocompleted_strr   total_ratio	total_strdownload_statusdownload_texts                 rN   r  zDownloadColumn.rendern  s+   ''	  $z5C
OOO9 	)  	#80QQQ LD&& $80III LD&
 AA	#d**;i;;;;:!
OOE$,K&7)7777III*AAYAAAA_4GHHHrO   )FN)r  r   r  r  rP   rQ   rT  r-  ru   s   @rN   r   r   a  sg          LP4 4 4 4 4 4 4! ! ! ! ! ! ! !rO   r   c                      e Zd ZdZddZdS )	TransferSpeedColumnz&Renders human readable transfer speed.r   r  rP   r9   c                    |j         p|j        }|t          dd          S t          j        t          |                    }t          | dd          S )zShow data transfer speed.Nr  zprogress.data.speedrd  z/s)rw  r6  r9   r+   r  r   )rL   r   r6  rt  s       rN   r  zTransferSpeedColumn.render  s]    #1tz=#89999%c%jj11
z%%%-BCCCCrO   NrT  ri  r   rO   rN   r  r    s4        00D D D D D DrO   r  c                  *    e Zd ZU dZded<   	 ded<   dS )ProgressSamplez$Sample of progress for a given time.rE   r  rI   N)rp   rq   rr   rs   r%  r   rO   rN   r  r    s3         ..$$rO   r  c                     e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   	 d
ed<   	 dZded<   	 dZded<   	  ee          Z	ded<   	  eddd          Z
ded<   	  eddd          Zded<   	 dZded<   	  ed dd          Zded<    ede          Zded<   	 d+d!Zed,d"            Zed-d#            Zed-d$            Zed,d%            Zed+d&            Zed-d'            Zed-d(            Zd.d*ZdS )/TaskzInformation regarding a progress task.

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

    r;   r  r   r   r   r   rE   rI   GetTimeCallable	_get_timeNrf  Tr   visible)default_factoryzDict[str, Any]fieldsF)defaultinitrepr
start_time	stop_timerw  c                 "    t          d          S )Nro  )maxlenr   r   rO   rN   <lambda>zTask.<lambda>  s    T 2 2 2 rO   )r  r  r  zDeque[ProgressSample]	_progress)r  r  r   _lockrP   c                *    |                                  S )z(float: Get the current time, in seconds.)r  r`   s    rN   r   zTask.get_time  s    ~~rO   c                    | j         duS )z#bool: Check if the task as started.N)r  r`   s    rN   r^  zTask.started  s     d**rO   c                2    | j         dS | j         | j        z
  S )zPOptional[float]: Get the number of steps remaining, if a non-None total was set.Nr   rI   r`   s    rN   	remainingzTask.remaining  s      :4zDN**rO   c                x    | j         dS | j        | j        | j         z
  S |                                 | j         z
  S )z]Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started.N)r  r  r   r`   s    rN   rg  zTask.elapsed  s=     ?"4>%>DO33}}00rO   c                    | j         duS )zCheck if the task has finished.N)rf  r`   s    rN   rA  zTask.finished  s     !--rO   c                x    | j         sdS | j        | j         z  dz  }t          dt          d|                    }|S )zOfloat: Get progress of task as a percentage. If a None total was set, returns 0              Y@)r   rI   minr]  )rL   rI   s     rN   
percentagezTask.percentage  sE     z 	3^dj0E9	s3	2233	rO   c                ^   | j         dS | j        5  | j        }|s	 ddd           dS |d         j        |d         j        z
  }|dk    r	 ddd           dS t	          |          }t          |           t          d |D                       }||z  }|cddd           S # 1 swxY w Y   dS )z=Optional[float]: Get the estimated speed in steps per second.Nr   r   c              3  $   K   | ]}|j         V  d S r]   r   ).0samples     rN   	<genexpr>zTask.speed.<locals>.<genexpr>  s%      !O!Ov&"2!O!O!O!O!O!OrO   )r  r  r  r  iterr   r   )rL   r@   
total_timeiter_progresstotal_completedr6  s         rN   r6  z
Task.speed  sI    ?"4Z 	 	~H 	 	 	 	 	 	 	 	 ""/(1+2GGJQ	 	 	 	 	 	 	 	 !NNM!!O!O!O!O!OOOO#j0E	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   B""B"=B""B&)B&c                h    | j         rdS | j        }|sdS | j        }|dS t          ||z            }|S )zJOptional[float]: Get estimated time to completion, or ``None`` if no data.r  N)rA  r6  r  r   )rL   r6  r  estimates       rN   r  zTask.time_remaining  sP     = 	3
 	4N	4	E)**rO   rQ   c                T    | j                                          d| _        d| _        dS )zReset progress.N)r  clearrf  rw  r`   s    rN   _resetzTask._reset  s,    !"rO   )rP   rE   r   )rP   r   rn   )rp   rq   rr   rs   r%  rf  r  r	   dictr  r  r  rw  r  r   r  r   r   r^  r  rg  rA  r  r6  r  r  r   rO   rN   r  r    sr          JJJG'>*+%)M))))(GJ"U4888F8888?"'%5u"M"M"MJMMMMN!&t%e!L!L!LILLLLN&*N****>',u22U( ( (I     5eU;;;E;;;;        + + + X+ + + + X+ 1 1 1 X1 . . . X.    X    X"    X# # # # # #rO   r  c                     e Zd ZdZddddddddddd
dsdZedtd            Zedud            Zedvd             Z	edwd"            Z
edxd#            Zdyd$Zdyd%Zdzd'Zd{d.Z	 	 	 	 	 d|d}d=Z	 d~dd>d?ddCZej        	 	 	 	 dddd>dEddN            Zej        	 	 	 	 dddd>dEddQ            Z	 	 	 	 	 dddd>dEddUZddWZddXZdddddddYdd`Zddd/dddaddcZdddeZdydfZddhZddjZddnZddoZ	 	 	 	 dddqZddrZ dS )r   a  Renders an auto-updating progress bar(s).

    Args:
        console (Console, optional): Optional Console instance. Defaults to 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.
    NTrw   g      >@F)
r   r   r   speed_estimate_periodr   redirect_stdoutredirect_stderrr   r   expandr   Union[str, ProgressColumn]r   r   r   r   r   rE   r  r   r  r  r   Optional[GetTimeCallable]r   r  rP   rQ   c       
   	        |dk    s
J d            t                      | _        |p|                                 | _        || _        |	| _        |
| _        i | _        t          d          | _	        t          |pt                      |||||| j                  | _        |p| j        j        | _        | j        j        | _        | j        j        | _        d S )Nr   zrefresh_per_second must be > 0)r   r   r   r   r  r  get_renderable)r   r  get_default_columnsr   r  r   r  _tasksr;   _task_indexr3   r,   r  rV   r   r   printlog)rL   r   r   r   r  r   r  r  r   r   r  r   s               rN   rK   zProgress.__init__5  s     "A%%%'G%%%WW
<$":":"<"<%:"*,#)!99,{}}%1++.
 
 
	 !9DL$9\'
<#rO   Tuple[ProgressColumn, ...]c                p    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.get_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.
        r   )r   r   r   r   )rq  s    rN   r  zProgress.get_default_columnsY  s3    2 ABBKK  !!	
 	
rO   r-   c                    | j         j        S r]   )rV   r   r`   s    rN   r   zProgress.consolex  s    y  rO   
List[Task]c                    | j         5  t          | j                                                  cddd           S # 1 swxY w Y   dS )zGet a list of Task instances.N)r  listr  valuesr`   s    rN   taskszProgress.tasks|  s     Z 	. 	.**,,--	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.   &;??List[TaskID]c                    | j         5  t          | j                                                  cddd           S # 1 swxY w Y   dS )zA list of task IDs.N)r  r  r  keysr`   s    rN   task_idszProgress.task_ids  s     Z 	, 	,((**++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,r  c                    | j         5  | j        s	 ddd           dS t          d | j                                        D                       cddd           S # 1 swxY w Y   dS )z'Check if all tasks have been completed.NTc              3  $   K   | ]}|j         V  d S r]   )rA  )r  r   s     rN   r  z$Progress.finished.<locals>.<genexpr>  s$      FFt}FFFFFFrO   )r  r  allr  r`   s    rN   rA  zProgress.finished  s     Z 	G 	G; 	G 	G 	G 	G 	G 	G 	G 	G FF1C1C1E1EFFFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   	A/AA!Ac                N    | j         s| j                            d           dS dS )zStart the progress display.T)rS   N)r   rV   r_   r`   s    rN   r_   zProgress.start  s2    | 	*IOODO)))))	* 	*rO   c                    | j                                          | j        j        s'| j        j        s| j                                         dS dS dS )zStop the progress display.N)rV   r   r   is_interactive
is_jupyterr  r`   s    rN   r   zProgress.stop  s[    	|* 	!4<3J 	!L     	! 	! 	! 	!rO   r)   c                .    |                                   | S r]   r^   r`   s    rN   ra   zProgress.__enter__  rb   rO   rc   rd   re   rf   rg   rh   c                .    |                                   d S r]   )r   rl   s       rN   rm   zProgress.__exit__  s     			rO   r   rv   r|   r}   r~   r   r   rI   r   rB   Optional[TaskID]r   r   rD   c              #    K   |t          t          |                    pd}||                     |||          }n|                     |||           | j        j        rFt          | ||          5 }|D ]}|V  |xj        dz  c_        	 ddd           dS # 1 swxY w Y   dS | j        }	| j	        }
|D ]}|V   |	|d            |
             dS )aC  Track progress by iterating over a sequence.

        You can also track progress of an iterable, which might require that you additionally specify ``total``.

        Args:
            sequence (Iterable[ProgressType]): Values you want to iterate over and track progress.
            total: (float, optional): Total number of steps. Default is len(sequence).
            completed (int, optional): Number of steps completed so far. Defaults to 0.
            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.
        Nr  r*   )
rE   r   add_taskrX   rV   r   r?   rI   rT   rS   )rL   r}   r   rI   rB   r   rD   track_threadvaluerT   rS   s              rN   r   zProgress.track  sb     0 =+h//008DE?mmKu	mRRGGKKu	KBBB9! 	dG];; 0|% 0 0EKKK **a/***00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 lGlG!  ###				 s   3BB"Br   )rB   r   r   r   r  c                   d}||}n3|1| j         5  | j        |         j        }ddd           n# 1 swxY w Y   |t          d          ||                     ||          }n|                     ||           t          || |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'r   Fr   )r  r  r   
ValueErrorr  rX   r   )rL   r   r   rB   r   total_bytess         rN   r   zProgress.wrap_file  s    . (,KK  9 9"k'289 9 9 9 9 9 9 9 9 9 9 9 9 9 9R  
 ?mmK{mCCGGKK{K333tT7????s   044r   )r   rB   r   r   r   r  r   r   r   r   r  c                   d S r]   r   
rL   r   r   r   r   r   r  r   rB   r   s
             rN   r  zProgress.open  	     	rO   "Union[Literal['r'], Literal['rt']]r$   c                   d S r]   r   r  s
             rN   r  zProgress.open  r  rO   r
  r  Union[BinaryIO, TextIO]c               6   d                     t          |d                    }
|
dvrt          d|          |dk    }|
dk    r#|dk    rt          j        dt
                     d	}n!|
d
v r|dk    rt          d          |dk    rd	}|t          |          j        }||                     |	|          }n| 	                    ||           t          j        |d|          }t          || |d          }|dv rt          j        |||||          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)brrtr
  zinvalid mode r*   r  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/ONr  rb)r   Tr  )r
  r   )r   r   r  line_buffering)rk   sortedr  warningswarnRuntimeWarningr   st_sizer  rX   ior  r   TextIOWrapper)rL   r   r   r   r   r   r  r   rB   r   _moder"  r   r   s                 rN   r  zProgress.open  sj   B tU33344)))5T55666 #aD==Y!^^Ms   IIk!!A~~ !ABBBa	 =JJ&E ?mmKum==GGKKuK--- ty999wTBBB ;#!-    rO   r;   c                    | j         5  | j        |         }|j        |                                 |_        ddd           dS # 1 swxY w Y   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  r  r  r   )rL   rB   r   s      rN   
start_taskzProgress.start_taskk  s     Z 	2 	2;w'D&"&--//	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   .AA
Ac                    | j         5  | j        |         }|                                 }|j        ||_        ||_        ddd           dS # 1 swxY w Y   dS )zStop a task.

        This will freeze the elapsed time on the task.

        Args:
            task_id (TaskID): ID of task.
        N)r  r  r   r  r  )rL   rB   r   r  s       rN   	stop_taskzProgress.stop_tasky  s     Z 	* 	*;w'D==??L&".)DN	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   7AAA)r   rI   rT   r   r  rS   rT   r  Optional[bool]rS   r  r   c                  | j         5  | j        |         }	|	j        }
|&||	j        k    r||	_        |	                                 ||	xj        |z  c_        |||	_        |||	_        |||	_        |	j                            |           |	j        |
z
  }| 	                                }|| j
        z
  }|	j        }|j        }|r.|d         j        |k     r |             |r|d         j        |k     |dk    r#|                    t          ||                     |	j        #|	j        |	j        k    r|	j        |	j        |	_        ddd           n# 1 swxY w Y   |r|                                  dS 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  r  rI   r   r  r   r  r  rX   r   r  r  popleftr  appendr  rf  rg  rS   )rL   rB   r   rI   rT   r   r  rS   r  r   completed_startupdate_completedr  old_sample_timer  r1  s                   rN   rX   zProgress.update  s   0 Z  	2  	2;w'D"nO Udj%8%8"
"')$!*&#. "&Kv&&&#~?==??L*T-GGOI'G 	! 6 H H			  	! 6 H H!##  >N!O!OPPP
&Ndj00&.%)\"A 	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2D  	LLNNNNN	 	s   D=EEE)r_   r   rI   r  r   r_   c               P   |                                  }| j        5  | j        |         }	|	                                 |r|nd|	_        |||	_        ||	_        |||	_        |r||	_        |||	_	        d|	_
        ddd           n# 1 swxY w Y   |                                  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)r   r  r  r  r  r   rI   r  r  r   rf  rS   )
rL   rB   r_   r   rI   r  r   r  r  r   s
             rN   resetzProgress.reset  s    , }}Z 	& 	&;w'DKKMMM.3=llDO "
&DN"& %$&#. !%D	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	s   ABBBr*   c                l   |                                  }| j        5  | j        |         }|j        }|xj        |z  c_        |j        |z
  }|| j        z
  }|j        }|j        }	|r.|d         j        |k     r |	             |r|d         j        |k     t          |          dk    r |	             t          |          dk    |	                    t          ||                     |j        /|j        |j        k    r|j        |j        |_        |j        |_        ddd           dS # 1 swxY w Y   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   ro  N)r   r  r  rI   r  r  r1  r  r   r2  r  r   rf  rg  r6  rw  )
rL   rB   rT   r  r   r3  r4  r5  r  r1  s
             rN   rT   zProgress.advance  s    }}Z 	1 	1;w'D"nONNg%NN#~?*T-GGOI'G 	! 6 H H			  	! 6 H Hi..4''			 i..4''^L:JKKLLL
&Ndj00&.%)\"&*j#)	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   D D))D-0D-c                f    | j         s'| j        j        r| j                                         dS dS dS )z*Refresh (render) the progress information.N)r   rV   rW   rS   r`   s    rN   rS   zProgress.refresh
  sF    | 	 	 4 	 I	  	  	  	 rO   r0   c                <    t          |                                  }|S )z*Get a renderable for the progress display.)r.   get_renderables)rL   r   s     rN   r  zProgress.get_renderable  s    D00223
rO   Iterable[RenderableType]c              #  F   K   |                      | j                  }|V  dS )z5Get a number of renderables for the progress display.N)make_tasks_tabler  )rL   tables     rN   r;  zProgress.get_renderables  s(      %%dj11rO   r  Iterable[Task]r8   c                    d | j         D             }t          j        |d| j        d}|D ]$j        r |j        fd| j         D               %|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              3     K   | ]O}t          |t                    rt          d           n%|                                                                V  PdS )TrL  N)r;  r   r7   r  copy)r  _columns     rN   r  z,Progress.make_tasks_table.<locals>.<genexpr>"  sr       
 
  gs++7t$$$$--//4466	
 
 
 
 
 
rO   )r   r*   )paddingr  c              3     K   | ]:}t          |t                    r|                               n
 |          V  ;dS )rP  N)r;  r   rQ  )r  columnr   s     rN   r  z,Progress.make_tasks_table.<locals>.<genexpr>/  sf         #  *&#66.FMMtM444!'	     rO   )r   r8   gridr  r  add_row)rL   r  table_columnsr?  r   s       @rN   r>  zProgress.make_tasks_table  s    
 
  <
 
 
 
M6$+NNN 	 	D| 
    '+l  	 	 rO   c                l    | j         5  |                                 cddd           S # 1 swxY w Y   dS )z+Makes the Progress class itself renderable.N)r  r  r`   s    rN   __rich__zProgress.__rich__:  s}    Z 	) 	)&&((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   )--r  c                n   | j         5  t          | j        |||||| j        | j                   }|| j        | j        <   |r|                     | j                   | j        }t          t          | j                  dz             | _        ddd           n# 1 swxY w Y   |                                  |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  r  r  r  r*   N)	r  r  r  r   r  r,  r;   r   rS   )	rL   r   r_   r   rI   r  r  r   new_task_indexs	            rN   r  zProgress.add_task?  s   0 Z 	A 	A -j	 	 	D -1DK() 2 0111!-N%c$*:&;&;a&?@@D	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A  	s   BBBBc                V    | j         5  | j        |= ddd           dS # 1 swxY w Y   dS )z]Delete a task if it exists.

        Args:
            task_id (TaskID): A task ID.

        N)r  r  )rL   rB   s     rN   remove_taskzProgress.remove_taskj  sz     Z 	% 	%G$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   	"")r   r  r   r   r   r   r   rE   r  rE   r   r   r  r   r  r   r   r  r   r   r  r   rP   rQ   )rP   r  )rP   r-   )rP   r  )rP   r   r   rn   )rP   r)   ro   )Nr   Nrv   r|   )r}   r~   r   r   rI   r   rB   r  r   r   rD   rE   rP   r~   r]   )
r   r   r   r  rB   r  r   r   rP   r   r   NNN)r   r   r   r  r   r   r   r   r   r   r  r   r   r  rB   r  r   r   rP   r   )r   r   r   r  r   r   r   r   r   r   r  r   r   r  rB   r  r   r   rP   r$   r
  r   NNN)r   r   r   r  r   r   r   r   r   r   r  r   r   r  rB   r  r   r   rP   r  )rB   r;   rP   rQ   )rB   r;   r   r   rI   r   rT   r   r   r   r  r/  rS   r   r  r   rP   rQ   )rB   r;   r_   r   r   r   rI   r   r  r/  r   r   r  r   rP   rQ   )r*   )rB   r;   rT   rE   rP   rQ   )rP   r0   )rP   r<  )r  r@  rP   r8   )Tr  r   T)r   r   r_   r   r   r   rI   r   r  r   r  r   rP   r;   )!rp   rq   rr   rs   rK   rx  r  r   r   r  r  rA  r_   r   ra   rm   r   r   typingoverloadr  r,  r.  rX   r7  rT   rS   r  r;  r>  rL  r  rP  r   rO   rN   r   r   %  s        $ &*!$&'+ $ $.2"$ "$ "$ "$ "$ "$H 
 
 
 [
< ! ! ! X! . . . X.
 , , , X,
 G G G XG* * * *
! ! ! !       "&$('"+ + + + +`  $(@
 %)'(@ (@ (@ (@ (@ (@T _
 "& $!%  $$('     _ _
 "& $!%  $$('     _$ CF"& $!%K  $$('K K K K K KZ2 2 2 2* * * *& "&%)#'%)"&; ; ; ; ; ;B !%"&%)% % % % % %N1 1 1 1 1<       
   
   
   B) ) ) ) !&) ) ) ) )V% % % % % %rO   r   __main__)Panel)Rule)Syntax)r8   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_numbersfoobar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...examplezPretty printed)typerB  z	Syntax...zGive it a try!)cycle)record)r   r   z[red]Downloadingro  r  z[green]Processingz[yellow]Thinkingrz  r   g333333?g{Gz?d   )rv   Nr   TNFNrw   rx   ry   rz   r{   r|   FT)"r}   r~   r   r   r   r   rI   r   r   r   r   r   r   r   r   r   r   rE   r   r6   r   r6   r   r6   r   r6   rD   rE   r   r   r   r   rP   r~   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rE   r   r6   r   r6   r   r6   r   r6   r   r   rP   r   rQ  )&r   r   r   r   r   r   r   r   r   r   r  r   r   r  r   r   r   r   r   r   r   r   r   r   r   rE   r   r6   r   r6   r   r6   r   r6   r   r   rP   r  )&r   r   r   r  r   r   r   r   r   r   r  r   r   r  r   r   r   r   r   r   r   r   r   r   r   rE   r   r6   r   r6   r   r6   r   r6   r   r   rP   r   rR  )&r   r   r   r  r   r   r   r   r   r   r  r   r   r  r   r   r   r   r   r   r   r   r   r   r   rE   r   r6   r   r6   r   r6   r   r6   r   r   rP   r  )
__future__r   r(  rS  r$  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'   r(   typing_extensionsr)   r(  r+   r,   r   r-   r.   r/   r0   rI  r1   jupyterr2   rV   r3   progress_barr4   r:  r5   r   r6   r?  r7   r8   rB  r9   r:   r   r;   r<   rE   r  r=   r?   r   r   r   r   rT  r  r  r'  r/  r   r   r`  r   r   r  r  r  r   r  r  r  r   rp   randomtimepanelrV  rulerW  syntaxrX  rI  progress_renderables	itertoolsrc  examplesr  r@   r  task1task2task3rA  rX   sleeprandintr  r   r   rO   rN   <module>r     s   " " " " " " 				   # # # # # # # #       ( ( ( ( ( ( ( (       . . . . . . . .                                 * * * * * * * * * *                                               ,  '&&&&&& # # # # # # # # B B B B B B B B B B B B $ $ $ $ $ $ ! ! ! ! ! !       % % % % % %                                            	3		w~&&2u9% V^D&(++% % % % %6 % % %T $!!%.2 "! . .(!K
 K
 K
 K
 K
\d1 d1 d1 d1 d1i d1 d1 d1N8 8 8 8 8>"%wr{ 8 8 82 $!%.2 "! . .(>* >* >* >* >* >*B  " !	  #!%.2 "! . .('	 	 	 	 	 	0  " !	  #!%.2 "! . .('	 	 	 	 	 	4 ?B" !S*  #!%.2 "! . .('S* S* S* S* S* S*l'1 '1 '1 '1 '1S '1 '1 '1T    ~   "/ / / / /N / / /d       <'
 '
 '
 '
 '
 '
 '
 '
T	: 	: 	: 	: 	: 	: 	: 	:E E E E E E E EP-, -, -, -, -,. -, -, -,`: : : : :^ : : :@ @ @ @ @. @ @ @
 
 
 
 
 
 
 
6. . . . .^ . . .b	D 	D 	D 	D 	D. 	D 	D 	D% % % % %Z % % % z# z# z# z# z# z# z# z#zM	% M	% M	% M	% M	%| M	% M	% M	%` zMMMKKKV
	" 	  F  E%&&E	MM#sC    	E899'&$455
  u)**HgT"""G	
		%	%	'	'
 	
 
 
 
 
 - 
!!"4D!AA!!"5T!BB!!"4D!AA# 	-OOE3O///OOE3O///DJtv~a%%))TT(^^,,, # 	-- - - - - - - - - - - - - - - - - -] s   9CQQQ