HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_vendor/rich/__pycache__/progress.cpython-310.pyc
o

@%NeV�� @stddlmZmZddlmZddlmZddlmZm	Z	ddl
mZddlm
Z
ddlmZmZmZddlmZdd	lmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"d
dl#m$Z$m%Z%d
dl&m'Z'm(Z(m)Z)m*Z*d
d
l+m,Z,d
dl-m.Z.d
dl/m0Z0d
dl1m2Z2d
dl3m4Z4d
dl5m6Z6d
dl7m8Z8m9Z9d
dl:m;Z;m<Z<ede=�Z>e!d�Z?ege@fZAGdd�de�ZB										 	!	"	dwd#e"ee?ee?fd$eCd%ee@d&eDd'ee'd(eDd)eege@fd*e@d+e6d,e6d-e6d.e6d/e@d0eDd1ee?fd2d3�ZEGd4d5�d5e�ZFGd6d7�d7eF�ZGGd8d9�d9eF�ZHGd:d;�d;eF�ZIGd<d=�d=eF�ZJGd>d?�d?eF�ZKGd@dA�dAeF�ZLGdBdC�dCeF�ZMGdDdE�dEeF�ZNGdFdG�dGeF�ZOGdHdI�dIeF�ZPGdJdK�dKe�ZQeGdLdM�dM��ZRGdNdO�dOe.�ZSeTdPk�r8ddlUZUddlVZVd
dQlWmXZXd
dRlYmZZZd
dSl[m\Z\d
dTl7m9Z9e\dUdVddW�Z[e9dXdYdZ�Z7e7�]d[d\d]�d^eXd_�d`e7dadbdcdd�dee[eZdf�g	Z^ddgl_m`Z`e`e^�Zae'ddh�Z&eSeH�eIdi�eJ�eIdj�eL�eK�e&ddk��RZbebjcdldmdn�Zdebjcdodmdn�Zeebjcdpdmddq�Zfebjg�s%ebjheddrds�ebjheedtds�eV�idu�eU�jddv�d
k�reb�kelea��ebjg�r�Wd�dSWd�dS1�s1wYdSdS)x�)�ABC�abstractmethod)�deque)�Sized)�	dataclass�field)�	timedelta)�ceil)�Event�RLock�Thread)�
TracebackType)�Any�Callable�Deque�Dict�Iterable�List�
NamedTuple�NewType�Optional�Sequence�Tuple�Type�TypeVar�Union�)�filesize�get_console)�Console�
JustifyMethod�RenderableType�Group)�Highlighter)�JupyterMixin)�Live)�ProgressBar)�Spinner)�	StyleType)�Column�Table)�Text�TextType�TaskID�ProgressTypecsleZdZdZdddddef�fdd�Zddd�Zdd
d�Zdee	e
dee
deed	d
fdd�Z�Z
S)�_TrackThreadz)A thread to periodically update progress.�progress�Progress�task_idr-�
update_periodcs.||_||_||_t�|_d|_t���dS)Nr)r0r2r3r
�done�	completed�super�__init__)�selfr0r2r3��	__class__��;/usr/lib/python3/dist-packages/pip/_vendor/rich/progress.pyr7/sz_TrackThread.__init__�returnNcCsj|j}|jj}|j}d}|jj}||�s(|j}||kr$||||�|}||�r|jj|j|jdd�dS)NrT)r5�refresh)r2r0�advancer3r4�waitr5�update)r8r2r?r3�last_completedr@r5r;r;r<�run8s�z_TrackThread.runcC�|��|S�N��start�r8r;r;r<�	__enter__F�z_TrackThread.__enter__�exc_type�exc_val�exc_tbcCs|j��|��dSrE)r4�set�join�r8rKrLrMr;r;r<�__exit__Js
z_TrackThread.__exit__�r=N)r=r/)�__name__�
__module__�__qualname__�__doc__�floatr7rCrIrr�
BaseExceptionr
rQ�
__classcell__r;r;r9r<r/,s
	

����r/�
Working...NTF�
�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_styler3�disabler=c	cs��|rtd�gng}|�t||	|
|d�td�t�f�t||||||p$d|
d��}|�|j||||d�EdHWd�dS1sCwYdS)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.done".
        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.
    Returns:
        Iterable[ProgressType]: An iterable of the values in the sequence.

    �([progress.description]{task.description})rirjrkrl�-[progress.percentage]{task.percentage:>3.0f}%r[)rdrerfrgrhrm)rcrbr3N)�
TextColumn�extend�	BarColumn�TimeRemainingColumnr1�track)rarbrcrdrerfrgrhrirjrkrlr3rm�columnsr0r;r;r<rtTs8�&�����
�"�rtc@speZdZUdZdZeeed<ddeeddfdd�Z	defdd	�Z
d
ddefdd
�Ze
d
ddefdd��ZdS)�ProgressColumnz3Base class for a widget to use in progress display.N�max_refresh�table_columnr=cCs||_i|_d|_dSrE)�
_table_column�_renderable_cache�_update_time)r8rxr;r;r<r7�s
zProgressColumn.__init__cCs|jpt�S)z.Get a table column, used to build tasks table.)ryr)rHr;r;r<�get_table_column�szProgressColumn.get_table_column�task�TaskcCsp|��}|jdur)|js)z
|j|j\}}Wn	tyYn
w||j|kr)|S|�|�}||f|j|j<|S)aCalled 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).
        N)rgrwr5rz�id�KeyError�render)r8r}�current_time�	timestamp�
renderabler;r;r<�__call__�s	�
zProgressColumn.__call__cCsdS)z"Should return a renderable object.Nr;�r8r}r;r;r<r��szProgressColumn.renderrE)rSrTrUrVrwrrW�__annotations__r)r7r|r!r�rr�r;r;r;r<rv�s
rvcsJeZdZdZ	ddd�dedeef�fdd�Zd	d
defdd
�Z�Z	S)�RenderableColumnz�A column to insert an arbitrary column.

    Args:
        renderable (RenderableType, optional): Any renderable. Defaults to empty string.
    �N�rxr�rxc�||_t�j|d�dS�Nr�)r�r6r7)r8r�rxr9r;r<r7��zRenderableColumn.__init__r}r~r=cCs|jSrE)r�r�r;r;r<r��szRenderableColumn.render)r�)
rSrTrUrVr!rr)r7r�rYr;r;r9r<r��s����r�cs�eZdZdZ					ddedeed	ed
edee	f
�fdd
�
Z
		ddedeed	eddfdd�Zdddefdd�Z
�ZS)�
SpinnerColumna�A column with a 'spinner' animation.

    Args:
        spinner_name (str, optional): Name of spinner animation. Defaults to "dots".
        style (StyleType, optional): Style of spinner. Defaults to "progress.spinner".
        speed (float, optional): Speed factor of spinner. Defaults to 1.0.
        finished_text (TextType, optional): Text used when task is finished. Defaults to " ".
    �dots�progress.spinner��?� N�spinner_nameri�speed�
finished_textrxcs<t|||d�|_t|t�rt�|�n||_t�j|d�dS)N�rir�r�)	r'�spinner�
isinstance�strr+�from_markupr�r6r7)r8r�rir�r�rxr9r;r<r7�s��zSpinnerColumn.__init__�
spinner_styler=cCst|||d�|_dS)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)r'r�)r8r�r�r�r;r;r<�set_spinner�s
zSpinnerColumn.set_spinnerr}r~cCs$|jr|j}|S|j�|���}|SrE)�finishedr�r�r�rg)r8r}�textr;r;r<r��s����zSpinnerColumn.render)r�r�r�r�N)r�r�)rSrTrUrVr�rr(rWr,r)r7r�r!r�rYr;r;r9r<r��s<����������
�r�csdeZdZdZ					ddededed	ed
ee	dee
ddf�fd
d�
Zdddefdd�Z
�ZS)rpzA column containing text.�none�leftTN�text_formatri�justify�markup�highlighterrxr=cs:||_||_||_||_||_t�j|ptdd�d�dS)NT��no_wrapr�)r�r�rir�r�r6r7r))r8r�rir�r�r�rxr9r;r<r7s	zTextColumn.__init__r}r~cCsR|jj|d�}|jrtj||j|jd�}n	t||j|jd�}|jr'|j�|�|S)N�r})rir�)	r��formatr�r+r�rir�r��	highlight)r8r}�_textr�r;r;r<r�szTextColumn.render)r�r�TNN)rSrTrUrVr�r(r �boolrr#r)r7r+r�rYr;r;r9r<rps.��������rpcsfeZdZdZ						ddeed	ed
ededed
eeddf�fdd�
Zddde	fdd�Z
�ZS)rraRenders 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.done".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
    �(r\r]r^r_N�	bar_widthrirjrkrlrxr=cs0||_||_||_||_||_t�j|d�dSr�)r�rirjrkrlr6r7)r8r�rirjrkrlrxr9r;r<r7.s	zBarColumn.__init__r}r~cCsPttd|j�td|j�|jdurdntd|j�|j|��|j|j|j	|j
d�	S)z&Gets a progress bar widget for a task.rNr)	rcr5�width�pulse�animation_timerirjrkrl)r&�maxrcr5r��startedrgrirjrkrlr�r;r;r<r�>s

�zBarColumn.render)r�r\r]r^r_N)rSrTrUrVr�intr(r)r7r&r�rYr;r;r9r<rr#s0��������rrc@�"eZdZdZdddefdd�ZdS)�TimeElapsedColumnzRenders time elapsed.r}r~r=cCsD|jr|jn|j}|durtddd�Stt|�d�}tt|�dd�S)�Show time remaining.N�-:--:--zprogress.elapsed�ri��seconds)r��
finished_time�elapsedr+rr�r�)r8r}r��deltar;r;r<r�Ps
zTimeElapsedColumn.renderN�rSrTrUrVr+r�r;r;r;r<r�M�r�c@s&eZdZdZdZdddefdd�ZdS)	rsz!Renders estimated time remaining.��?r}r~r=cCs8|j}|dur
tddd�Stt|�d�}tt|�dd�S)r�Nr�zprogress.remainingr�r�)�time_remainingr+rr�r�)r8r}�	remaining�remaining_deltar;r;r<r�_s
zTimeRemainingColumn.renderN)rSrTrUrVrwr+r�r;r;r;r<rsYsrsc@r�)�FileSizeColumnzRenders completed filesize.r}r~r=cC�t�t|j��}t|dd�S)�Show data completed.zprogress.filesizer�)r�decimalr�r5r+�r8r}�	data_sizer;r;r<r�k�zFileSizeColumn.renderNr�r;r;r;r<r�hr�r�c@r�)�TotalFileSizeColumnzRenders total filesize.r}r~r=cCr�)r�zprogress.filesize.totalr�)rr�r�rcr+r�r;r;r<r�tr�zTotalFileSizeColumn.renderNr�r;r;r;r<r�qr�r�csHeZdZdZ	d
dedeeddf�fdd�
Zd	d
defdd�Z	�Z
S)�DownloadColumnz�Renders file size downloaded and total, e.g. '0.5/2.3 GB'.

    Args:
        binary_units (bool, optional): Use binary units, KiB, MiB etc. Defaults to False.
    FN�binary_unitsrxr=cr�r�)r�r6r7)r8r�rxr9r;r<r7�r�zDownloadColumn.__init__r}r~c
Cs�t|j�}t|j�}|jrt�|gd�d�\}}nt�|gd�d�\}}||}||}|dkr2dnd}|d|�d��}	|d|�d��}
|	�d	|
�d
|��}t|dd�}|S)
z.Calculate common unit for completed and total.)	�bytes�KiB�MiB�GiB�TiB�PiB�EiB�ZiB�YiBi)	r��KB�MB�GB�TB�PB�EB�ZB�YB��rrz,.�f�/r�zprogress.downloadr�)r�r5rcr�r�pick_unit_and_suffixr+)
r8r}r5rc�unit�suffix�completed_ratio�total_ratio�	precision�
completed_str�	total_str�download_status�
download_textr;r;r<r��s&


�
�zDownloadColumn.render)FN)rSrTrUrVr�rr)r7r+r�rYr;r;r9r<r�zs����r�c@r�)�TransferSpeedColumnz&Renders human readable transfer speed.r}r~r=cCs@|jp|j}|durtddd�St�t|��}t|�d�dd�S)zShow data transfer speed.N�?zprogress.data.speedr�z/s)�finished_speedr�r+rr�r�)r8r}r��
data_speedr;r;r<r��s
zTransferSpeedColumn.renderNr�r;r;r;r<r��r�r�c@s$eZdZUdZeed<	eed<dS)�ProgressSamplez$Sample of progress for a given time.r�r5N)rSrTrUrVrWr�r;r;r;r<r��s
r�c@s�eZdZUdZeed<	eed<	eed<	eed<	eed<	dZ	e
eed<	d	Zeed
<	e
ed�Zeeefed<	e
dd
d
d�Ze
eed<	e
dd
d
d�Ze
eed<	dZe
eed<	e
ed
d
d�Zeeed<e
d
ed�Zeed<	defdd�Zedefdd��Zedefdd��Zede
efdd��Zedefdd ��Z edefd!d"��Z!ede
efd#d$��Z"ede
efd%d&��Z#d)d'd(�Z$dS)*r~z�Information regarding a progress task.

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

    rrbrcr5�	_get_timeNr�T�visible)�default_factory�fieldsF)�default�init�repr�
start_time�	stop_timer�)r�r�r��	_progress)r�r��_lockr=cCs|��S)z(float: Get the current time, in seconds.)r�rHr;r;r<rg��z
Task.get_timecC�
|jduS)z#bool: Check if the task as started.N)r�rHr;r;r<r���
zTask.startedcCs|j|jS)z)float: Get the number of steps remaining.)rcr5rHr;r;r<r��szTask.remainingcCs2|jdurdS|jdur|j|jS|��|jS)z]Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started.N)r�r�rgrHr;r;r<r��s


zTask.elapsedcCr�)zCheck if the task has finished.N)r�rHr;r;r<r��r�z
Task.finishedcCs.|jsdS|j|jd}tdtd|��}|S)z,float: Get progress of task as a percentage.��Y@)rcr5�minr�)r8r5r;r;r<�
percentages
zTask.percentagecCs�|jdurdS|j�D|j}|s	Wd�dS|dj|dj}|dkr0	Wd�dSt|�}t|�tdd�|D��}||}|Wd�S1sQwYdS)z=Optional[float]: Get the estimated speed in steps per second.N���rcs��|]}|jVqdSrE)r5)�.0�sampler;r;r<�	<genexpr>��zTask.speed.<locals>.<genexpr>)r�r�r�r��iter�next�sum)r8r0�
total_time�
iter_progress�total_completedr�r;r;r<r�	s"
��$�z
Task.speedcCs*|jrdS|j}|sdSt|j|�}|S)zJOptional[float]: Get estimated time to completion, or ``None`` if no data.r�N)r�r�r	r�)r8r��estimater;r;r<r�szTask.time_remainingcCs|j��d|_d|_dS)zReset progress.N)r��clearr�r�rHr;r;r<�_reset&s

zTask._resetrR)%rSrTrUrVr-r�r�rW�GetTimeCallabler�rr�r�r�dictr�rrr�r�r�rr�rr�rr�rg�propertyr�r�r�r�rr�r�rr;r;r;r<r~�sZ
�
r~c@s�eZdZdZddddddddddd�
deeefd	eed
e	de
de
d
e	de	de	deede	de	ddfdd�Ze
defdd��Ze
deefdd��Ze
deefdd��Ze
de	fdd��ZdVdd�ZdVd d!�ZdWd"d#�Zd$eeed%eed&eeddfd'd(�Z			)	*dXd+eeeeefd,ee
d-eed.ed/e
deefd0d1�Zd-eddfd2d3�Z d-eddfd4d5�Z!ddddddd6�d-ed,ee
d7ee
d8ee
d.eed9ee	d:e	d;e"ddfd<d=�Z#ddd>ddd?�d-ed@e	d,ee
d7e$d9ee	d.eed;e"ddfdAdB�Z%dYd-ed8e
ddfdDdE�Z&dVdFdG�Z'de(fdHdI�Z)dee(fdJdK�Z*dLeede+fdMdN�Z,de(fdOdP�Z-		Q	>	dZd.ed@e	d,e
d7e$d9e	d;e"defdRdS�Z.d-eddfdTdU�Z/dS)[r1a�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.
    NTr[g>@F)
rerdrh�speed_estimate_periodrf�redirect_stdout�redirect_stderrrgrm�expandrurerdrhrrfrrrgrmrr=c
	Gs�|dus|dksJd��t�|_|ptd�t�td�t�f|_||_|	|_|
|_i|_	t
d�|_t|p5t
�||||||jd�|_|pE|jj|_|jj|_|jj|_dS)Nrzrefresh_per_second must be > 0rnro)rerdrhrfrr�get_renderable)rr�rprrrsrurrmr�_tasksr-�_task_indexr%rr�livererg�print�log)r8rerdrhrrfrrrgrmrrur;r;r<r7=s6��
�	
zProgress.__init__cCs|jjSrE)rrerHr;r;r<rehr�zProgress.consolecC�8|j�t|j���Wd�S1swYdS)zGet a list of Task instances.N)r��listr�valuesrHr;r;r<�tasksl�$�zProgress.taskscCr)zA list of task IDs.N)r�r r�keysrHr;r;r<�task_idsrr#zProgress.task_idscCsZ|j� |js	Wd�dStdd�|j��D��Wd�S1s&wYdS)z'Check if all tasks have been completed.NTcsrrE)r�)rr}r;r;r<r~rz$Progress.finished.<locals>.<genexpr>)r�r�allr!rHr;r;r<r�xs�$�zProgress.finishedcCs|js|jjdd�dSdS)zStart the progress display.T)r>N)rmrrGrHr;r;r<rG�s�zProgress.startcCs$|j��|jjs|j��dSdS)zStop the progress display.N)r�stopre�is_interactiverrHr;r;r<r'�s
�z
Progress.stopcCrDrErFrHr;r;r<rI�rJzProgress.__enter__rKrLrMcCs|��dSrE)r'rPr;r;r<rQ�szProgress.__exit__rZr`rarcr2rbr3ccs��|durt|t�rtt|��}n
td|�d���|}|dur'|j||d�}n|j||d�|jjrZt	|||��}|D]}|V|j
d7_
q;Wd�dS1sSwYdS|j}	|j}
|D]
}|V|	|d�|
�qbdS)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.
        Nzunable to get size of z, please specify 'total'�rcr)
r�rrW�len�
ValueError�add_taskrArrdr/r5r?r>)r8rarcr2rbr3�
task_total�track_thread�valuer?r>r;r;r<rt�s2�

��"�
�zProgress.trackcCsZ|j� |j|}|jdur|��|_Wd�dSWd�dS1s&wYdS)z�Start 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�rr�rg)r8r2r}r;r;r<�
start_task�s	

�"�zProgress.start_taskcCsT|j�|j|}|��}|jdur||_||_Wd�dS1s#wYdS)z�Stop a task.

        This will freeze the elapsed time on the task.

        Args:
            task_id (TaskID): ID of task.
        N)r�rrgr�r�)r8r2r}r�r;r;r<�	stop_task�s

"�zProgress.stop_task)rcr5r?rbr�r>r5r?r�r>r�cKs\|j��|j|}	|	j}
|dur||	jkr||	_|	��|dur'|	j|7_|dur.||	_|dur5||	_|dur<||	_|	j�|�|	j|
}|�	�}||j
}
|	j}|j}|rk|dj
|
krk|�|rk|dj
|
ks_t|�dkrz|�t|�dksq|dkr�|�t||��|	j|	jkr�|	jdur�|	j|	_Wd�n1s�wY|r�|��dSdS)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.
        Nrr�)r�rr5rcrrbr�r�rArgrr��popleftr�r*�appendr�r�r�r>)r8r2rcr5r?rbr�r>r�r}�completed_start�update_completedr��old_sample_timer�r2r;r;r<rA�sF


���� �zProgress.updater)rGrcr5r�rbrGc
Ks�|��}|j�8|j|}	|	��|r|nd|	_|dur||	_||	_|dur)||	_|r.||	_|dur5||	_	d|	_
Wd�n1sBwY|��dS)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.
            **fields (str): Additional data fields required for rendering.
        N)rgr�rrr�rcr5r�r�rbr�r>)
r8r2rGrcr5r�rbr�r�r}r;r;r<�reset s"
�zProgress.resetrc
Cs|��}|j�w|j|}|j}|j|7_|j|}||j}|j}|j}	|r<|dj|kr<|	�|r<|dj|ks0t|�dkrK|	�t|�dksB|�	t
||��|j|jkrn|jdurv|j
|_|j|_Wd�dSWd�dSWd�dS1s�wYdS)z�Advance task by a number of steps.

        Args:
            task_id (TaskID): ID of task.
            advance (float): Number of steps to advance. Default is 1.
        rr�N)rgr�rr5rr�r2r�r*r3r�rcr�r�r�r�)
r8r2r?r�r}r4r5r6r�r2r;r;r<r?Es0


��
��"�zProgress.advancecCs$|js|jjr|j��dSdSdS)z*Refresh (render) the progress information.N)rmr�
is_startedr>rHr;r;r<r>_s�zProgress.refreshcCst|���}|S)z*Get a renderable for the progress display.)r"�get_renderables)r8r�r;r;r<rdszProgress.get_renderableccs�|�|j�}|VdS)z5Get a number of renderables for the progress display.N)�make_tasks_tabler")r8�tabler;r;r<r9is�
zProgress.get_renderablesr"csRdd�|jD�}tj|d|jd��}|D]��jr&|j�fdd�|jD��q|S)z�Get 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.
        css0�|]}t|t�rtdd�n|����VqdS)Tr�N)r�r�r)r|�copy)r�_columnr;r;r<rws���

�z,Progress.make_tasks_table.<locals>.<genexpr>)rr)�paddingrc3s.�|]}t|t�r|j�d�n|��VqdS)r�N)r�r�r�)r�columnr�r;r<r�s���
�)rur*�gridrr��add_row)r8r"�
table_columnsr;r;r�r<r:ns	�
���
zProgress.make_tasks_tablecCs2|j�|��Wd�S1swYdS)z+Makes the Progress class itself renderable.N)r�rrHr;r;r<�__rich__�s$�zProgress.__rich__rc	Ks�|j�2t|j||||||j|jd�}||j|j<|r!|�|j�|j}tt|j�d�|_Wd�n1s8wY|��|S)a�Add a new 'task' to the Progress display.

        Args:
            description (str): A description of the task.
            start (bool, optional): Start the task immediately (to calculate elapsed time). If set to False,
                you will need to call `start` manually. Defaults to True.
            total (float, optional): Number of total steps in the progress if know. 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�rN)	r�r~rrgrr0r-r�r>)	r8rbrGrcr5r�r�r}�new_task_indexr;r;r<r,�s&�
�zProgress.add_taskcCs4|j�
|j|=Wd�dS1swYdS)z]Delete a task if it exists.

        Args:
            task_id (TaskID): A task ID.

        N)r�r)r8r2r;r;r<�remove_task�s
"�zProgress.remove_taskrR)r=r1)NNrZr`)r)TrrT)0rSrTrUrVrr�rvrrr�rWrr7rrerr~r"r-r%r�rGr'rIrrXr
rQrr.rrtr0r1rrAr�r7r?r>r!rr9r*r:rCr,rEr;r;r;r<r1-s*�
�������	�
���
�+



���
�������
�1�������	�
�
�?�������	�

�%
!�������
�*r1�__main__)�Panel)�Rule)�Syntax)r*a~def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
    """Iterate and generate a tuple with a flag for last value."""
    iter_values = iter(values)
    try:
        previous_value = next(iter_values)
    except StopIteration:
        return
    for value in iter_values:
        yield False, previous_value
        previous_value = value
    yield True, previous_value�python)�line_numbers�foo�bar�baz�1�2�3z:Text may be printed while the progress bars are rendering.z(In fact, [i]any[/i] renderable will workzSuch as [magenta]tables[/]...zPretty printed structures...�examplezPretty printed)�typer�z	Syntax...zGive it a try!)�cycle)�recordrnro)rerfz[red]Downloadingr�r)z[green]Processingz[yellow]Thinking)rcrGr�)r?g333333�?g{�G�z�?�d)
rZNTNFNr[r\r]r^r_r`F)m�abcrr�collectionsr�collections.abcr�dataclassesrr�datetimer�mathr	�	threadingr
rr�typesr
�typingrrrrrrrrrrrrrrr�rrrerr r!r"r�r#�jupyterr$rr%�progress_barr&r�r'rir(r;r)r*r�r+r,r�r-r.rWrr/r�r�rtrvr�r�rprrr�rsr�r�r�r�r�r~r1rS�random�time�panelrG�rulerH�syntaxrIrA�progress_renderables�	itertoolsrT�examplesr0r,�task1�task2�task3r�rA�sleep�randintrr
r;r;r;r<�<module>s@
*���������	�
���
��
�D*2*		%	x
��
�	

��$��