
    dh                    "	   d dl mZ d dlZd dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZmZ d dlmZ d dlmZmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZ d dlmZmZmZ d dlmZ d dlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 erd dl2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZG ddlHmIZImJZJ ddlKmLZLmMZM  e+deN      ZO e0d      ZPe"g eQf   ZR ej`                  de-e!      ZS G d de      ZT	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dw	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dxd'ZU G d( d)ee!      ZV G d* d+e#eS   e&eS         ZWd,d dd!dd"d#d$d%d&d!d-	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dyd.ZXej                  	 	 	 	 dzdd,d dd!dd"d#d$d%d&d!d/	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d{d0       ZZej                  	 	 	 	 dzdd,d dd!dd"d#d$d%d&d!d/	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d|d1       ZZ	 	 	 	 	 d}dd,d dd!dd"d#d$d%d&d!d/	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d~d2ZZ G d3 d4e      Z[ G d5 d6e[      Z\ G d7 d8e[      Z] G d9 d:e[      Z^ G d; d<e[      Z_ G d= d>e[      Z` G d? d@e^      Za G dA dBe[      Zb G dC dDe[      Zc G dE dFe[      Zd G dG dHe[      Ze G dI dJe[      Zf G dK dLe[      Zg G dM dNe*      Zhe G dO dP             Zi G dQ dRe?      ZjekdSk(  rfd dllZld dlmZmddTlnmoZo ddUlpmqZq ddVlrmsZs ddWlHmJZJ  esdXdYd Z      Zr eJd[d\d]      ZHeHj                  d^d_d`       da eodb      dceHdddedfdgdher eqdi      g	Zud djlvmwZw  eweu      Zx e8d k      Z7 ej e]       gejj                          e`       e7d!dl5 Zzezj                  dmdno      Z|ezj                  dpdno      Z}ezj                  dqdo      Z~ezj                  swezj                  e|drs       ezj                  e}dts        emj                  du        elj                  d dv      dk  rezj                   eex             ezj                  swddd       yy# 1 sw Y   yxY w)    )annotationsN)ABCabstractmethoddeque)	dataclassfield)	timedelta)	RawIOBaseUnsupportedOperation)ceil)mmap)length_hint)PathLikestat)EventRLockThread)TracebackType)TYPE_CHECKINGAnyBinaryIOCallableContextManagerDequeDictGenericIterableListLiteral
NamedTupleNewTypeOptionalTextIOTupleTypeTypeVarUnion)Self   )filesizeget_console)ConsoleGroupJustifyMethodRenderableType)Highlighter)JupyterMixin)Live)ProgressBar)Spinner)	StyleType)ColumnTable)TextTextTypeTaskIDProgressType_Ic                  L     e Zd ZdZd fdZddZddZ	 	 	 	 	 	 	 	 d	dZ xZS )
_TrackThreadz)A thread to periodically update progress.c                |    || _         || _        || _        t               | _        d| _        t        |   d       y )Nr   T)daemon)progresstask_idupdate_periodr   done	completedsuper__init__)selfrB   rC   rD   	__class__s       [/var/www/html/vivango/api/ia/venv/lib/python3.12/site-packages/pip/_vendor/rich/progress.pyrH   z_TrackThread.__init__C   s9     *G	%    c                   | 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)rF   refresh)
rC   rB   advancerD   rE   waitlive
is_startedrF   update)rI   rC   rO   rD   last_completedrP   rF   s          rK   runz_TrackThread.runL   s    ,,--''**yy~~}%$--*<*<*G*GI*^!;<!*	 }%$--*<*<*G*G 	T\\T^^TRrL   c                &    | j                          | S NstartrI   s    rK   	__enter__z_TrackThread.__enter__Z       

rL   c                X    | j                   j                          | j                          y rW   )rE   setjoinrI   exc_typeexc_valexc_tbs       rK   __exit__z_TrackThread.__exit__^   s     					rL   )rB   
'Progress'rC   z'TaskID'rD   floatreturnNone)rh   z'_TrackThread'ra   zOptional[Type[BaseException]]rb   zOptional[BaseException]rc   zOptional[TracebackType]rh   ri   )	__name__
__module____qualname____doc__rH   rU   r[   rd   __classcell__rJ   s   @rK   r?   r?   @   sA    3&S/ ) (	
 
rL   r?   TF
   bar.backbar.completebar.finished	bar.pulsec           
   #  ,  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.

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

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

    ([progress.description]{task.description}stylecomplete_stylefinished_stylepulse_style)
show_speedT)elapsed_when_finishedrq   auto_refreshconsole	transientget_timerefresh_per_seconddisable)totalrF   descriptionrD   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnProgresstrack)sequencer   r   rF   r   r   r   r   r   ry   rz   r{   r|   rD   r   r}   columnsrB   s                     rK   r   r   h   s     X 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dZddZ	 	 	 	 	 	 	 	 ddZddZddZe	dd       Z
d dZdd	Ze	d!d
       Ze	d!d       ZddZddZddZd"d#dZd$dZd"d#dZd"d%dZd&dZd'd(dZd dZd)dZd*dZy)+_Readerz9A reader that tracks progress while it's being read from.c                J    || _         || _        || _        || _        d| _        y NF)handlerB   taskclose_handle_closed)rI   r   rB   r   r   s        rK   rH   z_Reader.__init__   s(      	(rL   c                :    | j                   j                          | S rW   )r   r[   rZ   s    rK   r[   z_Reader.__enter__   s    rL   c                $    | j                          y rW   )closer`   s       rK   rd   z_Reader.__exit__   s     	

rL   c                    | S rW    rZ   s    rK   __iter__z_Reader.__iter__   s    rL   c                    t        | j                        }| j                  j                  | j                  t        |             |S NrO   )nextr   rB   rO   r   len)rI   lines     rK   __next__z_Reader.__next__   s4    DKK diiT;rL   c                    | j                   S rW   )r   rZ   s    rK   closedz_Reader.closed   s    ||rL   c                6    | j                   j                         S rW   )r   filenorZ   s    rK   r   z_Reader.fileno       {{!!##rL   c                6    | j                   j                         S rW   )r   isattyrZ   s    rK   r   z_Reader.isatty   r   rL   c                .    | j                   j                  S rW   )r   moderZ   s    rK   r   z_Reader.mode       {{rL   c                .    | j                   j                  S rW   )r   namerZ   s    rK   r   z_Reader.name   r   rL   c                6    | j                   j                         S rW   )r   readablerZ   s    rK   r   z_Reader.readable       {{##%%rL   c                6    | j                   j                         S rW   )r   seekablerZ   s    rK   r   z_Reader.seekable   r   rL   c                     yr   r   rZ   s    rK   writablez_Reader.writable   s    rL   c                    | j                   j                  |      }| j                  j                  | j                  t        |             |S r   )r   readrB   rO   r   r   )rI   sizeblocks      rK   r   z_Reader.read   s:      &diiU<rL   c                    | j                   j                  |      }| j                  j                  | j                  |       |S r   )r   readintorB   rO   r   )rI   bns      rK   r   z_Reader.readinto   s6    KK  #dii3rL   c                    | j                   j                  |      }| j                  j                  | j                  t        |             |S r   )r   readlinerB   rO   r   r   )rI   r   r   s      rK   r   z_Reader.readline   s:    {{##D)diiT;rL   c           	         | j                   j                  |      }| j                  j                  | j                  t        t        t        |                   |S r   )r   	readlinesrB   rO   r   summapr   )rI   hint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   rZ   s    rK   r   z_Reader.close	  s"    KKrL   c                    | j                   j                  ||      }| j                  j                  | j                  |       |S )NrF   )r   seekrB   rS   r   )rI   offsetwhenceposs       rK   r   z_Reader.seek  s8    kkvv.TYY#6
rL   c                6    | j                   j                         S rW   )r   tellrZ   s    rK   r   z_Reader.tell  s    {{!!rL   c                    t        d      )Nwriter   )rI   ss     rK   r   z_Reader.write  s    "7++rL   c                    t        d      )N
writelinesr   )rI   r   s     rK   r   z_Reader.writelines  s    "<00rL   N)T)
r   r   rB   re   r   r;   r   boolrh   ri   )rh   z	'_Reader'rj   )rh   r   )rh   bytesrh   r   )rh   int)rh   str))r   r   rh   r   )r   z"Union[bytearray, memoryview, mmap])r   r   rh   zList[bytes]rg   )r   )r   r   r   r   rh   r   )r   r   rh   r   )r   zIterable[Any]rh   ri   )rk   rl   rm   rn   rH   r[   rd   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rL   rK   r   r      s    C "  	
  
/ ) (	
 

  $$        &&





",1rL   r   c                  8    e Zd ZdZddZddZ	 	 	 	 	 	 	 	 ddZy)	_ReadContextzEA utility class to handle a context for both a reader and a progress.c                     || _         || _        y rW   )rB   reader)rI   rB   r   s      rK   rH   z_ReadContext.__init__   s      rL   c                j    | j                   j                          | j                  j                         S rW   )rB   rY   r   r[   rZ   s    rK   r[   z_ReadContext.__enter__$  s%    {{$$&&rL   c                r    | j                   j                          | j                  j                  |||       y rW   )rB   stopr   rd   r`   s       rK   rd   z_ReadContext.__exit__(  s*     	Xw7rL   N)rB   re   r   r=   rh   ri   )rh   r=   rj   )rk   rl   rm   rn   rH   r[   rd   r   rL   rK   r   r     s:    O!'8/8 )8 (	8
 
8rL   r   
Reading...)r   r   r   r   r   r   ry   rz   r{   r|   r   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:
        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.

    rw   rx   rq   r   )r   r   )r   r   r   DownloadColumnr   r   	wrap_filer   )filer   r   r   r   r   r   r   ry   rz   r{   r|   r   r   rB   r   s                   rK   r   r   2  s    J EP>	?@UW  NN--'	 !		
 	!-3H E{KF&))rL   )r   r   r   r   r   r   r   ry   rz   r{   r|   r   c                    y rW   r   r   r   	bufferingencodingerrorsnewliner   r   r   r   r   r   r   ry   rz   r{   r|   r   s                     rK   openr   s      , 	rL   c                    y rW   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.

    rw   rx   rq   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   ry   rz   r{   r|   r   r   rB   r   s                        rK   r   r     s    b EP>	?@UW  NN--'	 !		
 	!-3H ]]  	F &))rL   c                  L    e Zd ZU dZdZded<   d	d
dZddZddZe	dd       Z
y)ProgressColumnz3Base class for a widget to use in progress display.NOptional[float]max_refreshc                .    || _         i | _        d | _        y rW   )_table_column_renderable_cache_update_time)rI   table_columns     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   rZ   s    rK   get_table_columnzProgressColumn.get_table_column  s    !!-VX-rL   c                .   |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   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   rW   )r   Optional[Column]rh   ri   )rh   r7   r   'Task'rh   r0   )rk   rl   rm   rn   r   __annotations__rH   r   r  r   r  r   rL   rK   r   r     s2    =#'K'2
.. 1 1rL   r   c                  <     e Zd ZdZ	 ddd	 	 	 d fdZddZ xZS )	RenderableColumnzA column to insert an arbitrary column.

    Args:
        renderable (RenderableType, optional): Any renderable. Defaults to empty string.
    Nr   c               4    || _         t        | 	  |       y Nr  )r  rG   rH   )rI   r  r   rJ   s      rK   rH   zRenderableColumn.__init__,  s     %l3rL   c                    | j                   S rW   )r  r	  s     rK   r  zRenderableColumn.render2  s    rL   ) )r  r0   r   r
  r  rk   rl   rm   rn   rH   r  ro   rp   s   @rK   r  r  %  s/     ,.4SW4(4@P4rL   r  c                  f     e Zd ZdZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 d fdZ	 	 d	 	 	 	 	 	 	 ddZd	dZ xZS )
SpinnerColumna  A column with a 'spinner' animation.

    Args:
        spinner_name (str, optional): Name of spinner animation. Defaults to "dots".
        style (StyleType, optional): Style of spinner. Defaults to "progress.spinner".
        speed (float, optional): Speed factor of spinner. Defaults to 1.0.
        finished_text (TextType, optional): Text used when task is finished. Defaults to " ".
    c                    t        |||      | _        t        |t              rt	        j
                  |      n|| _        t        | !  |       y )Nry   speedr  )	r5   spinner
isinstancer   r9   from_markupfinished_textrG   rH   )rI   spinner_namery   r  r  r   rJ   s         rK   rH   zSpinnerColumn.__init__@  sN     |5F -- ]+ 	
 	l3rL   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  spinner_styler  s       rK   set_spinnerzSpinnerColumn.set_spinnerP  s     |=NrL   c                    |j                   r| j                  }|S | j                  j                  |j	                               }|S rW   )finishedr  r  r  r   )rI   r   texts      rK   r  zSpinnerColumn.render_  sH     }}  	
  $$T]]_5 	
 rL   )dotsprogress.spinner      ? N)
r  r   ry   Optional[StyleType]r  rf   r  r:   r   r
  )r'  r(  )r  r   r!  r*  r  rf   rh   ri   r  )rk   rl   rm   rn   rH   r"  r  ro   rp   s   @rK   r  r  6  s     #%7"%)-44 #4 	4
  4 '4& .@	OO +O 	O
 
OrL   r  c                  R     e Zd ZdZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZddZ xZS )r   zA column containing text.c                    || _         || _        || _        || _        || _        t
        |   |xs t        d             y )NTno_wrapr  )text_formatjustifyry   markuphighlighterrG   rH   r7   )rI   r/  ry   r0  r1  r2  r   rJ   s          rK   rH   zTextColumn.__init__k  sD     '&-
&l&JfT6JKrL   c                B   | j                   j                  |      }| j                  r-t        j                  || j
                  | j                        }n"t        || j
                  | j                        }| j                  r| j                  j                  |       |S Nr   )ry   r0  )	r/  formatr1  r9   r  ry   r0  r2  	highlight)rI   r   _textr%  s       rK   r  zTextColumn.render{  sv      ''T'2;;##ET\\RDTZZFD&&t,rL   )noneleftTNN)r/  r   ry   r6   r0  r/   r1  r   r2  Optional[Highlighter]r   r
  rh   ri   r   r  rh   r9   r  rp   s   @rK   r   r   h  sm    #
 "!'-1)-LL L 	L
 L +L 'L 
L rL   r   c                  T     e Zd ZdZ	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZddZ xZS )r   a  Renders a visual progress bar.

    Args:
        bar_width (Optional[int], optional): Width of bar or None for full width. Defaults to 40.
        style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
        complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
        finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
    c                l    || _         || _        || _        || _        || _        t
        |   |       y r  )	bar_widthry   rz   r{   r|   rG   rH   )rI   r?  ry   rz   r{   r|   r   rJ   s          rK   rH   zBarColumn.__init__  s;     #
,,&l3rL   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*   )	r   rF   widthpulseanimation_timery   rz   r{   r|   )r4   r   maxrF   r?  startedr   ry   rz   r{   r|   r	  s     rK   r  zBarColumn.render  s    (,

(>#a$D!T^^,..0$c!T^^6Lll"==?**....((

 
	
rL   )(   rr   rs   rt   ru   N)r?  Optional[int]ry   r6   rz   r6   r{   r6   r|   r6   r   r
  rh   ri   )r   r  rh   r4   r  rp   s   @rK   r   r     sj     $&%$2$2!,)-4 4 4 "	4
 "4 4 '4 
4 
rL   r   c                      e Zd ZdZddZy)TimeElapsedColumnzRenders time elapsed.c                    |j                   r|j                  n|j                  }|t        dd      S t	        t        dt        |                  }t        t        |      d      S )zShow time elapsed.-:--:--progress.elapsedry   r   )seconds)r$  finished_timeelapsedr9   r
   rD  r   r   )rI   r   rP  deltas       rK   r  zTimeElapsedColumn.render  sS    (,$$$4<<?	);<<#aW"67CJ&899rL   Nr<  rk   rl   rm   rn   r  r   rL   rK   rI  rI    s
    :rL   rI  c                  r     e Zd ZdZ	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZedd       ZddZ xZS )	r   a  Show task progress as a percentage.

    Args:
        text_format (str, optional): Format for percentage display. Defaults to "[progress.percentage]{task.percentage:>3.0f}%".
        text_format_no_percentage (str, optional): Format if percentage is unknown. Defaults to "".
        style (StyleType, optional): Style of output. Defaults to "none".
        justify (JustifyMethod, optional): Text justification. Defaults to "left".
        markup (bool, optional): Enable markup. Defaults to True.
        highlighter (Optional[Highlighter], optional): Highlighter to apply to output. Defaults to None.
        table_column (Optional[Column], optional): Table Column to use. Defaults to None.
        show_speed (bool, optional): Show speed if total is unknown. Defaults to False.
    c	                L    || _         || _        t        	|   ||||||       y )N)r/  ry   r0  r1  r2  r   )text_format_no_percentager}   rG   rH   )
rI   r/  rU  ry   r0  r1  r2  r   r}   rJ   s
            rK   rH   zTaskProgressColumn.__init__  s9     *C&$##% 	 	
rL   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.percentagerM  )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   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  )r   r}   r]  finished_speedr  rU  r/  r6  r1  r9   r  ry   r0  r2  r7  )rI   r   r/  r8  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  r9  r:  TNNF)r/  r   rU  r   ry   r6   r0  r/   r1  r   r2  r;  r   r
  r}   r   rh   ri   )r  r   rh   r9   r<  )	rk   rl   rm   rn   rH   classmethodr]  r  ro   rp   s   @rK   r   r     s     K)+!!'-1)- 

 $'
 	

 
 
 +
 '
 
 

, S S&rL   r   c                  B     e Zd ZdZdZ	 	 	 d	 	 	 	 	 d fdZddZ xZS )r   a  Renders estimated time remaining.

    Args:
        compact (bool, optional): Render MM:SS when time remaining is less than an hour. Defaults to False.
        elapsed_when_finished (bool, optional): Render time elapsed when the task is finished. Defaults to False.
          ?c                B    || _         || _        t        |   |       y r  )compactr~   rG   rH   )rI   rd  r~   r   rJ   s       rK   rH   zTimeRemainingColumn.__init__  s$     %:"l3rL   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.rL  zprogress.remainingr  rM  z--:--rK  <   02d:d)	r~   r$  rO  time_remainingr   r9   rd  divmodr   )rI   r   	task_timery   minutesrN  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)rd  r   r~   r   r   r
  r<  )rk   rl   rm   rn   r   rH   r  ro   rp   s   @rK   r   r     s@     K &+)-	44  $4 '	4,rL   r   c                      e Zd ZdZddZy)FileSizeColumnzRenders completed filesize.c                l    t        j                  t        |j                              }t	        |d      S )Show data completed.zprogress.filesizerM  )r+   decimalr   rF   r9   rI   r   	data_sizes      rK   r  zFileSizeColumn.render7  s)    $$S%89	I%899rL   Nr<  rR  r   rL   rK   rq  rq  4  s
    %:rL   rq  c                      e Zd ZdZddZy)TotalFileSizeColumnzRenders total filesize.c                    |j                   (t        j                  t        |j                               nd}t	        |d      S )rs  r  zprogress.filesize.totalrM  )r   r+   rt  r   r9   ru  s      rK   r  zTotalFileSizeColumn.render@  s4    9=9OH$$S_5UW	I%>??rL   Nr<  rR  r   rL   rK   rx  rx  =  s    !@rL   rx  c                  .     e Zd ZdZdd fdZddZ xZS )MofNCompleteColumnaH  Renders completed count/total, e.g. '  10/1000'.

    Best for bounded tasks with int quantities.

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

    Args:
        separator (str, optional): Text to separate completed and total values. Defaults to "/".
    c                4    || _         t        | 	  |       y r  )	separatorrG   rH   )rI   r}  r   rJ   s      rK   rH   zMofNCompleteColumn.__init__R  s    "l3rL   c                    t        |j                        }|j                  t        |j                        nd}t        t	        |            }t        || d| j                   | d      S )zShow completed/total.?ri  progress.downloadrM  )r   rF   r   r   r   r9   r}  )rI   r   rF   r   total_widths        rK   r  zMofNCompleteColumn.renderV  sc    '	#'::#9DJJs#e*o+a((8@%
 	
rL   )/N)r}  r   r   r
  r<  r  rp   s   @rK   r{  r{  F  s    	4
rL   r{  c                  :     e Zd ZdZ	 d	 	 	 	 	 d fdZddZ xZS )r   zRenders file size downloaded and total, e.g. '0.5/2.3 GB'.

    Args:
        binary_units (bool, optional): Use binary units, KiB, MiB etc. Defaults to False.
    c                4    || _         t        | 	  |       y r  )binary_unitsrG   rH   )rI   r  r   rJ   s      rK   rH   zDownloadColumn.__init__h  s     )l3rL   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YBrW  r*   r   z,.fr  r  r)  r  rM  )r   rF   r   r  r+   rX  r9   )rI   r   rF    unit_and_suffix_calculation_baserZ  r[  	precisioncompleted_ratiocompleted_strr   total_ratio	total_strdownload_statusdownload_texts                 rK   r  zDownloadColumn.rendern  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)r  r   r   r
  rh   ri   r<  r  rp   s   @rK   r   r   a  s1     LP4 48H4	4!rL   r   c                      e Zd ZdZddZy)TransferSpeedColumnz&Renders human readable transfer speed.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.speedrM  z/s)r_  r  r9   r+   rt  r   )rI   r   r  r\  s       rK   r  zTransferSpeedColumn.render  sR    ##1tzz=#899%%c%j1
zl"%-BCCrL   Nr<  rR  r   rL   rK   r  r    s    0DrL   r  c                  (    e Zd ZU dZded<   	 ded<   y)ProgressSamplez$Sample of progress for a given time.rf   r  rF   N)rk   rl   rm   rn   r  r   rL   rK   r  r    s    .$rL   r  c                     e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   	 d
ed<   	 dZded<   	 dZded<   	  ee      Z	ded<   	  eddd      Z
ded<   	  eddd      Zded<   	 dZded<   	  ed dd      Zded<    ede      Zded<   	 d)d Zed*d!       Zed+d"       Zed+d#       Zed*d$       Zed)d%       Zed+d&       Zed+d'       Zd,d(Zy)-TaskzInformation regarding a progress task.

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

    r;   r  r   r   r   r   rf   rF   GetTimeCallable	_get_timeNrO  Tr   visible)default_factoryzDict[str, Any]fieldsF)defaultinitrepr
start_time	stop_timer_  c                     t        d      S )NrW  )maxlenr   r   rL   rK   <lambda>zTask.<lambda>  s    T 2 rL   )r  r  r  zDeque[ProgressSample]	_progress)r  r  r   _lockc                "    | j                         S )z(float: Get the current time, in seconds.)r  rZ   s    rK   r   zTask.get_time  s    ~~rL   c                    | j                   duS )z#bool: Check if the task as started.N)r  rZ   s    rK   rE  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r   rF   rZ   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  r   rZ   s    rK   rP  zTask.elapsed  sC     ??">>%>>DOO33}}00rL   c                    | j                   duS )zCheck if the task has finished.N)rO  rZ   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@)r   rF   minrD  )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rW   r   ).0samples     rK   	<genexpr>zTask.speed.<locals>.<genexpr>  s     !Ov&"2"2!O   )r  r  r  r  iterr   r   )rI   rB   
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   rj  zTask.time_remaining  sC     ==

NN		E)*rL   c                T    | j                   j                          d| _        d| _        y)zReset progress.N)r  clearrO  r_  rZ   s    rK   _resetzTask._reset  s"    !"rL   )rh   rf   r   )rh   r   rg   )rk   rl   rm   rn   r  rO  r  r	   dictr  r  r  r_  r  r   r  r   r   rE  r  rP  r$  r  r  rj  r  r   rL   rK   r  r    s_    	JG'>*+%)M?)(GTJ"48FN8?"'5u"MJMN!&t%e!LILN&*NO*>',2U(I$  eU;E5;  + + + + 1 1 . .    "  #rL   r  c                  $   e Zd ZdZddddddddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)dZed*d	       Zed+d
       Zed,d       Z	ed-d       Z
ed.d       Zd/dZd/dZd0dZ	 	 	 	 	 	 	 	 d1dZ	 	 	 	 	 d2	 	 	 	 	 	 	 	 	 	 	 	 	 d3dZ	 d4ddd	 	 	 	 	 	 	 	 	 d5dZej&                  	 	 	 	 d6dddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d7d       Zej&                  	 	 	 	 d6dddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d8d       Z	 	 	 	 	 d9dddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d:dZd;dZd;dZddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d<dZdddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d=d Zd>d?d!Zd/d"Zd@d#ZdAd$ZdBd%Zd@d&Z	 	 	 	 dC	 	 	 	 	 	 	 	 	 	 	 	 	 dDd'Zd;d(Z y)Er   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.
    NTrq   g      >@F)
r   r   r   speed_estimate_periodr   redirect_stdoutredirect_stderrr   r   expandc       
   	        |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   r   r   r   r  r  get_renderable)r   r  get_default_columnsr   r  r   r  _tasksr;   _task_indexr3   r,   r  rQ   r   r   printlog)rI   r   r   r   r  r   r  r  r   r   r  r   s               rK   rH   zProgress.__init__5  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.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.
        rw   )r   r   r   r   )rY  s    rK   r  zProgress.get_default_columnsY  s(    2 ABK !	
 	
rL   c                .    | j                   j                  S rW   )rQ   r   rZ   s    rK   r   zProgress.consolex  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  valuesrZ   s    rK   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  keysrZ   s    rK   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rW   )r$  )r  r   s     rK   r  z$Progress.finished.<locals>.<genexpr>  s     Ft}}Fr  )r  r  allr  rZ   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)rN   N)r   rQ   rY   rZ   s    rK   rY   zProgress.start  s     ||IIOODO) rL   c                    | j                   j                          | j                  j                  s2| j                  j                  s| j                  j                          yyy)zStop the progress display.N)rQ   r   r   is_interactive
is_jupyterr  rZ   s    rK   r   zProgress.stop  sB    		||**4<<3J3JLL  4K*rL   c                &    | j                          | S rW   rX   rZ   s    rK   r[   zProgress.__enter__  r\   rL   c                $    | j                          y rW   )r   r`   s       rK   rd   zProgress.__exit__  s     			rL   r   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)aC  Track progress by iterating over a sequence.

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

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

        Returns:
            Iterable[ProgressType]: An iterable of values taken from the provided sequence.
        Nr  r*   )
rf   r   add_taskrS   rQ   r   r?   rF   rO   rN   )rI   r   r   rF   rC   r   rD   track_threadvaluerO   rN   s              rK   r   zProgress.track  s     0 =+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   )rC   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  r   
ValueErrorr  rS   r   )rI   r   r   rC   r   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)r   rC   r   c                    y rW   r   
rI   r   r   r   r   r   r   r   rC   r   s
             rK   r   zProgress.open       	rL   c                    y rW   r   r  s
             rK   r   zProgress.open  r  rL   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)brrtrz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  rb)r   Tr  )r  r  )r   r   r   line_buffering)r_   sortedr  warningswarnRuntimeWarningr   st_sizer  rS   ior   r   TextIOWrapper)rI   r   r   r   r   r   r   r   rC   r   _moder  r   r   s                 rK   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 ;##!-  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  r   )rI   rC   r   s      rK   
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  )rI   rC   r   r  s       rK   	stop_taskzProgress.stop_tasky  sQ     ZZ 	*;;w'D==?L&".)DN	* 	* 	*s   :AA)r   rF   rO   r   r  rN   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   r   r  r   r  r  rS   r   r  r  popleftr  appendr  rO  rP  rN   )rI   rC   r   rF   rO   r   r  rN   r  r   completed_startupdate_completedr  old_sample_timer  r  s                   rK   rS   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)rY   r   rF   r  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  r   rF   r  r  r   rO  rN   )
rI   rC   rY   r   rF   r  r   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   rW  N)r   r  r  rF   r  r  r  r  r   r  r  r   rO  rP  r  r_  )
rI   rC   rO   r  r   r  r  r  r  r  s
             rK   rO   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   rQ   rR   rN   rZ   s    rK   rN   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   !#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)r5  N)r  r   r6  )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  rZ   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  r   r  r  r;   r   rN   )	rI   r   rY   r   rF   r  r  r   new_task_indexs	            rK   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  )rI   rC   s     rK   remove_taskzProgress.remove_taskj  s,     ZZ 	%G$	% 	% 	%s   $-)r   zUnion[str, ProgressColumn]r   Optional[Console]r   r   r   rf   r  rf   r   r   r  r   r  r   r   zOptional[GetTimeCallable]r   r   r  r   rh   ri   )rh   zTuple[ProgressColumn, ...])rh   r-   )rh   z
List[Task])rh   zList[TaskID]r   rg   )rh   r)   rj   )Nr   N
Working...皙?)r   Iterable[ProgressType]r   r   rF   r   rC   Optional[TaskID]r   r   rD   rf   rh   r3  rW   )
r   r   r   rG  rC   r4  r   r   rh   r   r   NNN)r   "Union[str, 'PathLike[str]', bytes]r   Literal['rb']r   r   r   Optional[str]r   r8  r   r8  r   rG  rC   r4  r   r   rh   r   )r   r6  r   z"Union[Literal['r'], Literal['rt']]r   r   r   r8  r   r8  r   r8  r   rG  rC   r4  r   r   rh   r$   r  r   NNN)r   r6  r   1Union[Literal['rb'], Literal['rt'], Literal['r']]r   r   r   r8  r   r8  r   r8  r   rG  rC   r4  r   r   rh   zUnion[BinaryIO, TextIO])rC   r;   rh   ri   )rC   r;   r   r   rF   r   rO   r   r   r8  r  Optional[bool]rN   r   r  r   rh   ri   )rC   r;   rY   r   r   r   rF   r   r  r;  r   r8  r  r   rh   ri   )r*   )rC   r;   rO   rf   rh   ri   )rh   r0   )rh   zIterable[RenderableType])r  zIterable[Task]rh   r8   )Tr  r   T)r   r   rY   r   r   r   rF   r   r  r   r  r   rh   r;   )!rk   rl   rm   rn   rH   r`  r  r   r   r  r  r$  rY   r   r[   rd   r   r   typingoverloadr   r  r  rS   r  rO   rN   r  r  r  r+  r  r/  r   rL   rK   r   r   %  s   $ &*!$&'+ $ $.2"$,"$ #"$ 	"$
 ""$  %"$ "$ "$ "$ ,"$ "$ "$ 
"$H 
 
< ! ! . .
 , ,
 G G*
!/ ) (	
 
 "&$('"+(+ + 	+
 "+ + + 
 +`  $(@
 %)'(@(@ (@
 "(@ (@ 
(@T __
 "& $!%  $$('0  	
      "  
  __
 "& $!%  $$('0 1 	
      "  
 $ CF"& $!%K  $$('K0K @K 	K
  K K K K "K K 
!KZ2*& "&%)#'%)"&;; 	;
 #; !; #;  ; ; ; 
;B !%"&%)%% 	%
 % %  % #% % 
%N1< 


B) !&)) ) 	)
 ) ) ) 
)V%rL   r   __main__)Panel)Rule)Syntax)r8   a~  def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
    """Iterate and generate a tuple with a flag for last value."""
    iter_values = iter(values)
    try:
        previous_value = next(iter_values)
    except StopIteration:
        return
    for value in iter_values:
        yield False, previous_value
        previous_value = value
    yield True, previous_valuepython)line_numbersfoobarbaz123z:Text may be printed while the progress bars are rendering.z(In fact, [i]any[/i] renderable will workzSuch as [magenta]tables[/]...zPretty printed structures...examplezPretty printed)typer%  z	Syntax...zGive it a try!)cycle)record)r   r   z[red]DownloadingrW  r  z[green]Processingz[yellow]Thinkingrb  r   g333333?g{Gz?d   )r1  Nr   TNFNrq   rr   rs   rt   ru   r2  FT)"r   r3  r   r   r   r   rF   r   r   r   r   r0  r   r   r   Optional[Callable[[], float]]r   rf   ry   r6   rz   r6   r{   r6   r|   r6   rD   rf   r   r   r}   r   rh   r3  )r   r   r   r   r   r   r   r   r   r0  r   r   r   rO  r   rf   ry   r6   rz   r6   r{   r6   r|   r6   r   r   rh   ContextManager[BinaryIO]r5  )&r   r6  r   z"Union[Literal['rt'], Literal['r']]r   r   r   r8  r   r8  r   r8  r   rG  r   r   r   r   r   r0  r   r   r   rO  r   rf   ry   r6   rz   r6   r{   r6   r|   r6   r   r   rh   zContextManager[TextIO])&r   r6  r   r7  r   r   r   r8  r   r8  r   r8  r   rG  r   r   r   r   r   r0  r   r   r   rO  r   rf   ry   r6   rz   r6   r{   r6   r|   r6   r   r   rh   rP  r9  )&r   r6  r   r:  r   r   r   r8  r   r8  r   r8  r   rG  r   r   r   r   r   r0  r   r   r   rO  r   rf   ry   r6   rz   r6   r{   r6   r|   r6   r   r   rh   z7Union[ContextManager[BinaryIO], ContextManager[TextIO]])
__future__r   r
  r<  r  abcr   r   collectionsr   dataclassesr   r	   datetimer
   r   r   mathr   r   operatorr   osr   r   	threadingr   r   r   typesr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   typing_extensionsr)   r  r+   r,   r   r-   r.   r/   r0   r2  r1   jupyterr2   rQ   r3   progress_barr4   r  r5   ry   r6   r  r7   r8   r%  r9   r:   r   r;   r<   rf   r  r=   r?   r   r   r   r   r=  r   r   r  r  r   r   rI  r   r   rq  rx  r{  r   r  r  r  r   rk   randomtimepanelr?  ruler@  syntaxrA  r(  progress_renderables	itertoolsrL  examplesr  rB   r  task1task2task3r$  rS   sleeprandintr  r   r   rL   rK   <module>rk     s=   " 	   #  (  .      * *      , & # B B $ !  %      	3	~&2u9% V^^D&(+%6 %T $!!%.2 "! . .(!K
$K
K
 K
 	K

 K
 K
 K
 ,K
 K
 K
 K
 K
 K
 K
 K
  !K
" #K
\d1i d1N8>"%wr{ 82 $!%.2 "! . .(>*
>*>* 	>*
 >* >* >* ,>* >* >* >* >* >* >* >*B  " !	  #!%.2 "! . .('	
,	
,	 	 		
 	 	 	 	 	 	 	 ,	 	 	  !	" #	$ %	& '	( )	 	0  " !	  #!%.2 "! . .('	
,	
	 	 		
 	 	 	 	 	 	 	 ,	 	 	  !	" #	$ %	& '	( )	 	4 ?B" !S*  #!%.2 "! . .('S*
,S*
;S* S* 	S*
 S* S* S* S* S* S* S* ,S* S* S*  !S*" #S*$ %S*& 'S*( =)S*l'1S '1T~ "/N /d <'
 '
T	: 	:E EP-,. -,`:^ :@. @
 
6.^ .b	D. 	D%Z % z# z# z#zM	%| M	%` 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<RR