
    ,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j`                  dk\  rd dlm1Z1 nd dl2m1Z1 ej`                  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-eVd.e)e8   d/eVd0e)e g eQf      d1eQd2eGd3eGd4eGd5eGd6eQd7eVd8eVd9e%eP   f"d:ZW G d; d<ee      ZX G d= d>e!eS   e$eS         ZYd?d"dd#dd$d%d&d'd(d#d@dAed+eNd*eUd-eVd.e)e8   d/eVd0e)e g eQf      d1eQd2eGd3eGd4eGd5eGd7eVd9e!e   fdBZZej                  	 	 	 	 ddd?d"dd#dd$d%d&d'd(d#dCdAe/eUdDe\f   dEe/e1dF   e1dG   f   dHeNdIe)eU   dJe)eU   dKe)eU   d+e)eN   d*eUd-eVd.e)e8   d/eVd0e)e g eQf      d1eQd2eGd3eGd4eGd5eGd7eVd9e!e+   f&dL       Z]ej                  	 	 	 	 ddd?d"dd#dd$d%d&d'd(d#dCdAe/eUdDe\f   dEe1dM   dHeNdIe)eU   dJe)eU   dKe)eU   d+e)eN   d*eUd-eVd.e)e8   d/eVd0e)e g eQf      d1eQd2eGd3eGd4eGd5eGd7eVd9e!e   f&dN       Z]	 	 	 	 	 ddd?d"dd#dd$d%d&d'd(d#dCdAe/eUdDe\f   dEe/e1dM   e1dF   e1dG   f   dHeNdIe)eU   dJe)eU   dKe)eU   d+e)eN   d*eUd-eVd.e)e8   d/eVd0e)e g eQf      d1eQd2eGd3eGd4eGd5eGd7eVd9e/e!e   e!e+   f   f&dOZ] G dP dQe      Z^ G dR dSe^      Z_ G dT dUe^      Z` G dV dWe^      Za G dX dYe^      Zb G dZ d[e^      Zc G d\ d]ea      Zd G d^ d_e^      Ze G d` dae^      Zf G db dce^      Zg G dd dee^      Zh G df dge^      Zi G dh die^      Zj G dj dke'      Zke
 G dl dm             Zl G dn doe?      Zmendpk(  rhd dloZod dlpZpddqlqmrZr ddrlsmtZt ddslumvZv ddtlHmJZJ  evdudvd"w      Zu eJdxdydz      ZHeHj                  d{d|d}       d~ erd      deHdddddeu etd      g	Zxd dlymzZz  ezex      Z{ e8d"      Z7 em e`       gemj                          ec       e7d#d5 Z}e}j                  dd      Ze}j                  dd      Ze}j                  dd      Ze}j                  sxe}j                  ed       e}j                  ed        epj                  d        eoj
                  d d      dk  re}j                   ee{             e}j                  sxddd       yy# 1 sw Y   yxY w)    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                   p     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       y )Nr   T)daemon)rB   rD   rE   r   done	completedsuper__init__)selfrB   rD   rE   	__class__s       O/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/rich/progress.pyrK   z_TrackThread.__init__G   s9     *G	%    returnNc                    | j                   }| j                  j                  }| j                  }d}| j                  j
                  } ||      sh| j                  j                  j                  rH| j                  }||k7  r ||||z
         |} ||      s!| j                  j                  j                  rH| j                  j                  | j                   | j                  d       y )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    ,,--''**yy~~}%$--*<*<*G*GI*^!;<!*	 }%$--*<*<*G*G 	T\\T^^TRrO   c                 &    | j                          | S NstartrL   s    rN   	__enter__z_TrackThread.__enter__^       

rO   exc_typeexc_valexc_tbc                 X    | j                   j                          | j                          y 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   sj    3& &h &u &S4./ -( '	
 
rO   rA   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           
   #   ,  K   |rt        d      gng }|j                  t        |	|
||      t        |      t	        d      f       t        ||||||xs d|d}|5  |j                  | ||||      E d	{    d	d	d	       y	7 # 1 sw Y   y	xY ww)
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_finishedrr   rz   r{   r|   r}   r~   r   )ry   rI   rx   rE   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnrC   track)rw   rx   ry   rI   rz   r{   r|   r}   r~   r   r   r   r   rE   r   r   columnsrB   s                     rN   r   r   l   s     T EP>	?@UW  NN--'	 *5d;		
 	!-3H 
 
>>#' " 
 	
 	

 
	

 
s0   ABB8B9B=	B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%d-d!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+y)._Readerz9A reader that tracks progress while it's being read from.handlerB   rC   taskclose_handlerP   Nc                 J    || _         || _        || _        || _        d| _        y NF)r   rB   r   r   _closed)rL   r   rB   r   r   s        rN   rK   z_Reader.__init__   s(      	(rO   c                 :    | j                   j                          | S r[   )r   r_   r^   s    rN   r_   z_Reader.__enter__   s    rO   ra   rb   rc   c                 $    | j                          y 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                  | j                  t        |             |S NrS   )nextr   rB   rS   r   len)rL   lines     rN   __next__z_Reader.__next__   s4    DKK diiT;rO   c                     | j                   S r[   )r   r^   s    rN   closedz_Reader.closed   s    ||rO   c                 6    | j                   j                         S r[   )r   filenor^   s    rN   r   z_Reader.fileno       {{!!##rO   c                 6    | j                   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                 6    | j                   j                         S r[   )r   readabler^   s    rN   r   z_Reader.readable       {{##%%rO   c                 6    | j                   j                         S r[   )r   seekabler^   s    rN   r   z_Reader.seekable   r   rO   c                      yr   r   r^   s    rN   writablez_Reader.writable   s    rO   sizec                     | j                   j                  |      }| j                  j                  | j                  t        |             |S r   )r   readrB   rS   r   r   )rL   r   blocks      rN   r   z_Reader.read   s:      &diiU<rO   bc                     | j                   j                  |      }| j                  j                  | j                  |       |S r   )r   readintorB   rS   r   )rL   r   ns      rN   r   z_Reader.readinto   s6    KK  #dii3rO   c                     | j                   j                  |      }| j                  j                  | j                  t        |             |S r   )r   readlinerB   rS   r   r   )rL   r   r   s      rN   r   z_Reader.readline  s:    {{##D)diiT;rO   hintc           	          | j                   j                  |      }| j                  j                  | j                  t        t        t        |                   |S r   )r   	readlinesrB   rS   r   summapr   )rL   r   liness      rN   r   z_Reader.readlines  sA    %%d+diiSe_1EFrO   c                 ^    | j                   r| j                  j                          d| _        y )NT)r   r   r   r   r^   s    rN   r   z_Reader.close  s"    KKrO   offsetwhencec                     | j                   j                  ||      }| j                  j                  | j                  |       |S )NrI   )r   seekrB   rW   r   )rL   r   r   poss       rN   r   z_Reader.seek  s8    kkvv.TYY#6
rO   c                 6    | j                   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0rO   )T)rP   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      s   C "  	
  
4./ -( '	
 
( % 
   $ $$ $  c      c    &$ &&$ &$  e 
%	:t ;< 
S % 
c 4; 

3  C 
"c ",s ,s ,1 1$ 1rO   r   c                   `    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y)_ReadContextzEA utility class to handle a context for both a reader and a progress.rB   rC   readerrP   Nc                      || _         || _        y r[   )rB   r   )rL   rB   r   s      rN   rK   z_ReadContext.__init__"  s      rO   c                 j    | j                   j                          | j                  j                         S r[   )rB   r]   r   r_   r^   s    rN   r_   z_ReadContext.__enter__&  s%    {{$$&&rO   ra   rb   rc   c                 r    | j                   j                          | j                  j                  |||       y r[   )rB   stopr   rh   rg   s       rN   rh   z_ReadContext.__exit__*  s*     	Xw7rO   )rj   rk   rl   rm   r?   rK   r_   r    r$   ro   r   rh   r   rO   rN   r   r     sj    O! !R !D !'2 '84./8 -(8 '	8
 
8rO   r   
Reading...)rx   rz   r{   r|   r}   r~   r   r   r   r   r   filec          
          |rt        d      gng }|j                  t        ||	|
|      t               t	               f       t        ||||||xs d|d}|j                  | ||      }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   rr   r   )ry   rx   )r   r   r   DownloadColumnr   rC   	wrap_filer   )r   ry   rx   rz   r{   r|   r}   r~   r   r   r   r   r   r   rB   r   s                   rN   r   r   4  s    J EP>	?@UW  NN--'	 !		
 	!-3H E{KF&))rO   )ry   rx   rz   r{   r|   r}   r~   r   r   r   r   r   PathLike[str]r   rtr	bufferingencodingerrorsnewlinec                     y r[   r   r   r   r   r   r   r   ry   rx   rz   r{   r|   r}   r~   r   r   r   r   r   s                     rN   openr   u      , 	rO   rbc                     y r[   r   r   s                     rN   r   r     r   rO   c          
          |rt        d      gng }|j                  t        ||||      t               t	               f       t        |||	|
||xs d|d}|j                  | |||||||      }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   rr   r   )r   r   r   r   r   ry   rx   )r   r   r   r   r   rC   r   r   )r   r   r   r   r   r   ry   rx   rz   r{   r|   r}   r~   r   r   r   r   r   r   rB   r   s                        rN   r   r     s    b EP>	?@UW  NN--'	 !		
 	!-3H ]]  	F &))rO   c                   t    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y)ProgressColumnz3Base class for a widget to use in progress display.Nmax_refreshtable_columnrP   c                 .    || _         i | _        d | _        y r[   )_table_column_renderable_cache_update_time)rL   r   s     rN   rK   zProgressColumn.__init__  s    )MO-1rO   c                 2    | j                   xs
 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    !!-VX-rO   r   Taskc                 .   |j                         }| j                  =|j                  s1	 | j                  |j                     \  }}|| j                  z   |kD  r|S | j                  |      }||f| j                  |j                  <   |S # t
        $ r Y 9w xY w)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     }}'&(,(>(>tww(G%	: t///,>%%[[&
+7*Dtww'  s   B 	BBc                      y)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     sl    =#'K%'2Xf%5 2 2
.& .V  . 16 1n 1 1rO   r   c                   L     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                4    || _         t        | 	  |       y Nr  )r  rJ   rK   )rL   r  r   rM   s      rN   rK   zRenderableColumn.__init__.  s     %l3rO   r   r  rP   c                     | j                   S r[   )r  r  s     rN   r  zRenderableColumn.render4  s    rO   ) )
rj   rk   rl   rm   r2   r    r9   rK   r  rp   rq   s   @rN   r  r  '  sB     ,.4SW4(4@H@P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 " ".
    Nspinner_namer   speedfinished_textr   c                     t        |||      | _        t        |t              rt	        j
                  |      n|| _        t        | !  |       y )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  sN     |5F -- ]+ 	
 	l3rO   spinner_stylerP   c                 *    t        |||      | _        y)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rO   r   r  c                     |j                   r| j                  }|S | j                  j                  |j	                               }|S r[   )finishedr  r  r  r}   )rL   r   texts      rN   r  zSpinnerColumn.rendera  sH     }}  	
  $$T]]_5 	
 rO   )dotsprogress.spinner      ? 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 v&4& .@	OO  	*O 	O
 
O6 n rO   r  c                   h     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.Ntext_formatr   justifymarkuphighlighterr   rP   c                     || _         || _        || _        || _        || _        t
        |   |xs t        d             y )NTno_wrapr  )r,  r-  r   r.  r/  rJ   rK   r9   )rL   r,  r   r-  r.  r/  r   rM   s          rN   rK   zTextColumn.__init__m  sD     '&-
&l&JfT6JKrO   r   r  c                 B   | j                   j                  |      }| j                  r-t        j                  || j
                  | j                        }n"t        || j
                  | j                        }| j                  r| j                  j                  |       |S Nr   )r   r-  )	r,  formatr.  r;   r   r   r-  r/  	highlight)rL   r   _textr&  s       rN   r  zTextColumn.render}  sv      ''T'2;;##ET\\RDTZZFD&&t,rO   )noneleftTNN)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 k*L v&L 
L 6 d rO   r   c                   j     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".
    N	bar_widthr   r   r   r   r   rP   c                 l    || _         || _        || _        || _        || _        t
        |   |       y r  )r<  r   r   r   r   rJ   rK   )rL   r<  r   r   r   r   r   rM   s          rN   rK   zBarColumn.__init__  s;     #
,,&l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                  | j                  	      S )z&Gets a progress bar widget for a task.Nr   r,   )	ry   rI   widthpulseanimation_timer   r   r   r   )r6   ry   maxrI   r<  startedr}   r   r   r   r   r  s     rN   r  zBarColumn.render  s    (,

(>#a$D!T^^,..0$c!T^^6Lll"==?**....((

 
	
rO   )(   rs   rt   ru   rv   N)rj   rk   rl   rm   r    r   r8   r9   rK   r6   r  rp   rq   s   @rN   r   r     s     $&%$2$2!,)-4C=4 4 "	4
 "4 4 v&4 
4 
6 
k 
rO   r   c                        e Zd ZdZdddefdZy)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.-:--:--progress.elapsedr   r   )seconds)r%  finished_timeelapsedr;   r	   rB  r   r   )rL   r   rM  deltas       rN   r  zTimeElapsedColumn.render  sS    (,$$$4<<?	);<<#aW"67CJ&899rO   Nrj   rk   rl   rm   r;   r  r   rO   rN   rF  rF    s    :6 :d :rO   rF  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.
    Nr,  text_format_no_percentager   r-  r.  r/  r   r   rP   c	                 L    || _         || _        t        	|   ||||||       y )N)r,  r   r-  r.  r/  r   )rQ  r   rJ   rK   )
rL   r,  rQ  r   r-  r.  r/  r   r   rM   s
            rN   rK   zTaskProgressColumn.__init__  s9     *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.
        r  zprogress.percentagerJ  )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  s_     ="78844J<
f
 T\
z#&vhe4<QRRrO   r   r  c                    |j                   5| j                  r)| j                  |j                  xs |j                        S |j                   | j
                  n| j                  }|j                  |      }| j                  r-t        j                  || j                  | j                        }n"t        || j                  | j                        }| j                  r| j                  j                  |       |S r4  )ry   r   rZ  finished_speedr  rQ  r,  r6  r.  r;   r   r   r-  r/  r7  )rL   r   r,  r8  r&  s        rN   r  zTaskProgressColumn.render  s    ::$//$$T%8%8%FDJJGG.2jj.@D**dFVFV 	 """-;;##ET\\RDTZZFD&&t,rO   )z-[progress.percentage]{task.percentage:>3.0f}%r  r9  r:  TNNF)rj   rk   rl   rm   r   r8   r1   r   r    r3   r9   rK   classmethodrn   r;   rZ  r  rp   rq   s   @rN   r   r     s     K)+!!'-1)- 

 $'
 	

 
 
 k*
 v&
 
 

, S% ST S S&6 d rO   r   c                   R     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.
          ?compactr   r   c                 B    || _         || _        t        |   |       y r  )r`  r   rJ   rK   )rL   r`  r   r   rM   s       rN   rK   zTimeRemainingColumn.__init__  s$     %:"l3rO   r   r  rP   c                    | j                   r|j                  r|j                  }d}n|j                  }d}|j                  t        d|      S |!t        | j                  rd|      S 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.rI  zprogress.remainingr  rJ  z--:--rH  <   02d:d)	r   r%  rL  time_remainingry   r;   r`  divmodr   )rL   r   	task_timer   minutesrK  hours	formatteds           rN   r  zTimeRemainingColumn.render  s    %%$--**I&E++I(E::%((4<<eLLYeLL "#i."5,w<<"3-q6I )1WSM73-@IIU++rO   )FFN)rj   rk   rl   rm   r   r   r    r9   rK   r;   r  rp   rq   s   @rN   r   r     sS     K &+)-	44  $4 v&	4,6 ,d ,rO   r   c                        e Zd ZdZdddefdZy)FileSizeColumnzRenders completed filesize.r   r  rP   c                 l    t        j                  t        |j                              }t	        |d      S )Show data completed.zprogress.filesizerJ  )r-   decimalr   rI   r;   rL   r   	data_sizes      rN   r  zFileSizeColumn.render9  s)    $$S%89	I%899rO   NrO  r   rO   rN   rn  rn  6  s    %:6 :d :rO   rn  c                        e Zd ZdZdddefdZy)TotalFileSizeColumnzRenders total filesize.r   r  rP   c                     |j                   (t        j                  t        |j                               nd}t	        |d      S )rp  r  zprogress.filesize.totalrJ  )ry   r-   rq  r   r;   rr  s      rN   r  zTotalFileSizeColumn.renderB  s4    9=9OH$$S_5UW	I%>??rO   NrO  r   rO   rN   ru  ru  ?  s    !@6 @d @rO   ru  c                   D     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 "/".
    	separatorr   c                 4    || _         t        | 	  |       y r  )ry  rJ   rK   )rL   ry  r   rM   s      rN   rK   zMofNCompleteColumn.__init__T  s    "l3rO   r   r  rP   c                     t        |j                        }|j                  t        |j                        nd}t        t	        |            }t        || d| j                   | d      S )zShow completed/total.?rf  progress.downloadrJ  )r   rI   ry   r   r   r;   ry  )rL   r   rI   ry   total_widths        rN   r  zMofNCompleteColumn.renderX  sc    '	#'::#9DJJs#e*o+a((8@%
 	
rO   )/N)rj   rk   rl   rm   r   r    r9   rK   r;   r  rp   rq   s   @rN   rx  rx  H  s3    	4# 48F;K 4
6 
d 
rO   rx  c                   J     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.
    Nbinary_unitsr   rP   c                 4    || _         t        | 	  |       y r  )r  rJ   rK   )rL   r  r   rM   s      rN   rK   zDownloadColumn.__init__j  s     )l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.)	r   KiBMiBGiBTiBPiBEiBZiBYiBi   )	r   kBMBGBTBPBEBZBYBrT  r,   r   z,.fr|  r  r*  r}  rJ  )r   rI   ry   r  r-   rU  r;   )rL   r   rI    unit_and_suffix_calculation_baserW  rX  	precisioncompleted_ratiocompleted_strry   total_ratio	total_strdownload_statusdownload_texts                 rN   r  zDownloadColumn.renderp  s    '	  $zz5C

O9 	) #880QLD& $880ILD&
 A	#d**2i[/:::!

OE$,K&r)Ao6II*O1YKqA_4GHrO   )FN)rj   rk   rl   rm   r   r    r9   rK   r;   r  rp   rq   s   @rN   r   r   c  sD     LP4 48@8H4	4!6 !d !rO   r   c                        e Zd ZdZdddefdZy)TransferSpeedColumnz&Renders human readable transfer speed.r   r  rP   c                     |j                   xs |j                  }|t        dd      S t        j                  t        |            }t        | dd      S )zShow data transfer speed.r|  zprogress.data.speedrJ  z/s)r\  r  r;   r-   rq  r   )rL   r   r  rY  s       rN   r  zTransferSpeedColumn.render  sR    ##1tzz=#899%%c%j1
zl"%-BCCrO   NrO  r   rO   rN   r  r    s    0D6 Dd DrO   r  c                   (    e Zd ZU dZeed<   	 eed<   y)ProgressSamplez$Sample of progress for a given time.r
  rI   N)rj   rk   rl   rm   rn   r  r   rO   rN   r  r    s    .$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#y)"r  zInformation regarding a progress task.

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

    r  rx   ry   rI   	_get_timeNrL  Tvisible)default_factoryfieldsF)defaultinitrepr
start_time	stop_timer\  c                      t        d      S )NrT  )maxlenr   r   rO   rN   <lambda>zTask.<lambda>  s    T 2 rO   )r  r  r  	_progress)r  r  _lockrP   c                 "    | j                         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   rC  zTask.started  s     d**rO   c                 N    | j                   y| j                   | j                  z
  S )zPOptional[float]: Get the number of steps remaining, if a non-None total was set.Nry   rI   r^   s    rN   	remainingzTask.remaining  s$     ::zzDNN**rO   c                     | j                   y| j                  | j                  | j                   z
  S | j                         | 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   rM  zTask.elapsed  sC     ??">>%>>DOO33}}00rO   c                     | j                   duS )zCheck if the task has finished.N)rL  r^   s    rN   r%  zTask.finished  s     !!--rO   c                     | j                   sy| 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@)ry   rI   minrB  )rL   rI   s     rN   
percentagezTask.percentage  s>     zz^^djj0E9	s3	23	rO   c                 J   | j                   y| j                  5  | j                  }|s
	 ddd       y|d   j                  |d   j                  z
  }|dk(  r
	 ddd       yt	        |      }t        |       t        d |D              }||z  }|cddd       S # 1 sw Y   yxY w)z=Optional[float]: Get the estimated speed in steps per second.Nr   r   c              3   4   K   | ]  }|j                     y wr[   r   ).0samples     rN   	<genexpr>zTask.speed.<locals>.<genexpr>  s     !Ov&"2"2!O   )r  r  r  r
  iterr   r   )rL   rB   
total_timeiter_progresstotal_completedr  s         rN   r  z
Task.speed   s     ??"ZZ 	~~H	 	 ""//(1+2G2GGJQ	 	 !NM!!O!OOO#j0E	 	 	s   B%B!.BB"c                 x    | j                   ry| j                  }|sy| j                  }|y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   rg  zTask.time_remaining  sC     ==

NN		E)*rO   c                 T    | j                   j                          d| _        d| _        y)zReset progress.N)r  clearrL  r\  r^   s    rN   _resetzTask._reset   s"    !"rO   ri   )$rj   rk   rl   rm   r=   r  r   r    rn   GetTimeCallablerL  r  r   r   dictr  r   r   r  r  r\  r  r   r  r   r  r}   r   rC  r  rM  r%  r  r  rg  r  r   rO   rN   r  r    s    	JG'E?>*+%)M8E?)(GTJ"48FDcN8?"'5u"MJMN!&t%e!LIxLN&*NHUO*>',2U(Iu^$  eU;E5; %   + + + +8E? + + 1% 1 1 .$ . . E   x  "   #rO   r  c                      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dOdZdOdZdefdZdeee      dee   d ee   ddfd!Z	 	 	 	 	 dPd#ee e!   e"e!   f   d$ee
   d%e#d&ee   d'ed(e
de e!   fd)Z$	 dQdd*d+d,e%d$ee#   d&ee   d'ede%f
d-Z&e'jP                  	 	 	 	 dRddd*d.d,eed/e)f   d0e*d1   d2e#d3ee   d4ee   d5ee   d$ee#   d&ee   d'ede%fd6       Z+e'jP                  	 	 	 	 dRddd*d.d,eed/e)f   d0ee*d7   e*d8   f   d2e#d3ee   d4ee   d5ee   d$ee#   d&ee   d'ede,fd9       Z+	 	 	 	 	 dSddd*d.d,eed/e)f   d0ee*d1   e*d8   e*d7   f   d2e#d3ee   d4ee   d5e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
   d>ee
   d'ee   d?ee	   d@e	dAe/ddfdBZ0ddd"dddCd&edDe	d$ee
   d%e#d?ee	   d'ee   dAe/ddfdEZ1dTd&ed>e
ddfdFZ2dOdGZ3de4fdHZ5de e4   fdIZ6dJe e   de7fdKZ8de4fdLZ9	 	 	 	 dUd'edDe	d$ee
   d%e#d?e	dAe/defdMZ:d&eddfdNZ;y)VrC   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.
    NTrr   g      >@F)
r{   rz   r~   speed_estimate_periodr|   redirect_stdoutredirect_stderrr}   r   expandr   r{   rz   r~   r  r|   r  r  r}   r   r  rP   c       
   	         |dkD  sJ d       t               | _        |xs | j                         | _        || _        |	| _        |
| _        i | _        t        d      | _	        t        |xs
 t               |||||| j                        | _        |xs | j                  j                  | _        | j                  j                   | _        | j                  j"                  | _        y )Nr   zrefresh_per_second must be > 0)r{   rz   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{   rz   r~   r  r|   r  r  r}   r   r  r   s               rN   rK   zProgress.__init__7  s     "A%G'GGW
<$":":"<%:"*,#)!9,{}%1++..
	 !9DLL$9$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   )rV  s    rN   r  zProgress.get_default_columns[  s(    2 ABK !	
 	
rO   c                 .    | j                   j                  S r[   )rU   r{   r^   s    rN   r{   zProgress.consolez  s    yy   rO   c                     | j                   5  t        | j                  j                               cddd       S # 1 sw Y   yxY w)zGet a list of Task instances.N)r  listr  valuesr^   s    rN   taskszProgress.tasks~  s5     ZZ 	.**,-	. 	. 	.	   #:Ac                     | j                   5  t        | j                  j                               cddd       S # 1 sw Y   yxY w)zA list of task IDs.N)r  r  r  keysr^   s    rN   task_idszProgress.task_ids  s5     ZZ 	,((*+	, 	, 	,r  c                     | j                   5  | j                  s
	 ddd       yt        d | j                  j                         D              cddd       S # 1 sw Y   yxY w)z'Check if all tasks have been completed.NTc              3   4   K   | ]  }|j                     y wr[   )r%  )r  r   s     rN   r  z$Progress.finished.<locals>.<genexpr>  s     Ft}}Fr  )r  r  allr  r^   s    rN   r%  zProgress.finished  sW     ZZ 	G;;	G 	G F1C1C1EFF	G 	G 	Gs   A)AA c                 V    | j                   s| j                  j                  d       yy)zStart the progress display.T)rR   N)r   rU   r]   r^   s    rN   r]   zProgress.start  s     ||IIOODO) rO   c                     | j                   j                          | j                  j                  s2| j                  j                  s| j                  j                          yyy)zStop the progress display.N)rU   r   r{   is_interactive
is_jupyterr  r^   s    rN   r   zProgress.stop  sB    		||**4<<3J3JLL  4K*rO   c                 &    | j                          | S r[   r\   r^   s    rN   r_   zProgress.__enter__  r`   rO   ra   rb   rc   c                 $    | j                          y r[   )r   rg   s       rN   rh   zProgress.__exit__  s     			rO   r   rw   ry   rI   rD   rx   rE   c              #     K   |t        t        |            xs d}|| j                  |||      }n| j                  |||       | j                  j
                  r8t        | ||      5 }|D ]  }| |xj                  dz  c_         	 ddd       y| j                  }	| j                  }
|D ]  }|  |	|d        |
         y# 1 sw Y   yxY ww)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   rz   rA   rI   rS   rR   )rL   rw   ry   rI   rD   rx   rE   track_threadvaluerS   rR   s              rN   r   zProgress.track  s     , =+h/08DE?mmKu	mRGKKu	KB99!!dG]; 0|% 0EK **a/*00 0
 llGllG! #	0 0s   A)C+!C
=C
CCr   )rD   rx   r   c                   d}||}n0|.| j                   5  | j                  |   j                  }ddd       |t        d      || j	                  ||      }n| j                  ||       t        || |d      S # 1 sw Y   NxY w)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'ry   Fr   )r  r  ry   
ValueErrorr  rW   r   )rL   r   ry   rD   rx   total_bytess         rN   r   zProgress.wrap_file  s    . (,K  9"kk'2889Q 
 ?mmK{mCGKK{K3tT7??9 9s   A==B)ry   rD   rx   r   r   r   r   r   r   r   c                     y r[   r   
rL   r   r   r   r   r   r   ry   rD   rx   s
             rN   r   zProgress.open       	rO   r   r   c                     y r[   r   r  s
             rN   r   zProgress.open  r  rO   c                   dj                  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                  }|| j                  |	|      }n| j                  ||       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/Or  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   ry   rD   rx   _moder  r   r   s                 rN   r   zProgress.open  s#   B tU34))}TH566 #aD=Y!^MMs Ik!A~ !ABBa	 =J&&E ?mmKum=GKKuK- ty9wTB ;##!-  rO   c                     | j                   5  | j                  |   }|j                  | j                         |_        ddd       y# 1 sw Y   yxY w)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  sE     ZZ 	2;;w'D&"&--/	2 	2 	2s   1AAc                     | j                   5  | j                  |   }| j                         }|j                  ||_        ||_        ddd       y# 1 sw Y   yxY w)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  sQ     ZZ 	*;;w'D==?L&".)DN	* 	* 	*s   :AA)ry   rI   rS   rx   r  rR   rS   r  rR   r  c                <   | j                   5  | j                  |   }	|	j                  }
|&||	j                  k7  r||	_        |	j	                          ||	xj                  |z  c_        |||	_        |||	_        |||	_        |	j                  j                  |       |	j                  |
z
  }| j                         }|| j                  z
  }|	j                  }|j                  }|r.|d   j                  |k  r |        |r|d   j                  |k  r|dkD  r|j                  t        ||             |	j                  6|	j                  |	j                  k\  r|	j                   |	j"                  |	_        ddd       |r| j%                          yy# 1 sw Y   xY w)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   ry   r  rx   r  r  rW   r}   r  r  popleftr
  appendr  rL  rM  rR   )rL   rD   ry   rI   rS   rx   r  rR   r  r   completed_startupdate_completedr	  old_sample_timer  r  s                   rN   rW   zProgress.update  sy   0 ZZ  	2;;w'D"nnO Udjj%8"
"')$!*&#. "&KKv&#~~?==?L*T-G-GGOI''G	! 6 6 H	 	! 6 6 H!#  >N!OP

&NNdjj0&&.%)\\"A 	2D LLN E 	2  	2s   DFA"FF)r]   ry   rI   r  rx   r]   c                >   | j                         }| j                  5  | j                  |   }	|	j                          |r|nd|	_        |||	_        ||	_        |||	_        |r||	_        |||	_	        d|	_
        ddd       | j                          y# 1 sw Y   xY w)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  ry   rI   r  r  rx   rL  rR   )
rL   rD   r]   ry   rI   r  rx   r  r	  r   s
             rN   resetzProgress.reset  s    , }}ZZ 	&;;w'DKKM.3lDO "
&DN"&$&#. !%D	& 		& 	&s   ABBc                    | j                         }| j                  5  | j                  |   }|j                  }|xj                  |z  c_        |j                  |z
  }|| j                  z
  }|j
                  }|j                  }	|r.|d   j                  |k  r |	        |r|d   j                  |k  rt        |      dkD  r |	        t        |      dkD  r|j                  t        ||             |j                  G|j                  |j                  k\  r.|j                  "|j                  |_        |j                  |_        ddd       y# 1 sw Y   yxY w)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   rT  N)r}   r  r  rI   r  r  r  r
  r   r  r  ry   rL  rM  r  r\  )
rL   rD   rS   r	  r   r  r  r  r  r  s
             rN   rS   zProgress.advance  s%    }}ZZ 	1;;w'D"nnONNg%N#~~?*T-G-GGOI''G	! 6 6 H	 	! 6 6 Hi.4'	 i.4'^L:JKL

&NNdjj0&&.%)\\"&*jj#)	1 	1 	1s   BE4#EA.EEc                     | j                   s2| j                  j                  r| j                  j                          yyy)z*Refresh (render) the progress information.N)r   rU   rV   rR   r^   s    rN   rR   zProgress.refresh
  s,    ||		 4 4II !5|rO   c                 2    t        | j                          }|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3
rO   c              #   J   K   | j                  | j                        }| yw)z5Get a number of renderables for the progress display.N)make_tasks_tabler  )rL   tables     rN   r  zProgress.get_renderables  s     %%djj1s   !#r  c                     d | j                   D        }t        j                  |d| j                  d}|D ]1  j                  s |j
                  fd| j                   D          3 |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   | ]>  }t        |t              rt        d       n|j                         j	                          @ yw)Tr1  N)r  r   r9   r  copy)r  _columns     rN   r  z,Progress.make_tasks_table.<locals>.<genexpr>"  sE      
  gs+ t$--/4467
s   AA)r   r,   )paddingr  c              3   r   K   | ].  }t        |t              r|j                         n |       0 yw)r5  N)r  r   r6  )r  columnr   s     rN   r  z,Progress.make_tasks_table.<locals>.<genexpr>/  s>       #  *&#6 #MMtM4!'.s   47)r   r:   gridr  r  add_row)rL   r  table_columnsr  r   s       @rN   r  zProgress.make_tasks_table  sn    
  <<
 

M6$++N 	D|| '+ll		 rO   c                 f    | j                   5  | j                         cddd       S # 1 sw Y   yxY w)z+Makes the Progress class itself renderable.N)r  r  r^   s    rN   __rich__zProgress.__rich__:  s*    ZZ 	)&&(	) 	) 	)s   '0c                    | j                   5  t        | j                  |||||| j                  | j                         }|| j                  | j                  <   |r| j                  | j                         | j                  }t        t        | j                        dz         | _        ddd       | j                          S # 1 sw Y   xY w)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   rx   r]   ry   rI   r  r  r   new_task_indexs	            rN   r  zProgress.add_task?  s    0 ZZ 	A  --jj	D -1DKK(() 0 01!--N%c$*:*:&;a&?@D	A  	#	A 	As   BCC
c                 `    | j                   5  | j                  |= ddd       y# 1 sw Y   yxY w)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  s,     ZZ 	%G$	% 	% 	%s   $-ri   )Nr   N
Working...皙?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.#*=$> 
 
< ! ! ! .tDz . .
 ,$v, , ,
 G$ G G*
!4 4./ -( '	
 
 "&$('").0FFG) ) 	)
 &!) ) ) 
,	)\  $(@
 %)'(@(@ }(@
 &!(@ (@ 
(@T __
 "& $!%  $$('C%/0 dm 	
 3-  # } &!  
  __
 "& $!%  $$('C%/0 GCL'$-/0 	
 3-  # } &!  
 $ CF"& $!%K  $$('KC%/0K GDM74='#,>?K 	K
 3-K K #K }K &!K K 
x	 KZ2& 2T 2* *D *& "&%)#'%)"&;; 	;
 E?; %; c]; $; ; ; 
;B !%"&%)%% 	%
 % % $% c]% % 
%N1v 1 1d 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]DownloadingrT  r  z[green]Processingz[yellow]Thinkingr_  r   g333333?g{Gz?d   )r)  Nr   TNFNrr   rs   rt   ru   rv   r*  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)   typing_extensionsr+   r  r-   r.   r{   r/   r0   r1   r2   r/  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   rF  r   r   rn  ru  rx  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)w& # B B $ !  %      	3	~&2u9% V^^D&(+%6 %T $!!%.2 "! . .(!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
Xd1i d1N8>"%wr{ 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*
_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*l'1S '1T~ "/N /d <'
 '
T	: 	:E EP-,. -,`:^ :@. @
 
6.^ .b	D. 	D%Z % z# z# z#zK	%| K	%\ z
	" 	F  %&E	MM#sC  	E89'&$45
  )*HT"G	
		%	%	'
 	
 
 - 
!!"4D!A!!"5T!B!!"4D!A##OOE3O/OOE3O/DJJtv~~a%)T(^, ##- -] \- -s   B>U''U0