
    *,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 ddl3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZD ddlEmFZF ddlGmHZHmIZI ddlJmKZKmLZL  e(deM      ZN e.d      ZOe g ePf   ZQ ej\                  de+e      ZR G d de      ZS	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd'e/e*eO   e%eO   f   d(eTd)e)eP   d*eUd+e)e7   d,eUd-e)e g ePf      d.ePd/eFd0eFd1eFd2eFd3ePd4eUd5eUd6e%eO   f d7ZV G d8 d9ee      ZW G d: d;e!eR   e$eR         ZXd<d dd!dd"d#d$d%d&d!d=d>ed)eMd(eTd*eUd+e)e7   d,eUd-e)e g ePf      d.ePd/eFd0eFd1eFd2eFd4eUd6e!e   fd?ZYej                  	 	 	 	 ddd<d dd!dd"d#d$d%d&d!d@d>e/eTdAe[f   dBe/e1dC   e1dD   f   dEeMdFe)eT   dGe)eT   dHe)eT   d)e)eM   d(eTd*eUd+e)e7   d,eUd-e)e g ePf      d.ePd/eFd0eFd1eFd2eFd4eUd6e!e+   f&dI       Z\ej                  	 	 	 	 ddd<d dd!dd"d#d$d%d&d!d@d>e/eTdAe[f   dBe1dJ   dEeMdFe)eT   dGe)eT   dHe)eT   d)e)eM   d(eTd*eUd+e)e7   d,eUd-e)e g ePf      d.ePd/eFd0eFd1eFd2eFd4eUd6e!e   f&dK       Z\	 	 	 	 	 ddd<d dd!dd"d#d$d%d&d!d@d>e/eTdAe[f   dBe/e1dJ   e1dC   e1dD   f   dEeMdFe)eT   dGe)eT   dHe)eT   d)e)eM   d(eTd*eUd+e)e7   d,eUd-e)e g ePf      d.ePd/eFd0eFd1eFd2eFd4eUd6e/e!e   e!e+   f   f&dLZ\ G dM dNe      Z] G dO dPe]      Z^ G dQ dRe]      Z_ G dS dTe]      Z` G dU dVe]      Za G dW dXe]      Zb G dY dZe`      Zc G d[ d\e]      Zd G d] d^e]      Ze G d_ d`e]      Zf G da dbe]      Zg G dc dde]      Zh G de dfe]      Zi G dg dhe'      Zje
 G di dj             Zk G dk dle>      Zlemdmk(  rhd dlnZnd dloZoddnlpmqZq ddolrmsZs ddpltmuZu ddqlGmIZI  eudrdsd t      Zt eIdudvdw      ZGeGj                  dxdydz       d{ eqd|      d}eGd~ddddet esd      g	Zwd dlxmyZy  eyew      Zz e7d       Z6 el e_       gelj                          eb       e6d!d5 Z|e|j                  dd      Z~e|j                  dd      Ze|j                  dd      Ze|j                  sxe|j                  e~d       e|j                  ed        eoj                  d        enj                  d d      dk  re|j                   eez             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   )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                 x    || _         || _        || _        t               | _        d| _        t        |           y )Nr   )r@   rB   rC   r   done	completedsuper__init__)selfr@   rB   rC   	__class__s       [/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pip/_vendor/rich/progress.pyrH   z_TrackThread.__init__B   s4     *G	    returnNc                 T   | j                   }| j                  j                  }| j                  }d}| j                  j
                  } ||      s(| j                  }||k7  r ||||z
         |} ||      s(| j                  j                  | j                   | j                  d       y )Nr   T)rF   refresh)rB   r@   advancerC   rE   waitrF   update)rI   rB   rP   rC   last_completedrQ   rF   s          rK   runz_TrackThread.runK   s    ,,--''**yy~~}%I*^!;<!*	 }% 	T\\T^^TRrL   c                 &    | j                          | S NstartrI   s    rK   	__enter__z_TrackThread.__enter__Y       

rL   exc_typeexc_valexc_tbc                 X    | j                   j                          | j                          y rV   )rE   setjoinrI   r\   r]   r^   s       rK   __exit__z_TrackThread.__exit__]   s     					rL   rM   N)rM   r?   )__name__
__module____qualname____doc__floatrH   rT   rZ   r    r$   BaseExceptionr   rc   __classcell__rJ   s   @rK   r?   r?   ?   sj    3 h u S4./ -( '	
 
rL   r?   TF
   bar.backbar.completebar.finished	bar.pulsesequencedescriptiontotalauto_refreshconsole	transientget_timerefresh_per_secondstylecomplete_stylefinished_stylepulse_stylerC   disable
show_speedrM   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).
        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}rz   r{   r|   r}   )r   T)elapsed_when_finishedrm   ru   rv   rw   rx   ry   r~   )rt   rs   rC   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnrA   track)rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   rC   r~   r   columnsr@   s                    rK   r   r   g   s     P EP>	?@UW  NN--'	 *5d;		
 	!-3H 
 
>>E{- " 
 	
 	

 
	

 
s0   ABB7B8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)y),_Readerz9A reader that tracks progress while it's being read from.handler@   rA   taskclose_handlerM   Nc                 J    || _         || _        || _        || _        d| _        y NF)r   r@   r   r   _closed)rI   r   r@   r   r   s        rK   rH   z_Reader.__init__   s(      	(rL   c                 :    | j                   j                          | S rV   )r   rZ   rY   s    rK   rZ   z_Reader.__enter__   s    rL   r\   r]   r^   c                 $    | j                          y rV   )closerb   s       rK   rc   z_Reader.__exit__   s     	

rL   c                     | S rV    rY   s    rK   __iter__z_Reader.__iter__   s    rL   c                     t        | j                        }| j                  j                  | j                  t        |             |S NrP   )nextr   r@   rP   r   len)rI   lines     rK   __next__z_Reader.__next__   s4    DKK diiT;rL   c                     | j                   S rV   )r   rY   s    rK   closedz_Reader.closed   s    ||rL   c                 6    | j                   j                         S rV   )r   filenorY   s    rK   r   z_Reader.fileno       {{!!##rL   c                 6    | j                   j                         S rV   )r   isattyrY   s    rK   r   z_Reader.isatty   r   rL   c                 .    | j                   j                  S rV   )r   moderY   s    rK   r   z_Reader.mode       {{rL   c                 .    | j                   j                  S rV   )r   namerY   s    rK   r   z_Reader.name   r   rL   c                 6    | j                   j                         S rV   )r   readablerY   s    rK   r   z_Reader.readable       {{##%%rL   c                 6    | j                   j                         S rV   )r   seekablerY   s    rK   r   z_Reader.seekable   r   rL   c                      yr   r   rY   s    rK   writablez_Reader.writable   s    rL   sizec                     | j                   j                  |      }| j                  j                  | j                  t        |             |S r   )r   readr@   rP   r   r   )rI   r   blocks      rK   r   z_Reader.read   s:      &diiU<rL   bc                     | j                   j                  |      }| j                  j                  | j                  |       |S r   )r   readintor@   rP   r   )rI   r   ns      rK   r   z_Reader.readinto   s6    KK  #dii3rL   c                     | j                   j                  |      }| j                  j                  | j                  t        |             |S r   )r   readliner@   rP   r   r   )rI   r   r   s      rK   r   z_Reader.readline   s:    {{##D)diiT;rL   hintc           	          | j                   j                  |      }| j                  j                  | j                  t        t        t        |                   |S r   )r   	readlinesr@   rP   r   summapr   )rI   r   liness      rK   r   z_Reader.readlines   sA    %%d+diiSe_1EFrL   c                 ^    | j                   r| j                  j                          d| _        y )NT)r   r   r   r   rY   s    rK   r   z_Reader.close   s"    KKrL   offsetwhencec                     | j                   j                  ||      }| j                  j                  | j                  |       |S )NrF   )r   seekr@   rR   r   )rI   r   r   poss       rK   r   z_Reader.seek  s8    kkvv.TYY#6
rL   c                 6    | j                   j                         S rV   )r   tellrY   s    rK   r   z_Reader.tell
  s    {{!!rL   sc                     t        d      )Nwrite)r   )rI   r   s     rK   r   z_Reader.write  s    "7++rL   )T)rM   r   )rd   )r   )*re   rf   rg   rh   r   r;   boolrH   rZ   r    r$   rj   r   rc   r   bytesr   propertyr   intr   r   strr   r   r   r   r   r   r&   	bytearray
memoryviewr   r   r   r   r   r   r   r   r   r   r   rL   rK   r   r      s   C "  	
  
4./ -( '	
 
( % 
   $ $$ $  c      c    &$ &&$ &$  e 
%	:t ;< 
S % 
c 4; 

3  C 
"c ",s ,s ,rL   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.r@   rA   readerrM   Nc                      || _         || _        y rV   )r@   r   )rI   r@   r   s      rK   rH   z_ReadContext.__init__  s      rL   c                 j    | j                   j                          | j                  j                         S rV   )r@   rX   r   rZ   rY   s    rK   rZ   z_ReadContext.__enter__  s%    {{$$&&rL   r\   r]   r^   c                 r    | j                   j                          | j                  j                  |||       y rV   )r@   stopr   rc   rb   s       rK   rc   z_ReadContext.__exit__  s*     	Xw7rL   )re   rf   rg   rh   r=   rH   rZ   r    r$   rj   r   rc   r   rL   rK   r   r     sj    O! !R !D !'2 '84./8 -(8 '	8
 
8rL   r   
Reading...)rs   ru   rv   rw   rx   ry   rz   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   rm   r   )rt   rs   )r   r   r   DownloadColumnr   rA   	wrap_filer   )r   rt   rs   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r@   r   s                   rK   r   r   &  s    J EP>	?@UW  NN--'	 !		
 	!-3H E{KF&))rL   )rt   rs   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   PathLike[str]r   rtr	bufferingencodingerrorsnewlinec                     y rV   r   r   r   r   r   r   r   rt   rs   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   s                     rK   openr   g      , 	rL   rbc                     y rV   r   r   s                     rK   r   r     r   rL   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   rm   r   )r   r   r   r   r   rt   rs   )r   r   r   r   r   rA   r   r   )r   r   r   r   r   r   rt   rs   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r@   r   s                        rK   r   r     s    b EP>	?@UW  NN--'	 !		
 	!-3H ]]  	F &))rL   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_columnrM   c                 .    || _         i | _        d | _        y rV   )_table_column_renderable_cache_update_time)rI   r   s     rK   rH   zProgressColumn.__init__  s    )MO-1rL   c                 2    | j                   xs
 t               S )z.Get a table column, used to build tasks table.)r   r7   rY   s    rK   get_table_columnzProgressColumn.get_table_column  s    !!-VX-rL   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).
        )rx   r   rF   r   idKeyErrorrender)rI   r   current_time	timestamp
renderables        rK   __call__zProgressColumn.__call__  s     }}'&(,(>(>tww(G%	: t///,>%%[[&
+7*Dtww'  s   B 	BBc                      y)z"Should return a renderable object.Nr   rI   r   s     rK   r   zProgressColumn.render  s    rL   rV   )re   rf   rg   rh   r   r    ri   __annotations__r7   rH   r   r0   r  r   r   r   rL   rK   r   r     sl    =#'K%'2Xf%5 2 2
.& .V  . 16 1n 1 1rL   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  rG   rH   )rI   r  r   rJ   s      rK   rH   zRenderableColumn.__init__   s     %l3rL   r   r   rM   c                     | j                   S rV   )r  r  s     rK   r   zRenderableColumn.render&  s    rL   ) )
re   rf   rg   rh   r0   r    r7   rH   r   rk   rl   s   @rK   r	  r	    sB     ,.4SW4(4@H@P46 n rL   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_namerz   speedfinished_textr   c                     t        |||      | _        t        |t              rt	        j
                  |      n|| _        t        | !  |       y )Nrz   r  r
  )	r5   spinner
isinstancer   r9   from_markupr  rG   rH   )rI   r  rz   r  r  r   rJ   s         rK   rH   zSpinnerColumn.__init__4  sN     |5F -- ]+ 	
 	l3rL   spinner_stylerM   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)r5   r  )rI   r  r  r  s       rK   set_spinnerzSpinnerColumn.set_spinnerD  s     |=NrL   r   r   c                     |j                   r| j                  }|S | j                  j                  |j	                               }|S rV   )finishedr  r  r   rx   )rI   r   texts      rK   r   zSpinnerColumn.renderS  sH     }}  	
  $$T]]_5 	
 rL   )dotsprogress.spinner      ? N)r   r!  )re   rf   rg   rh   r   r    r6   ri   r:   r7   rH   r  r0   r   rk   rl   s   @rK   r  r  *  s     #%7"%)-44 	"4 	4
  4 v&4& .@	OO  	*O 	O
 
O6 n rL   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_formatrz   justifymarkuphighlighterr   rM   c                     || _         || _        || _        || _        || _        t
        |   |xs t        d             y )NTno_wrapr
  )r$  r%  rz   r&  r'  rG   rH   r7   )rI   r$  rz   r%  r&  r'  r   rJ   s          rK   rH   zTextColumn.__init___  sD     '&-
&l&JfT6JKrL   r   r   c                 B   | j                   j                  |      }| j                  r-t        j                  || j
                  | j                        }n"t        || j
                  | j                        }| j                  r| j                  j                  |       |S Nr   )rz   r%  )	r$  formatr&  r9   r  rz   r%  r'  	highlight)rI   r   _textr  s       rK   r   zTextColumn.rendero  sv      ''T'2;;##ET\\RDTZZFD&&t,rL   )noneleftTNN)re   rf   rg   rh   r   r6   r/   r   r    r1   r7   rH   r9   r   rk   rl   s   @rK   r   r   \  s    #
 "!'-1)-LL L 	L
 L k*L v&L 
L 6 d rL   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_widthrz   r{   r|   r}   r   rM   c                 l    || _         || _        || _        || _        || _        t
        |   |       y r  )r4  rz   r{   r|   r}   rG   rH   )rI   r4  rz   r{   r|   r}   r   rJ   s          rK   rH   zBarColumn.__init__  s;     #
,,&l3rL   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*   )	rt   rF   widthpulseanimation_timerz   r{   r|   r}   )r4   rt   maxrF   r4  startedrx   rz   r{   r|   r}   r  s     rK   r   zBarColumn.render  s    (,

(>#a$D!T^^,..0$c!T^^6Lll"==?**....((

 
	
rL   )(   rn   ro   rp   rq   N)re   rf   rg   rh   r    r   r6   r7   rH   r4   r   rk   rl   s   @rK   r   r   z  s     $&%$2$2!,)-4C=4 4 "	4
 "4 4 v&4 
4 
6 
k 
rL   r   c                        e Zd ZdZdddefdZy)TimeElapsedColumnzRenders time elapsed.r   r   rM   c                     |j                   r|j                  n|j                  }|t        dd      S t	        t        |            }t        t        |      d      S )zShow time elapsed.-:--:--progress.elapsedrz   )seconds)r  finished_timeelapsedr9   r	   r   r   )rI   r   rE  deltas       rK   r   zTimeElapsedColumn.render  sL    (,$$$4<<?	);<<#g,/CJ&899rL   Nre   rf   rg   rh   r9   r   r   rL   rK   r>  r>    s    :6 :d :rL   r>  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_percentagerz   r%  r&  r'  r   r   rM   c	                 L    || _         || _        t        	|   ||||||       y )N)r$  rz   r%  r&  r'  r   )rI  r   rG   rH   )
rI   r$  rI  rz   r%  r&  r'  r   r   rJ   s
            rK   rH   zTaskProgressColumn.__init__  s9     *C&$##% 	 	
rL   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.percentagerB  )r  u   ×10³u   ×10⁶u   ×10⁹u   ×10¹²  z.1fz it/s)r9   r+   pick_unit_and_suffixr   )clsr  unitsuffix
data_speeds        rK   render_speedzTaskProgressColumn.render_speed  s_     ="78844J<
f
 T\
z#&vhe4<QRRrL   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 r,  )rt   r   rR  finished_speedr  rI  r$  r.  r&  r9   r  rz   r%  r'  r/  )rI   r   r$  r0  r  s        rK   r   zTaskProgressColumn.render  s    ::$//$$T%8%8%FDJJGG.2jj.@D**dFVFV 	 """-;;##ET\\RDTZZFD&&t,rL   )z-[progress.percentage]{task.percentage:>3.0f}%r  r1  r2  TNNF)re   rf   rg   rh   r   r6   r/   r   r    r1   r7   rH   classmethodri   r9   rR  r   rk   rl   s   @rK   r   r     s     K)+!!'-1)- 

 $'
 	

 
 
 k*
 v&
 
 

. S% ST S S&6 d rL   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  )rX  r   rG   rH   )rI   rX  r   r   rJ   s       rK   rH   zTimeRemainingColumn.__init__  s$     %:"l3rL   r   r   rM   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.rA  zprogress.remainingr  rB  z--:--r@  <   02d:d)	r   r  rD  time_remainingrt   r9   rX  divmodr   )rI   r   	task_timerz   minutesrC  hours	formatteds           rK   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++rL   )FFN)re   rf   rg   rh   r   r   r    r7   rH   r9   r   rk   rl   s   @rK   r   r     sS     K &+)-	44  $4 v&	4,6 ,d ,rL   r   c                        e Zd ZdZdddefdZy)FileSizeColumnzRenders completed filesize.r   r   rM   c                 l    t        j                  t        |j                              }t	        |d      S )Show data completed.zprogress.filesizerB  )r+   decimalr   rF   r9   rI   r   	data_sizes      rK   r   zFileSizeColumn.render,  s)    $$S%89	I%899rL   NrG  r   rL   rK   rf  rf  )  s    %:6 :d :rL   rf  c                        e Zd ZdZdddefdZy)TotalFileSizeColumnzRenders total filesize.r   r   rM   c                     |j                   (t        j                  t        |j                               nd}t	        |d      S )rh  r  zprogress.filesize.totalrB  )rt   r+   ri  r   r9   rj  s      rK   r   zTotalFileSizeColumn.render5  s4    9=9OH$$S_5UW	I%>??rL   NrG  r   rL   rK   rm  rm  2  s    !@6 @d @rL   rm  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  )rq  rG   rH   )rI   rq  r   rJ   s      rK   rH   zMofNCompleteColumn.__init__G  s    "l3rL   r   r   rM   c                     t        |j                        }|j                  t        |j                        nd}t        t	        |            }t        || d| j                   | d      S )zShow completed/total.?r^  progress.downloadrB  )r   rF   rt   r   r   r9   rq  )rI   r   rF   rt   total_widths        rK   r   zMofNCompleteColumn.renderK  sc    '	#'::#9DJJs#e*o+a((8@%
 	
rL   )/N)re   rf   rg   rh   r   r    r7   rH   r9   r   rk   rl   s   @rK   rp  rp  ;  s3    	4# 48F;K 4
6 
d 
rL   rp  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   rM   c                 4    || _         t        | 	  |       y r  )ry  rG   rH   )rI   ry  r   rJ   s      rK   rH   zDownloadColumn.__init__]  s     )l3rL   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YBrL  r*   r   z,.frt  rw  r"  ru  rB  )r   rF   rt   ry  r+   rM  r9   )rI   r   rF    unit_and_suffix_calculation_baserO  rP  	precisioncompleted_ratiocompleted_strrt   total_ratio	total_strdownload_statusdownload_texts                 rK   r   zDownloadColumn.renderc  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rL   )FN)re   rf   rg   rh   r   r    r7   rH   r9   r   rk   rl   s   @rK   r   r   V  sD     LP4 48@8H4	4!6 !d !rL   r   c                        e Zd ZdZdddefdZy)TransferSpeedColumnz&Renders human readable transfer speed.r   r   rM   c                     |j                   xs |j                  }|t        dd      S t        j                  t        |            }t        | dd      S )zShow data transfer speed.rt  zprogress.data.speedrB  z/s)rT  r  r9   r+   ri  r   )rI   r   r  rQ  s       rK   r   zTransferSpeedColumn.render  sR    ##1tzz=#899%%c%j1
zl"%-BCCrL   NrG  r   rL   rK   r  r    s    0D6 Dd DrL   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  rF   N)re   rf   rg   rh   ri   r  r   rL   rK   r  r    s    .$rL   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   rs   rt   rF   	_get_timeNrD  Tvisible)default_factoryfieldsF)defaultinitrepr
start_time	stop_timerT  c                      t        d      S )NrL  )maxlenr   r   rL   rK   <lambda>zTask.<lambda>  s    T 2 rL   )r  r  r  	_progress)r  r  _lockrM   c                 "    | j                         S )z(float: Get the current time, in seconds.)r  rY   s    rK   rx   zTask.get_time  s    ~~rL   c                     | j                   duS )z#bool: Check if the task as started.N)r  rY   s    rK   r;  zTask.started  s     d**rL   c                 N    | j                   y| j                   | j                  z
  S )zPOptional[float]: Get the number of steps remaining, if a non-None total was set.N)rt   rF   rY   s    rK   	remainingzTask.remaining  s$     ::zzDNN**rL   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  rx   rY   s    rK   rE  zTask.elapsed  sC     ??">>%>>DOO33}}00rL   c                     | j                   duS )zCheck if the task has finished.N)rD  rY   s    rK   r  zTask.finished  s     !!--rL   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@)rt   rF   minr:  )rI   rF   s     rK   
percentagezTask.percentage  s>     zz^^djj0E9	s3	23	rL   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rV   r   ).0samples     rK   	<genexpr>zTask.speed.<locals>.<genexpr>  s     !Ov&"2"2!O   )r  r  r  r  iterr   r   )rI   r@   
total_timeiter_progresstotal_completedr  s         rK   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   )rI   r  r  estimates       rK   r_  zTask.time_remaining  sC     ==

NN		E)*rL   c                 T    | j                   j                          d| _        d| _        y)zReset progress.N)r  clearrD  rT  rY   s    rK   _resetzTask._reset  s"    !"rL   rd   )$re   rf   rg   rh   r;   r  r   r    ri   GetTimeCallablerD  r  r   r   dictr  r   r   r  r  rT  r  r   r  r   r  rx   r   r;  r  rE  r  r  r  r_  r  r   rL   rK   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  "   #rL   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dPdZdeee      dee   d ee   ddfd!Z	 	 	 	 dQd"eee    e!e    f   d#ee
   d$ee   d%ed&e
dee    fd'Z"	 dRdd(d)d*e#d#ee$   d$ee   d%ede#f
d+Z%e&jN                  	 	 	 	 dSddd(d,d*eed-e(f   d.e)d/   d0e$d1ee   d2ee   d3ee   d#ee$   d$ee   d%ede#fd4       Z*e&jN                  	 	 	 	 dSddd(d,d*eed-e(f   d.ee)d5   e)d6   f   d0e$d1ee   d2ee   d3ee   d#ee$   d$ee   d%ede+fd7       Z*	 	 	 	 	 dTddd(d,d*eed-e(f   d.ee)d/   e)d6   e)d5   f   d0e$d1ee   d2ee   d3ee   d#ee$   d$ee   d%edee#e+f   fd8Z*d$eddfd9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	d@e.ddfdAZ/dddBdddCd$edDe	d#ee
   d<e$d>ee	   d%ee   d@e.ddfdEZ0dUd$ed=e
ddfdFZ1dOdGZ2de3fdHZ4dee3   fdIZ5dJee   de6fdKZ7de3fdLZ8	 	 	 	 dVd%edDe	d#ee
   d<e$d>e	d@e.defdMZ9d$eddfdNZ:y)WrA   a  Renders an auto-updating progress bar(s).

    Args:
        console (Console, optional): Optional Console instance. Default will an internal Console instance writing to stdout.
        auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()`.
        refresh_per_second (Optional[float], optional): Number of times per second to refresh the progress information or None to use default (10). Defaults to None.
        speed_estimate_period: (float, optional): Period (in seconds) used to calculate the speed estimate. Defaults to 30.
        transient: (bool, optional): Clear the progress on exit. Defaults to False.
        redirect_stdout: (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True.
        redirect_stderr: (bool, optional): Enable redirection of stderr. Defaults to True.
        get_time: (Callable, optional): A callable that gets the current time, or None to use Console.get_time. Defaults to None.
        disable (bool, optional): Disable progress display. Defaults to False
        expand (bool, optional): Expand tasks table to fit width. Defaults to False.
    NTrm   g      >@F)
rv   ru   ry   speed_estimate_periodrw   redirect_stdoutredirect_stderrrx   r~   expandr   rv   ru   ry   r  rw   r  r  rx   r~   r  rM   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)rv   ru   ry   rw   r  r  get_renderable)r   r  get_default_columnsr   r  r~   r  _tasksr;   _task_indexr3   r,   r  liverv   rx   printlog)rI   rv   ru   ry   r  rw   r  r  rx   r~   r  r   s               rK   rH   zProgress.__init__*  s     "A%G'GGW
<$":":"<%:"*,#)!9,{}%1++..
	 !9DLL$9$9\\''
<<##rL   .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.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   )rN  s    rK   r  zProgress.get_default_columnsN  s(    2 ABK !	
 	
rL   c                 .    | j                   j                  S rV   )r  rv   rY   s    rK   rv   zProgress.consolem  s    yy   rL   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  valuesrY   s    rK   taskszProgress.tasksq  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  keysrY   s    rK   task_idszProgress.task_idsw  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rV   )r  )r  r   s     rK   r  z$Progress.finished.<locals>.<genexpr>  s     Ft}}Fr  )r  r  allr  rY   s    rK   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)rO   N)r~   r  rX   rY   s    rK   rX   zProgress.start  s     ||IIOODO) rL   c                     | j                   j                          | j                  j                  s| j                  j	                          yy)zStop the progress display.N)r  r   rv   is_interactiver  rY   s    rK   r   zProgress.stop  s2    		||**LL  +rL   c                 &    | j                          | S rV   rW   rY   s    rK   rZ   zProgress.__enter__  r[   rL   r\   r]   r^   c                 $    | j                          y rV   )r   rb   s       rK   rc   zProgress.__exit__  s     			rL   rr   rt   rB   rs   rC   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).
            task_id: (TaskID): Task to track. Default is new task.
            description: (str, optional): Description of task, if new task is created.
            update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1.

        Returns:
            Iterable[ProgressType]: An iterable of values taken from the provided sequence.
        Nrt   r*   )
ri   r   add_taskrR   r  ru   r?   rF   rP   rO   )
rI   rr   rt   rB   rs   rC   track_threadvaluerP   rO   s
             rK   r   zProgress.track  s     ( =+h/08DE?mmKum=GKKuK-99!!dG]; 0|% 0EK **a/*00 0
 llGllG! #	0 0s   A'C)!C=CCCr   )rB   rs   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'r  Fr   )r  r  rt   
ValueErrorr  rR   r   )rI   r   rt   rB   rs   total_bytess         rK   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)rt   rB   rs   r   r   r   r   r   r   r   c                     y rV   r   
rI   r   r   r   r   r   r   rt   rB   rs   s
             rK   r   zProgress.open       	rL   r   r   c                     y rV   r   r  s
             rK   r   zProgress.open  r  rL   c                   dj                  t        |d            }
|
dvrt        dj                  |            |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*   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)ra   sortedr  r.  warningswarnRuntimeWarningr   st_sizer  rR   ior   r   TextIOWrapper)rI   r   r   r   r   r   r   rt   rB   rs   _moder  r   r   s                 rK   r   zProgress.open  s(   B tU34))077=>> #aD=Y!^MMs Ik!A~ !ABBa	 =J&&E ?mmKum=GKKuK- ty9wTB ;##!-  rL   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  rx   )rI   rB   r   s      rK   
start_taskzProgress.start_task\  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  rx   r  r  )rI   rB   r   r  s       rK   	stop_taskzProgress.stop_taskj  sQ     ZZ 	*;;w'D==?L&".)DN	* 	* 	*s   :AA)rt   rF   rP   rs   r  rO   rF   rP   r  rO   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  rF   rt   r  rs   r  r  rR   rx   r  r  popleftr  appendr  rD  rE  rO   )rI   rB   rt   rF   rP   rs   r  rO   r  r   completed_startupdate_completedr  old_sample_timer  r  s                   rK   rR   zProgress.updatey  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   )rX   rt   rF   r  rs   rX   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)rx   r  r  r  r  rt   rF   r  r  rs   rD  rO   )
rI   rB   rX   rt   rF   r  rs   r  r  r   s
             rK   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   rL  N)rx   r  r  rF   r  r  r  r  r   r  r  rt   rD  rE  r  rT  )
rI   rB   rP   r  r   r  r  r  r  r  s
             rK   rP   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~   r  
is_startedrO   rY   s    rK   rO   zProgress.refresh  s,    ||		 4 4II !5|rL   c                 2    t        | j                          }|S )z*Get a renderable for the progress display.)r.   get_renderables)rI   r  s     rK   r  zProgress.get_renderable   s    D0023
rL   c              #   J   K   | j                  | j                        }| yw)z5Get a number of renderables for the progress display.N)make_tasks_tabler  )rI   tables     rK   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)Tr)  N)r  r   r7   r   copy)r  _columns     rK   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)r-  N)r  r   r.  )r  columnr   s     rK   r  z,Progress.make_tasks_table.<locals>.<genexpr>   s>       #  *&#6 #MMtM4!'.s   47)r   r8   gridr  r  add_row)rI   r  table_columnsr  r   s       @rK   r  zProgress.make_tasks_table
  sn    
  <<
 

M6$++N 	D|| '+ll		 rL   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  rY   s    rK   __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  rx   r  r  r;   r   rO   )	rI   rs   rX   rt   rF   r  r  r   new_task_indexs	            rK   r  zProgress.add_task0  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  )rI   rB   s     rK   remove_taskzProgress.remove_task[  s,     ZZ 	%G$	% 	% 	%s   $-rd   )rM   rA   )NN
Working...皙?rV   r   NNNr   r   NNN)r*   )Tr  r   T);re   rf   rg   rh   r&   r   r   r    r-   r   ri   r  rH   rU  r#   r  r   rv   r   r   r  r;   r  r  rX   r   rZ   r$   rj   r   rc   r   r<   r!   r   r   r   r   typingoverloadr   r)   r   r"   r  r   r   rR   r  rP   rO   r0   r  r  r8   r  r  r  r   r   rL   rK   rA   rA     s   $ &*!$&'+ $ $.2"$^+,"$ '""$ 	"$
 ""$  %"$ "$ "$ "$ ?+"$ "$ "$ 
"$H 
E.#*=$> 
 
< ! ! ! .tDz . .
 ,$v, , ,
 G$ G G*
!4./ -( '	
 
 "&$('"'.0FFG' ' &!	'
 ' ' 
,	'X  $(@
 %)'(@(@ }(@
 &!(@ (@ 
(@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 %rL   rA   __main__)Panel)Rule)Syntax)r8   a~  def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
    """Iterate and generate a tuple with a flag for last value."""
    iter_values = iter(values)
    try:
        previous_value = next(iter_values)
    except StopIteration:
        return
    for value in iter_values:
        yield False, previous_value
        previous_value = value
    yield True, previous_valuepython)line_numbersfoobarbaz123z:Text may be printed while the progress bars are rendering.z(In fact, [i]any[/i] renderable will workzSuch as [magenta]tables[/]...zPretty printed structures...examplezPretty printed)typer  z	Syntax...zGive it a try!)cycle)record)rv   rw   z[red]DownloadingrL  r  z[green]Processingz[yellow]ThinkingrW  r   g333333?g{Gz?d   )r!  NTNFNrm   rn   ro   rp   rq   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)   pip._vendor.typing_extensionsr  r+   r,   rv   r-   r.   r/   r0   r'  r1   jupyterr2   r  r3   progress_barr4   r  r5   rz   r6   r  r7   r8   r  r9   r:   r   r;   r<   ri   r  r=   r?   r   r   r   r   r   r   r&  r   r   r   r	  r  r   r   r>  r   r   rf  rm  rp  r   r  r  r   rA   re   randomtimepanelr(  ruler)  syntaxr*  r  progress_renderables	itertoolsr5  examplesr  r@   r  task1task2task3r  rR   sleeprandintr  r   r   rL   rK   <module>rS     sY	   	 
   #  (  .      * *     * v5 # B B $ !  %      	3	~&2u9% V^^D&(+%6 %T $!!%.2 "! . .(C
H\*H\,BBCC
C
 E?C
 	C

 gC
 C
 xE	*+C
 C
 C
 C
 C
 C
 C
 C
 C
  l!C
La,i a,H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	: 	:F FR-,. -,`:^ :@. @
 
6.^ .b	D. 	D%Z % z# z# z#zI	%| I	%X 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U