
     h              +          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j0        dk    rd dlm1Z1 nd dl2m1Z1 ej0        dk    rd dlm3Z3 n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 e.d          ZPe g eQf         ZR ej.        de+e          ZS G d  d!e          ZT	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd+e/e*eP         e%eP         f         d,eUd-e)eQ         d.eNd/eVd0e)e8         d1eVd2e)e g eQf                  d3eQd4eGd5eGd6eGd7eGd8eQd9eVd:eVd;e%eP         f"d<ZW G d= d>ee          ZX G d? d@e!eS         e$eS                   ZYdAd#dd$dd%d&d'd(d)d$dBdCed-eNd,eUd/eVd0e)e8         d1eVd2e)e g eQf                  d3eQd4eGd5eGd6eGd7eGd9eVd;e!e         fdDZZej[        	 	 	 	 dddAd#dd$dd%d&d'd(d)d$dFdCe/eUdGe\f         dHe/e1dI         e1dJ         f         dKeNdLe)eU         dMe)eU         dNe)eU         d-e)eN         d,eUd/eVd0e)e8         d1eVd2e)e g eQf                  d3eQd4eGd5eGd6eGd7eGd9eVd;e!e+         f&dO            Z]ej[        	 	 	 	 dddAd#dd$dd%d&d'd(d)d$dFdCe/eUdGe\f         dHe1dP         dKeNdLe)eU         dMe)eU         dNe)eU         d-e)eN         d,eUd/eVd0e)e8         d1eVd2e)e g eQf                  d3eQd4eGd5eGd6eGd7eGd9eVd;e!e         f&dQ            Z]	 	 	 	 	 dddAd#dd$dd%d&d'd(d)d$dFdCe/eUdGe\f         dHe/e1dP         e1dI         e1dJ         f         dKeNdLe)eU         dMe)eU         dNe)eU         d-e)eN         d,eUd/eVd0e)e8         d1eVd2e)e g eQf                  d3eQd4eGd5eGd6eGd7eGd9eVd;e/e!e         e!e+         f         f&dRZ] G dS dTe          Z^ G dU dVe^          Z_ G dW dXe^          Z` G dY dZe^          Za G d[ d\e^          Zb G d] d^e^          Zc G d_ d`ea          Zd G da dbe^          Ze G dc dde^          Zf G de dfe^          Zg G dg dhe^          Zh G di dje^          Zi G dk dle^          Zj G dm dne'          Zke
 G do dp                      Zl G dq dre?          Zmendsk    rd dloZod dlpZpddtlqmrZr ddulsmtZt ddvlumvZv ddwlHmJZJ  evdxdyd#z          Zu eJd{d|d}          ZHeHw                    d~dd           d erd          deHdddddeu etd          g	Zxd dlymzZz  ezex          Z{ e8d#          Z7 em e`            gem|                                 ec            R e7d$d5 Z}e}~                    dd          Ze}~                    dd          Ze}~                    dd          Ze}j        sxe}                    ed           e}                    ed            epj        d            eoj        d d          dk     re}                     ee{                     e}j        xddd           dS # 1 swxY w Y   dS 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)r'      )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ddddef fdZdd
ZddZdee	e
                  dee
         dee         dd	fdZ xZS )_TrackThreadz)A thread to periodically update progress.progressProgresstask_idr=   update_periodc                     || _         || _        || _        t                      | _        d| _        t                                          d           d S )Nr   T)daemon)rB   rD   rE   r   done	completedsuper__init__)selfrB   rD   rE   	__class__s       X/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/pip/_vendor/rich/progress.pyrK   z_TrackThread.__init__G   sL     *GG	%%%%%    returnNc                 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)
rD   rB   advancerE   rH   waitlive
is_startedrI   update)rL   rD   rS   rE   last_completedrT   rI   s          rN   runz_TrackThread.runP   s    ,-'*y~$}%% 	+$-*<*G 	+I**^!;<<<!*	 $}%% 	+$-*<*G 	+ 	T\T^TRRRRRrO   c                 .    |                                   | S NstartrL   s    rN   	__enter__z_TrackThread.__enter__^       

rO   exc_typeexc_valexc_tbc                 `    | j                                          |                                  d S r[   )rH   setjoinrL   ra   rb   rc   s       rN   __exit__z_TrackThread.__exit__b   s$     				rO   rP   N)rP   rA   )__name__
__module____qualname____doc__floatrK   rY   r_   r    r$   BaseExceptionr   rh   __classcell__rM   s   @rN   rA   rA   D   s        33& &h &u & & & & & &S S S S   4./ -( '	
 
       rO   rA   
Working...TF
   bar.backbar.completebar.finished	bar.pulse皙?sequencedescriptiontotalrI   auto_refreshconsole	transientget_timerefresh_per_secondstylecomplete_stylefinished_stylepulse_stylerE   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.

    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).
        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_finishedrs   r|   r}   r~   r   r   r   )r{   rI   rz   rE   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnrC   track)ry   rz   r{   rI   r|   r}   r~   r   r   r   r   r   r   rE   r   r   columnsrB   s                     rN   r   r   l   sg     T 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edddededd	f
d
Zd-dZde	e
e                  de	e         de	e         dd	fdZdefdZdefdZedefd            ZdefdZdefdZedefd            Zedefd            ZdefdZdefdZdefdZd.dedefdZdeeee f         fdZ!d.dedefdZ"d.d ede#e         fd!Z$d/d"Z%d0d$ed%edefd&Z&defd'Z'd(e(defd)Z)d*e*e(         dd	fd+Z+d	S )1_Readerz9A reader that tracks progress while it's being read from.ThandlerB   rC   taskclose_handlerP   Nc                 L    || _         || _        || _        || _        d| _        d S NF)r   rB   r   r   _closed)rL   r   rB   r   r   s        rN   rK   z_Reader.__init__   s,      	(rO   c                 8    | j                                          | S r[   )r   r_   r^   s    rN   r_   z_Reader.__enter__   s    rO   ra   rb   rc   c                 .    |                                   d S r[   )closerg   s       rN   rh   z_Reader.__exit__   s     	

rO   c                     | S r[    r^   s    rN   __iter__z_Reader.__iter__   s    rO   c                     t          | j                  }| j                            | j        t          |                     |S NrS   )nextr   rB   rS   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   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   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   readrB   rS   r   r   )rL   r   blocks      rN   r   z_Reader.read   s?      &&diU<<<rO   bc                 |    | j                             |          }| j                            | j        |           |S r   )r   readintorB   rS   r   )rL   r   ns      rN   r   z_Reader.readinto   s9    K  ##di333rO   c                     | j                             |          }| j                            | j        t          |                     |S r   )r   readlinerB   rS   r   r   )rL   r   r   s      rN   r   z_Reader.readline  s?    {##D))diT;;;rO   hintc           	          | j                             |          }| j                            | j        t          t          t          |                               |S r   )r   	readlinesrB   rS   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   seekrB   rW   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   sc                      t          d          )Nwriter   )rL   r   s     rN   r   z_Reader.write  s    "7+++rO   r   c                      t          d          )N
writelinesr   )rL   r   s     rN   r   z_Reader.writelines  s    "<000rO   )T)rP   r   )r   ri   )r   ),rj   rk   rl   rm   r   r=   boolrK   r_   r    r$   ro   r   rh   r   bytesr   propertyr   intr   r   strr   r   r   r   r   r   r&   	bytearray
memoryviewr   r   r   r   r   r   r   r   r   r   r   r   r   rO   rN   r   r      sA       CC "   	
  
      4./ -( '	
 
   (    %    
     X$ $ $ $ $$ $ $ $ $  c       X   c       X &$ & & & &&$ & & & &$      e    
%	:t ;<    
 S %    
 c 4;    
   
 3  C    
"c " " " ",s ,s , , , ,1 1$ 1 1 1 1 1 1rO   r   c                   z    e Zd ZdZdddeddfdZdefdZd	eee	                  d
ee	         dee
         ddfdZdS )_ReadContextzEA utility class to handle a context for both a reader and a progress.rB   rC   readerrP   Nc                 "    || _         || _        d S r[   )rB   r   )rL   rB   r   s      rN   rK   z_ReadContext.__init__"  s      rO   c                 f    | j                                          | j                                        S r[   )rB   r]   r   r_   r^   s    rN   r_   z_ReadContext.__enter__&  s*    {$$&&&rO   ra   rb   rc   c                 p    | j                                          | j                            |||           d S r[   )rB   stopr   rh   rg   s       rN   rh   z_ReadContext.__exit__*  s8     	Xw77777rO   )rj   rk   rl   rm   r?   rK   r_   r    r$   ro   r   rh   r   rO   rN   r   r     s        OO! !R !D ! ! ! !'2 ' ' ' '84./8 -(8 '	8
 
8 8 8 8 8 8rO   r   
Reading...)rz   r|   r}   r~   r   r   r   r   r   r   r   filec          
      "   |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   rs   r   )r{   rz   )r   r   r   DownloadColumnr   rC   	wrap_filer   )r   r{   rz   r|   r}   r~   r   r   r   r   r   r   r   r   rB   r   s                   rN   r   r   4  s    J EPW>	?	?@@UW  NN--'	   !!		
   	!-3  H E{KKF&)))rO   r   )r{   rz   r|   r}   r~   r   r   r   r   r   r   r   PathLike[str]r   rtr	bufferingencodingerrorsnewlinec                    d S r[   r   r   r   r   r   r   r   r{   rz   r|   r}   r~   r   r   r   r   r   r   r   s                     rN   openr   u  	    , 	DrO   rbc                    d S r[   r   r   s                     rN   r   r     r   rO   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   rs   r   )r   r   r   r   r   r{   rz   )r   r   r   r   r   rC   r   r   )r   r   r   r   r   r   r{   rz   r|   r}   r~   r   r   r   r   r   r   r   r   rB   r   s                        rN   r   r     s    b EPW>	?	?@@UW  NN--'	   !!		
   	!-3  H ]]  	 	F &)))rO   c                       e Zd ZU dZdZee         ed<   ddee         ddfdZ	defdZ
dd	defd
Zedd	defd            ZdS )ProgressColumnz3Base class for a widget to use in progress display.Nmax_refreshtable_columnrP   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   c                 ,    | j         pt                      S )z.Get a table column, used to build tasks table.)r  r9   r^   s    rN   get_table_columnzProgressColumn.get_table_column  s    !-VXX-rO   r   Taskc                    |                                 }| 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[   )rj   rk   rl   rm   r   r    rn   __annotations__r9   rK   r  r2   r  r   r
  r   rO   rN   r   r     s         ==#'K%'''2 2Xf%5 2 2 2 2 2
.& . . . .V     . 16 1n 1 1 1 ^1 1 1rO   r   c                   R     e Zd ZdZ	 ddddedee         f fdZdd	d
ef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  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.render4  s
    rO   )r  )
rj   rk   rl   rm   r2   r    r9   rK   r
  rp   rq   s   @rN   r  r  '  s          ,.4SW4 4 4(4@H@P4 4 4 4 4 46 n        rO   r  c                        e Zd ZdZ	 	 	 	 	 ddedee         d	ed
edee	         f
 fdZ
	 	 ddedee         d	eddfdZdddef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   speedfinished_textr   c                     t          |||          | _        t          |t                    rt	          j        |          n|| _        t                                          |           d S )Nr   r   r  )	r7   spinner
isinstancer   r;   from_markupr!  rJ   rK   )rL   r  r   r   r!  r   rM   s         rN   rK   zSpinnerColumn.__init__B  sm     |5FFF ---D]+++ 	
 	l33333rO   spinner_stylerP   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.
        r#  N)r7   r$  )rL   r  r'  r   s       rN   set_spinnerzSpinnerColumn.set_spinnerR  s     |=NNNrO   r   r  c                 z    |j         r| j        n+| j                            |                                          }|S r[   )finishedr!  r$  r
  r   )rL   r   texts      rN   r
  zSpinnerColumn.rendera  s=     }6D$$T]]__55 	
 rO   )r  r  r  r  N)r  r  )rj   rk   rl   rm   r   r    r8   rn   r<   r9   rK   r)  r2   r
  rp   rq   s   @rN   r  r  8  s         #%7"%)-4 44 	"4 	4
  4 v&4 4 4 4 4 4& .@	O OO  	*O 	O
 
O O O O6 n        rO   r  c                   t     e Zd ZdZ	 	 	 	 	 ddededed	ed
ee	         dee
         ddf fdZdddefdZ xZS )r   zA column containing text.noneleftTNtext_formatr   justifymarkuphighlighterr   rP   c                     || _         || _        || _        || _        || _        t                                          |pt          d                     d S )NTno_wrapr  )r0  r1  r   r2  r3  rJ   rK   r9   )rL   r0  r   r1  r2  r3  r   rM   s          rN   rK   zTextColumn.__init__m  s[     '&-
&l&JfT6J6J6JKKKKKrO   r   r  c                    | j                             |          }| j        r"t          j        || j        | j                  }nt          || j        | j                  }| j        r| j                            |           |S Nr   )r   r1  )	r0  formatr2  r;   r&  r   r1  r3  	highlight)rL   r   _textr,  s       rN   r
  zTextColumn.render}  s     ''T'22; 	G#ET\RRRDDTZFFFD 	-&&t,,,rO   )r.  r/  TNN)rj   rk   rl   rm   r   r8   r1   r   r    r3   r9   rK   r;   r
  rp   rq   s   @rN   r   r   j  s        ##
 "!'-1)-L LL L 	L
 L k*L v&L 
L L L L L L 6 d        rO   r   c                   v     e Zd ZdZ	 	 	 	 	 	 ddee         d	ed
edededee         ddf fdZddde	f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".
    (   rt   ru   rv   rw   N	bar_widthr   r   r   r   r   rP   c                     || _         || _        || _        || _        || _        t                                          |           d S r  )r?  r   r   r   r   rJ   rK   )rL   r?  r   r   r   r   r   rM   s          rN   rK   zBarColumn.__init__  sL     #
,,&l33333rO   r   r  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   )r6   r{   maxrI   r?  startedr   r   r   r   r   r  s     rN   r
  zBarColumn.render  s    (,
(>#a$$$D!T^,,.0$$c!T^6L6Ll"==??*..(

 

 

 
	
rO   )r>  rt   ru   rv   rw   N)rj   rk   rl   rm   r    r   r8   r9   rK   r6   r
  rp   rq   s   @rN   r   r     s          $&%$2$2!,)-4 4C=4 4 "	4
 "4 4 v&4 
4 4 4 4 4 4 
6 
k 
 
 
 
 
 
 
 
rO   r   c                   "    e Zd ZdZdddefdZdS )TimeElapsedColumnzRenders time elapsed.r   r  rP   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)r+  finished_timeelapsedr;   r	   rE  r   r   )rL   r   rO  deltas       rN   r
  zTimeElapsedColumn.render  sk    (,G$$$4<?	);<<<<#aW"6"6777CJJ&89999rO   Nrj   rk   rl   rm   r;   r
  r   rO   rN   rH  rH    s<        :6 :d : : : : : :rO   rH  c                        e Zd ZdZ	 	 	 	 	 	 	 	 dd	ed
ededededee	         dee
         deddf fdZedee         defd            Zdddef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  r.  r/  TNFr0  text_format_no_percentager   r1  r2  r3  r   r   rP   c	                 r    || _         || _        t                                          ||||||           d S )N)r0  r   r1  r2  r3  r   )rT  r   rJ   rK   )
rL   r0  rT  r   r1  r2  r3  r   r   rM   s
            rN   rK   zTaskProgressColumn.__init__  sR     *C&$##% 	 	
 	
 	
 	
 	
rO   r   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.percentagerL  )r  u   ×10³u   ×10⁶u   ×10⁹u   ×10¹²  z.1fz it/s)r;   r-   pick_unit_and_suffixr   )clsr   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 r8  )r{   r   r]  finished_speedr   rT  r0  r:  r2  r;   r&  r   r1  r3  r;  )rL   r   r0  r<  r,  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   )rS  r  r.  r/  TNNF)rj   rk   rl   rm   r   r8   r1   r   r    r3   r9   rK   classmethodrn   r;   r]  r
  rp   rq   s   @rN   r   r     s#         K)+!!'-1)- 
 

 $'
 	

 
 
 k*
 v&
 
 

 
 
 
 
 
, S% ST S S S [S&6 d        rO   r   c                   X     e Zd ZdZdZ	 	 	 ddededee         f fdZd	d
de	f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   c                 h    || _         || _        t                                          |           d S r  )rc  r   rJ   rK   )rL   rc  r   r   rM   s       rN   rK   zTimeRemainingColumn.__init__  s5     %:"l33333rO   r   r  rP   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.rK  zprogress.remainingNr  rL  z--:--rJ  <   02d:d)	r   r+  rN  time_remainingr{   r;   rc  divmodr   )rL   r   	task_timer   minutesrM  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)rj   rk   rl   rm   r   r   r    r9   rK   r;   r
  rp   rq   s   @rN   r   r     s          K &+)-	4 44  $4 v&	4 4 4 4 4 4,6 ,d , , , , , , , ,rO   r   c                   "    e Zd ZdZdddefdZdS )FileSizeColumnzRenders completed filesize.r   r  rP   c                 p    t          j        t          |j                            }t	          |d          S )Show data completed.zprogress.filesizerL  )r-   decimalr   rI   r;   rL   r   	data_sizes      rN   r
  zFileSizeColumn.render9  s0    $S%8%899	I%89999rO   NrQ  r   rO   rN   rq  rq  6  s<        %%:6 :d : : : : : :rO   rq  c                   "    e Zd ZdZdddefdZdS )TotalFileSizeColumnzRenders total filesize.r   r  rP   c                     |j         &t          j        t          |j                             nd}t	          |d          S )rs  Nr  zprogress.filesize.totalrL  )r{   r-   rt  r   r;   ru  s      rN   r
  zTotalFileSizeColumn.renderB  s;    9=9OH$S__555UW	I%>????rO   NrQ  r   rO   rN   rx  rx  ?  sD        !!@6 @d @ @ @ @ @ @rO   rx  c                   J     e Zd ZdZddedee         f fdZddd	ef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   c                 Z    || _         t                                          |           d S r  )r}  rJ   rK   )rL   r}  r   rM   s      rN   rK   zMofNCompleteColumn.__init__T  s+    "l33333rO   r   r  rP   c                     t          |j                  }|j        t          |j                  nd}t          t	          |                    }t          || d| j         | d          S )zShow completed/total.N?ri  progress.downloadrL  )r   rI   r{   r   r   r;   r}  )rL   r   rI   r{   total_widths        rN   r
  zMofNCompleteColumn.renderX  st    ''	#':#9DJs#e**oo+@@@@@@@%
 
 
 	
rO   )r|  N)rj   rk   rl   rm   r   r    r9   rK   r;   r
  rp   rq   s   @rN   r{  r{  H  s        	 	4 4# 48F;K 4 4 4 4 4 4
6 
d 
 
 
 
 
 
 
 
rO   r{  c                   P     e Zd ZdZ	 ddedee         ddf fdZdd	def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   rP   c                 Z    || _         t                                          |           d S r  )r  rJ   rK   )rL   r  r   rM   s      rN   rK   zDownloadColumn.__init__j  s.     )l33333rO   r   r  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YBrW  r,   r   z,.fr  r|  r  r  rL  )r   rI   r{   r  r-   rX  r;   )rL   r   rI    unit_and_suffix_calculation_baserZ  r[  	precisioncompleted_ratiocompleted_strr{   total_ratio	total_strdownload_statusdownload_texts                 rN   r
  zDownloadColumn.renderp  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)rj   rk   rl   rm   r   r    r9   rK   r;   r
  rp   rq   s   @rN   r   r   c  s          LP4 4 48@8H4	4 4 4 4 4 4!6 !d ! ! ! ! ! ! ! !rO   r   c                   "    e Zd ZdZdddefdZdS )TransferSpeedColumnz&Renders human readable transfer speed.r   r  rP   c                     |j         p|j        }|t          dd          S t          j        t          |                    }t          | dd          S )zShow data transfer speed.Nr  zprogress.data.speedrL  z/s)r_  r   r;   r-   rt  r   )rL   r   r   r\  s       rN   r
  zTransferSpeedColumn.render  s]    #1tz=#89999%c%jj11
z%%%-BCCCCrO   NrQ  r   rO   rN   r  r    sD        00D6 Dd D D D D D DrO   r  c                   *    e Zd ZU dZeed<   	 eed<   dS )ProgressSamplez$Sample of progress for a given time.r  rI   N)rj   rk   rl   rm   rn   r  r   rO   rN   r  r    s3         ..$$rO   r  c                      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          Zeeef         ed<   	  eddd          Zee         ed<   	  eddd          Zee         ed<   	 dZee         ed<   	  ed dd          Zee         ed<    ede          Zeed<   	 defdZedefd            Zedee         fd            Zedee         fd            Zedefd            Zedefd            Z edee         fd            Z!edee         fd            Z"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  rz   r{   rI   	_get_timeNrN  Tvisible)default_factoryfieldsF)defaultinitrepr
start_time	stop_timer_  c                  "    t          d          S )NrW  )maxlenr   r   rO   rN   <lambda>zTask.<lambda>  s    T 2 2 2 rO   )r  r  r  	_progress)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   rF  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   rO  zTask.elapsed  s=     ?"4>%>DO33}}00rO   c                     | j         duS )zCheck if the task has finished.N)rN  r^   s    rN   r+  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   minrE  )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   rB   
total_timeiter_progresstotal_completedr   s         rN   r   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)r+  r   r  r   )rL   r   r  estimates       rN   rj  zTask.time_remaining  sP     = 	3
 	4N	4	E)**rO   c                 T    | j                                          d| _        d| _        dS )zReset progress.N)r  clearrN  r_  r^   s    rN   _resetzTask._reset   s,    !"rO   ri   )$rj   rk   rl   rm   r=   r  r   r    rn   GetTimeCallablerN  r  r   r   dictr  r   r   r  r  r_  r  r   r  r   r  r   r   rF  r  rO  r+  r  r   rj  r  r   rO   rN   r  r    s          	JJJG'E?>*+%)M8E?)))(GTJ"U4888FDcN888?"'%5u"M"M"MJMMMN!&t%e!L!L!LIxLLLN&*NHUO***>',u22U( ( (Iu^$    5eU;;;E5;;; %         + + + + X+ +8E? + + + X+ 1% 1 1 1 X1 .$ . . . X. E    X x    X"     X# # # # # #rO   r  c                   j   e Zd ZdZddddddddddd
deeef         d	ee         d
e	de
de
de	de	de	dee         de	de	ddfdZedeedf         fd            Zedefd            Zedee         fd            Zedee         fd            Zede	fd            ZdTdZdTdZdefdZdeee                  dee         d ee         ddfd!Z	 	 	 	 	 dUd%ee e!         e"e!         f         d&ee
         d'e#d(ee         d)ed*e
de e!         fd+Z$	 dVdd,d-d.e%d&ee#         d(ee         d)ede%f
d/Z&e'j(        	 	 	 	 dWddd,d1d.eed2e)f         d3e*d4         d5e#d6ee         d7ee         d8ee         d&ee#         d(ee         d)ede%fd9            Z+e'j(        	 	 	 	 dWddd,d1d.eed2e)f         d3ee*d:         e*d;         f         d5e#d6ee         d7ee         d8ee         d&ee#         d(ee         d)ede,fd<            Z+	 	 	 	 	 dXddd,d1d.eed2e)f         d3ee*d4         e*d;         e*d:         f         d5e#d6ee         d7ee         d8ee         d&ee#         d(ee         d)edee%e,f         fd=Z+d(eddfd>Z-d(eddfd?Z.ddddddd@d(ed&ee
         d'ee
         dAee
         d)ee         dBee	         dCe	dDe/ddfdEZ0ddd"dddFd(edGe	d&ee
         d'e#dBee	         d)ee         dDe/ddfdHZ1dYd(edAe
ddfdJZ2dTdKZ3de4fdLZ5de e4         fdMZ6dNe e         de7fdOZ8de4fdPZ9	 	 	 	 dZd)edGe	d&ee
         d'e#dBe	dDe/defdRZ:d(eddfdSZ;dS )[rC   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.
    NTrs   g      >@F)
r}   r|   r   speed_estimate_periodr~   redirect_stdoutredirect_stderrr   r   expandr   r}   r|   r   r  r~   r  r  r   r   r  rP   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_indexr5   r.   r  rU   r}   r   printlog)rL   r}   r|   r   r  r~   r  r  r   r   r  r   s               rN   rK   zProgress.__init__7  s     "A%%%'G%%%WW
<$":":"<"<%:"*,#)!99,{}}%1++.
 
 
	 !9DL$9\'
<#rO   .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   )rY  s    rN   r  zProgress.get_default_columns[  s3    2 ABBKK  !!	
 	
rO   c                     | j         j        S r[   )rU   r}   r^   s    rN   r}   zProgress.consolez  s    y  rO   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 	. 	.**,,--	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.   &;??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[   )r+  )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   r+  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)rR   N)r   rU   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)rU   r   r}   is_interactive
is_jupyterr  r^   s    rN   r   zProgress.stop  s[    	|* 	!4<3J 	!L     	! 	! 	! 	!rO   c                 .    |                                   | S r[   r\   r^   s    rN   r_   zProgress.__enter__  r`   rO   ra   rb   rc   c                 .    |                                   d S r[   )r   rg   s       rN   rh   zProgress.__exit__  s     			rO   r   rr   rx   ry   r{   rI   rD   rz   rE   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 )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).
            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,   )
rn   r   add_taskrW   rU   r|   rA   rI   rS   rR   )rL   ry   r{   rI   rD   rz   rE   track_threadvaluerS   rR   s              rN   r   zProgress.track  sb     , =+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   )rD   rz   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  rW   r   )rL   r   r{   rD   rz   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{   rD   rz   r   r   r   r   r   r   r   c                    d S r[   r   
rL   r   r   r   r   r   r   r{   rD   rz   s
             rN   r   zProgress.open  	     	rO   r   r   c                    d S r[   r   r  s
             rN   r   zProgress.open  r  rO   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)brr   r   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  r   )r   Tr  )r   r   )r   r   r   line_buffering)rf   sortedr  warningswarnRuntimeWarningr   st_sizer  rW   ior   r   TextIOWrapper)rL   r   r   r   r   r   r   r{   rD   rz   _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   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   rD   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   rD   r   r  s       rN   	stop_taskzProgress.stop_tasky  s     Z 	* 	*;w'D==??L&".)DN	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   7AAA)r{   rI   rS   rz   r  rR   rS   r  rR   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  rz   r  r  rW   r   r  r  popleftr  appendr  rN  rO  rR   )rL   rD   r{   rI   rS   rz   r  rR   r  r   completed_startupdate_completedr  old_sample_timer  r  s                   rN   rW   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  rz   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  rz   rN  rR   )
rL   rD   r]   r{   rI   r  rz   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   rW  N)r   r  r  rI   r  r  r  r  r   r  r  r{   rN  rO  r   r_  )
rL   rD   rS   r  r   r  r  r  r  r  s
             rN   rS   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   rU   rV   rR   r^   s    rN   rR   zProgress.refresh
  sF    | 	 	 4 	 I	  	  	  	 rO   c                 <    t          |                                  }|S )z*Get a renderable for the progress display.)r0   get_renderables)rL   r  s     rN   r  zProgress.get_renderable  s    D00223
rO   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  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 )Tr5  N)r%  r   r9   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 )r9  N)r%  r   r:  )r  columnr   s     rN   r  z,Progress.make_tasks_table.<locals>.<genexpr>/  sf         #  *&#66.FMMtM444!'	     rO   )r   r:   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   rR   )	rL   rz   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   rD   s     rN   remove_taskzProgress.remove_taskj  sz     Z 	% 	%G$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   	""ri   )Nr   Nrr   rx   r[   r   NNNr   r   NNN)r,   )Tr  r   T)<rj   rk   rl   rm   r&   r   r   r    r/   r   rn   r  rK   r`  r#   r  r   r}   r   r  r  r=   r  r+  r]   r   r+   r_   r$   ro   r   rh   r   r>   r!   r   r   r   r   typingoverloadr   r)   r   r"   r	  r  r   rW   r  rS   rR   r2   r  r  r:   r  r&  r  r*  r   rO   rN   rC   rC   '  s        $ &*!$&'+ $ $.2"$ "$ "$^+,"$ '""$ 	"$
 ""$  %"$ "$ "$ "$ ?+"$ "$ "$ 
"$ "$ "$ "$H 
E.#*=$> 
 
 
 [
< ! ! ! ! X! .tDz . . . X.
 ,$v, , , , X,
 G$ G G G XG* * * *
! ! ! !4    4./ -( '	
 
    "&$('") ).0FFG) ) 	)
 &!) ) ) 
,	) ) ) )\  $(@
 %)'(@ (@ (@(@ }(@
 &!(@ (@ 
(@ (@ (@ (@T _
 "& $!%  $$('  C%/0 dm 	
 3-  # } &!  
   _ _
 "& $!%  $$('  C%/0 GCL'$-/0 	
 3-  # } &!  
   _$ CF"& $!%K  $$('K K KC%/0K GDM74='#,>?K 	K
 3-K K #K }K &!K K 
x	 K K K KZ2& 2T 2 2 2 2* *D * * * *& "&%)#'%)"&; ; ;; 	;
 E?; %; c]; $; ; ; 
; ; ; ;B !%"&%)% % %% 	%
 % % $% c]% % 
% % % %N1 1v 1 1d 1 1 1 1<       
    
.!9    
htn     B). ) ) ) ) !&) )) ) 	)
 ) ) ) 
) ) ) )V%6 %d % % % % % %rO   rC   __main__)Panel)Rule)Syntax)r:   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)typer,  z	Syntax...zGive it a try!)cycle)record)r}   r~   z[red]DownloadingrW  r  z[green]Processingz[yellow]Thinkingrb  r   g333333?g{Gz?d   )rr   Nr   TNFNrs   rt   ru   rv   rw   rx   FTr+  r,  )r  sysr-  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&   version_infor)   pip._vendor.typing_extensionsr+   r  r-   r.   r}   r/   r0   r1   r2   r3  r3   jupyterr4   rU   r5   progress_barr6   r$  r7   r   r8   r  r9   r:   r,  r;   r<   r   r=   r>   rn   r  r?   rA   r   r   r   r   r   r   r.  r   r   r   r  r  r   r   rH  r   r   rq  rx  r{  r   r  r  r  rC   rj   randomtimepanelr0  ruler1  syntaxr2  r#  progress_renderables	itertoolsr=  examplesr  rB   r  task1task2task3r+  rW   sleeprandintr  r   r   rO   rN   <module>r[     s   				 



   # # # # # # # #       ( ( ( ( ( ( ( (       . . . . . . . .                                 * * * * * * * * * *                                             * v555555w222222 # # # # # # # # B B B B B B B B B B B B $ $ $ $ $ $ ! ! ! ! ! !       % % % % % %                                            	3		w~&&2u9% V^D&(++% % % % %6 % % %T $!!%.2 "! . .(!I
 I
H\*H\,BBCI
I
 E?I
 	I

 I
 gI
 I
 xE	*+I
 I
 I
 I
 I
 I
 I
 I
  !I
" l#I
 I
 I
 I
X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 "! . .(>* >* >*
>*>* 	>*
 >* g>* >* xE	*+>* >* >* >* >* >* >* H>* >* >* >*B  " !	  #!%.2 "! . .('	 	 	
_e+
,	
ws|+
,	 	 sm		
 SM	 c]	 C=	 	 	 g	 	 xE	*+	 	 	  !	" #	$ %	& '	( F)	 	 	 	0  " !	  #!%.2 "! . .('	 	 	
_e+
,	
$-	 	 sm		
 SM	 c]	 C=	 	 	 g	 	 xE	*+	 	 	  !	" #	$ %	& '	( H)	 	 	 	4 ?B" !S*  #!%.2 "! . .('S* S* S*
_e+
,S*
wt}gcl:
;S* S* sm	S*
 SMS* c]S* C=S* S* S* gS* S* xE	*+S* S* S*  !S*" #S*$ %S*& 'S*( >(#^F%;;<)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K	% K	% K	% K	% K	%| K	% K	% K	%\ 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   CY!!Y%(Y%