HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/site-packages/pip/_vendor/rich/__pycache__/progress.cpython-310.pyc
o

��i���+@sddlZddlZddlZddlZddlmZmZddlmZddl	m
Z
ddlmZm
Z
ddlmZddlmZmZddlmZdd	lmZdd
lmZmZddlmZmZmZddlmZdd
lmZmZm 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/ej0dkr�ddlm1Z1nddl2m1Z1ddl3m4Z4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:ddl;m<Z<ddl=m>Z>ddl?m@Z@ddlAmBZBddlCmDZDddlEmFZFddlGmHZHmIZIddlJmKZKmLZLe(deM�ZNe.d�ZOe gePfZQe�.de+e�ZRGdd�de�ZS	 		!		"		#	$	%	&	'	(	"	!d�d)e/e*eOe%eOfd*eTd+e)ePd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd5ePd6eUd7eUd8e%eOf d9d:�ZVGd;d<�d<ee�ZWGd=d>�d>e!eRe$eR�ZXd?d!dd"dd#d$d%d&d'd"d@�dAed+eMd*eTd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd6eUd8e!efdBdC�ZYejZ	D			d�dd?d!dd"dd#d$d%d&d'd"dE�dAe/eTdFe[fdGe/e1dHe1dIfdJeMdKe)eTdLe)eTdMe)eTd+e)eMd*eTd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd6eUd8e!e+f&dNdO��Z\ejZ	D			d�dd?d!dd"dd#d$d%d&d'd"dE�dAe/eTdFe[fdGe1dPdJeMdKe)eTdLe)eTdMe)eTd+e)eMd*eTd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd6eUd8e!ef&dQdO��Z\	I	D			d�dd?d!dd"dd#d$d%d&d'd"dE�dAe/eTdFe[fdGe/e1dPe1dHe1dIfdJeMdKe)eTdLe)eTdMe)eTd+e)eMd*eTd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd6eUd8e/e!ee!e+ff&dRdO�Z\GdSdT�dTe�Z]GdUdV�dVe]�Z^GdWdX�dXe]�Z_GdYdZ�dZe]�Z`Gd[d\�d\e]�ZaGd]d^�d^e]�ZbGd_d`�d`e`�ZcGdadb�dbe]�ZdGdcdd�dde]�ZeGdedf�dfe]�ZfGdgdh�dhe]�ZgGdidj�dje]�ZhGdkdl�dle]�ZiGdmdn�dne'�ZjeGdodp�dp��ZkGdqdr�dre>�Zlemdsk�r�ddlnZnddloZoddtlpmqZqddulrmsZsddvltmuZuddwlGmIZIeudxdyd!dz�ZteId{d|d}�ZGeG�vd~dd��d�eqd��d�eGd�d�d�d��d�etesd��g	Zwdd�lxmyZyeyew�Zze7d!d��Z6ele_�gel�{��eb��Re6d"d����QZ|e|j}d�d�d��Z~e|j}d�d�d��Ze|j}d�dd��Z�e|j��s�e|j�e~d�d��e|j�ed�d��eo��d��en��dd��dk�r�e|��e�ez��e|j��r�Wd�dSWd�dS1�s�wYdSdS)��N)�ABC�abstractmethod��deque)�Sized)�	dataclass�field)�	timedelta)�	RawIOBase�UnsupportedOperation)�ceil)�mmap)�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�_IcsleZdZdZdddddef�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)r>r@rAr�done�	completed�super�__init__)�selfr>r@rA��	__class__��D/usr/local/lib/python3.10/site-packages/pip/_vendor/rich/progress.pyrEBsz_TrackThread.__init__�returnNcCsj|j}|jj}|j}d}|jj}||�s(|j}||kr$||||�|}||�r|jj|j|jdd�dS)NrT)rC�refresh)r@r>�advancerArB�waitrC�update)rFr@rMrA�last_completedrNrCrIrIrJ�runKs�z_TrackThread.runcC�|��|S�N��start�rFrIrIrJ�	__enter__Y�z_TrackThread.__enter__�exc_type�exc_val�exc_tbcCs|j��|��dSrS)rB�set�join�rFrYrZr[rIrIrJ�__exit__]s
z_TrackThread.__exit__�rKN)rKr=)�__name__�
__module__�__qualname__�__doc__�floatrErQrWrr#�
BaseExceptionrr_�
__classcell__rIrIrGrJr=?s
	

����r=�
Working...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_stylerA�disable�
show_speedrKc	cs��|rtd�gng}|�t||	|
|d�t|d�t�f�t||||||p%d|
d��}|�|j||||d�EdHWd�dS1sDwYdS)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}�rwrxryrz)r|ri�rrrsrtrurvr{)rqrprAN)�
TextColumn�extend�	BarColumn�TaskProgressColumn�TimeRemainingColumnr?�track)rorprqrrrsrtrurvrwrxryrzrAr{r|�columnsr>rIrIrJr�gs8�(�����
�"�r�c@s�eZdZdZ	d?dedddededd	f
d
d�Zd@dd
�Zde	e
ede	ede	edd	fdd�Z
defdd�Zdefdd�Zedefdd��Zdefdd�Zdefdd�Zedefdd��Zedefdd ��Zdefd!d"�Zdefd#d$�Zdefd%d&�ZdAd(edefd)d*�Zd+eeee ffd,d-�Z!dAd(edefd.d/�Z"dAd0ede#efd1d2�Z$dBd3d4�Z%dCd6ed7edefd8d9�Z&defd:d;�Z'd<e(defd=d>�Z)d	S)D�_Readerz9A reader that tracks progress while it's being read from.T�handler>r?�task�close_handlerKNcCs"||_||_||_||_d|_dS�NF)r�r>r�r��_closed)rFr�r>r�r�rIrIrJrE�s

z_Reader.__init__cCs|j��|SrS)r�rWrVrIrIrJrW�s
z_Reader.__enter__rYrZr[cC�|��dSrS)�closer^rIrIrJr_��z_Reader.__exit__cCs|SrSrIrVrIrIrJ�__iter__��z_Reader.__iter__cCs$t|j�}|jj|jt|�d�|S�N�rM)�nextr�r>rMr��len)rF�linerIrIrJ�__next__�s
z_Reader.__next__cC�|jSrS)r�rVrIrIrJ�closed�sz_Reader.closedcC�
|j��SrS)r��filenorVrIrIrJr���
z_Reader.filenocCr�rS)r��isattyrVrIrIrJr��r�z_Reader.isattycC�|jjSrS)r��moderVrIrIrJr���z_Reader.modecCr�rS)r��namerVrIrIrJr��r�z_Reader.namecCr�rS)r��readablerVrIrIrJr��r�z_Reader.readablecCr�rS)r��seekablerVrIrIrJr��r�z_Reader.seekablecC�dSr�rIrVrIrIrJ�writable�r�z_Reader.writable����sizecC�&|j�|�}|jj|jt|�d�|Sr�)r��readr>rMr�r�)rFr��blockrIrIrJr���z_Reader.read�bcCs"|j�|�}|jj|j|d�|Sr�)r��readintor>rMr�)rFr��nrIrIrJr��sz_Reader.readintocCr�r�)r��readliner>rMr�r�)rFr�r�rIrIrJr��r�z_Reader.readline�hintcCs,|j�|�}|jj|jttt|��d�|Sr�)r��	readlinesr>rMr��sum�mapr�)rFr��linesrIrIrJr��sz_Reader.readlinescCs|jr|j��d|_dS)NT)r�r�r�r�rVrIrIrJr�s

z
_Reader.closer�offset�whencecCs$|j�||�}|jj|j|d�|S)N�rC)r��seekr>rOr�)rFr�r��posrIrIrJr�sz_Reader.seekcCr�rS)r��tellrVrIrIrJr�
r�z_Reader.tell�scCstd��)N�write)r)rFr�rIrIrJr�
sz
_Reader.write)T)rKr�)r�r`)r)*rarbrcrdrr:�boolrErWrr#rfrr_r��bytesr��propertyr��intr�r��strr�r�r�r�r�r�r%�	bytearray�
memoryviewr
r�r�rr�r�r�r�rr�rIrIrIrJr��sZ�����
�


���
�
r�c@s^eZdZdZdddeddfdd�Zdefd	d
�Zdeee	dee	d
ee
ddfdd�ZdS)�_ReadContextzEA utility class to handle a context for both a reader and a progress.r>r?�readerrKNcCs||_||_dSrS)r>r�)rFr>r�rIrIrJrEs
z_ReadContext.__init__cCs|j��|j��SrS)r>rUr�rWrVrIrIrJrWs

z_ReadContext.__enter__rYrZr[cCs|j��|j�|||�dSrS)r>�stopr�r_r^rIrIrJr_s
z_ReadContext.__exit__)rarbrcrdr<rErWrr#rfrr_rIrIrIrJr�s
����r��
Reading...)rprrrsrtrurvrwrxryrzr{�filec	Csh|rtd�gng}
|
�t||	|
|d�t�t�f�t|
|||||p"d|d��}|j|||d�}t||�S)aRead 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~rir)rqrp)r�r�r��DownloadColumnr�r?�	wrap_filer�)r�rqrprrrsrtrurvrwrxryrzr{r�r>r�rIrIrJr�&s0%�����

r�r�)rqrprrrsrtrurvrwrxryrzr{�
PathLike[str]r��rt�r�	buffering�encoding�errors�newlinecC�dSrSrI�r�r�r�r�r�r�rqrprrrsrtrurvrwrxryrzr{rIrIrJ�openg�r��rbcCr�rSrIr�rIrIrJr��r�c
Csr|rtd�gng}|�t|
|||d�t�t�f�t|||	|
||p"d|d��}|j||||||||d�}t||�S)a�Read bytes from a file while tracking progress.

    Args:
        path (Union[str, PathLike[str], BinaryIO]): The path to the file to read, or a file-like object in binary mode.
        mode (str): The mode to use to open the file. Only supports "r", "rb" or "rt".
        buffering (int): The buffering strategy to use, see :func:`io.open`.
        encoding (str, optional): The encoding to use when reading in text mode, see :func:`io.open`.
        errors (str, optional): The error handling strategy for decoding errors, see :func:`io.open`.
        newline (str, optional): The strategy for handling newlines in text mode, see :func:`io.open`
        total: (int, optional): Total number of bytes to read. Must be provided if reading from a file handle. Default for a path is os.stat(file).st_size.
        description (str, optional): Description of task show next to progress bar. Defaults to "Reading".
        auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
        transient: (bool, optional): Clear the progress on exit. Defaults to False.
        console (Console, optional): Console to write to. Default creates internal Console instance.
        refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
        style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
        complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
        finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
        disable (bool, optional): Disable display of progress.
        encoding (str, optional): The encoding to use when reading in text mode.

    Returns:
        ContextManager[BinaryIO]: A context manager yielding a progress reader.

    r}r~rir)r�r�r�r�r�rqrp)r�r�r�r�r�r?r�r�)r�r�r�r�r�r�rqrprrrsrtrurvrwrxryrzr{r�r>r�rIrIrJr��sB1�����
�

c@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_columnrKcCs||_i|_d|_dSrS)�
_table_column�_renderable_cache�_update_time)rFr�rIrIrJrE�s
zProgressColumn.__init__cCs|jpt�S)z.Get a table column, used to build tasks table.)r�r6rVrIrIrJ�get_table_column�szProgressColumn.get_table_columnr��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)rur�rCr��id�KeyError�render)rFr��current_time�	timestamp�
renderablerIrIrJ�__call__�s	�
zProgressColumn.__call__cCr�)z"Should return a renderable object.NrI�rFr�rIrIrJr�szProgressColumn.renderrS)rarbrcrdr�rre�__annotations__r6rEr�r/r�rr�rIrIrIrJr��s
r�csJeZdZdZ	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�r�r�r�c�||_t�j|d�dS�Nr�)r�rDrE)rFr�r�rGrIrJrE �zRenderableColumn.__init__r�r�rKcCr�rS)r�r�rIrIrJr�&szRenderableColumn.render)r�)
rarbrcrdr/rr6rEr�rgrIrIrGrJr�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_namerw�speed�
finished_textr�cs<t|||d�|_t|t�rt�|�n||_t�j|d�dS)N�rwr�r�)	r4�spinner�
isinstancer�r8�from_markupr�rDrE)rFr�rwr�r�r�rGrIrJrE4s��zSpinnerColumn.__init__�
spinner_stylerKcCst|||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)r4r�)rFr�r�r�rIrIrJ�set_spinnerDs
zSpinnerColumn.set_spinnerr�r�cCs$|jr|j}|S|j�|���}|SrS)�finishedr�r�r�ru)rFr��textrIrIrJr�Ss����zSpinnerColumn.render)r�r�r�r�N)r�r�)rarbrcrdr�rr5rer9r6rEr�r/r�rgrIrIrGrJr�*s<����������
�r�csdeZdZdZ					ddededed	ed
ee	dee
ddf�fd
d�
Zdddefdd�Z
�ZS)r�zA column containing text.�none�leftTN�text_formatrw�justify�markup�highlighterr�rKcs:||_||_||_||_||_t�j|ptdd�d�dS)NT��no_wrapr�)rrrwrrrDrEr6)rFrrwrrrr�rGrIrJrE_s	zTextColumn.__init__r�r�cCsR|jj|d�}|jrtj||j|jd�}n	t||j|jd�}|jr'|j�|�|S�N�r�)rwr)	r�formatrr8r�rwrr�	highlight)rFr��_textr�rIrIrJr�oszTextColumn.render)r�r�TNN)rarbrcrdr�r5r.r�rr0r6rEr8r�rgrIrIrGrJr�\s.��������r�csfeZdZdZ						ddeed	ed
ededed
eeddf�fdd�
Zddde	fdd�Z
�ZS)r�aRenders 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".
    �(rjrkrlrmN�	bar_widthrwrxryrzr�rKcs0||_||_||_||_||_t�j|d�dSr�)rrwrxryrzrDrE)rFrrwrxryrzr�rGrIrJrE�s	zBarColumn.__init__r�r�cCs^t|jdurtd|j�ndtd|j�|jdurdntd|j�|j|��|j|j|j	|j
d�	S)z&Gets a progress bar widget for a task.Nrr))	rqrC�width�pulse�animation_timerwrxryrz)r3rq�maxrCr�startedrurwrxryrzr�rIrIrJr��s
�zBarColumn.render)rrjrkrlrmN)rarbrcrdrr�r5r6rEr3r�rgrIrIrGrJr�zs0��������r�c@�"eZdZdZdddefdd�ZdS)�TimeElapsedColumnzRenders time elapsed.r�r�rKcCsD|jr|jn|j}|durtddd�Stt|�d�}tt|�dd�S)�Show time remaining.N�-:--:--�progress.elapsed�rw)�seconds)r��
finished_time�elapsedr8r	r�r�)rFr�r�deltarIrIrJr��s
zTimeElapsedColumn.renderN�rarbrcrdr8r�rIrIrIrJr��rcs�eZdZdZ								dd	ed
ededed
edee	dee
deddf�fdd�
Zedee
defdd��Zdddefdd�Z�ZS)r�aShow task progress as a percentage.

    Args:
        text_format (str, optional): Format for percentage display. Defaults to "[progress.percentage]{task.percentage:>3.0f}%".
        text_format_no_percentage (str, optional): Format if percentage is unknown. Defaults to "".
        style (StyleType, optional): Style of output. Defaults to "none".
        justify (JustifyMethod, optional): Text justification. Defaults to "left".
        markup (bool, optional): Enable markup. Defaults to True.
        highlighter (Optional[Highlighter], optional): Highlighter to apply to output. Defaults to None.
        table_column (Optional[Column], optional): Table Column to use. Defaults to None.
        show_speed (bool, optional): Show speed if total is unknown. Defaults to False.
    �-[progress.percentage]{task.percentage:>3.0f}%r�r�r�TNFr�text_format_no_percentagerwrrrr�r|rKc		s(||_||_t�j||||||d�dS)N)rrwrrrr�)rr|rDrE)	rFrrrwrrrr�r|rGrIrJrE�s
�zTaskProgressColumn.__init__r�cCsN|dur
tddd�St�t|�gd�d�\}}||}t|d�|�d�dd�S)	z�Render the speed in iterations per second.

        Args:
            task (Task): A Task object.

        Returns:
            Text: Text object containing the task speed.
        Nr�zprogress.percentager)r�u×10³u×10⁶u×10⁹u×10¹²��z.1fz it/s)r8r*�pick_unit_and_suffixr�)�clsr��unit�suffix�
data_speedrIrIrJ�render_speed�s
�zTaskProgressColumn.render_speedr�r�cCs�|jdur|jr|�|jp|j�S|jdur|jn|j}|j|d�}|jr0t	j
||j|jd�}n	t	||j|jd�}|j
rB|j
�|�|Sr)rqr|r&�finished_speedr�rrrrr8r�rwrrr	)rFr�rr
r�rIrIrJr��s�zTaskProgressColumn.render)rr�r�r�TNNF)rarbrcrdr�r5r.r�rr0r6rE�classmethodrer8r&r�rgrIrIrGrJr��s@��������	�
�r�csPeZdZdZdZ			ddededeef�fdd	�
Zd
dde	fd
d�Z
�ZS)r�aRenders estimated time remaining.

    Args:
        compact (bool, optional): Render MM:SS when time remaining is less than an hour. Defaults to False.
        elapsed_when_finished (bool, optional): Render time elapsed when the task is finished. Defaults to False.
    ��?FN�compact�elapsed_when_finishedr�cs||_||_t�j|d�dSr�)r*r+rDrE)rFr*r+r�rGrIrJrEszTimeRemainingColumn.__init__r�r�rKcCs�|jr|jr|j}d}n|j}d}|jdurtd|d�S|dur.t|jr)d|d�Sd|d�Stt|�d�\}}t|d�\}}|jrM|sM|d	�d
|d	��}n
|d�d
|d	�d
|d	��}t||d�S)rrzprogress.remainingNr�rz--:--r�<�02d�:�d)	r+r�r�time_remainingrqr8r*�divmodr�)rFr��	task_timerw�minutesr�hours�	formattedrIrIrJr�s

zTimeRemainingColumn.render)FFN)rarbrcrdr�r�rr6rEr8r�rgrIrIrGrJr��s����
r�c@r)�FileSizeColumnzRenders completed filesize.r�r�rKcCst�t|j��}t|dd�S)�Show data completed.zprogress.filesizer)r*�decimalr�rCr8�rFr��	data_sizerIrIrJr�,szFileSizeColumn.renderNrrIrIrIrJr6)rr6c@r)�TotalFileSizeColumnzRenders total filesize.r�r�rKcCs*|jdur
t�t|j��nd}t|dd�S)r7Nr�zprogress.filesize.totalr)rqr*r8r�r8r9rIrIrJr�5szTotalFileSizeColumn.renderNrrIrIrIrJr;2rr;csBeZdZdZd
dedeef�fdd�
Zdd	d
efdd�Z	�Z
S)�MofNCompleteColumnaHRenders completed count/total, e.g. '  10/1000'.

    Best for bounded tasks with int quantities.

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

    Args:
        separator (str, optional): Text to separate completed and total values. Defaults to "/".
    �/N�	separatorr�cr�r�)r>rDrE)rFr>r�rGrIrJrEGszMofNCompleteColumn.__init__r�r�rKcCsPt|j�}|jdurt|j�nd}tt|��}t||�d��|j�|��dd�S)zShow completed/total.N�?r/�progress.downloadr)r�rCrqr�r�r8r>)rFr�rCrq�total_widthrIrIrJr�Ks
�zMofNCompleteColumn.render)r=N)rarbrcrdr�rr6rEr8r�rgrIrIrGrJr<;sr<csHeZdZdZ	d
dedeeddf�fdd�
Zd	d
defdd�Z	�Z
S)r�z�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_unitsr�rKcr�r�)rBrDrE)rFrBr�rGrIrJrE]r�zDownloadColumn.__init__r�r�cCs�t|j�}|jdurt|j�n|}|jr t�|gd�d�\}}nt�|gd�d�\}}|dkr1dnd}||}|d|�d	��}|jdurVt|j�}	|	|}
|
d|�d	��}nd
}|�d|�d|��}t|d
d�}
|
S)z.Calculate common unit for completed and total.N)	r��KiB�MiB�GiB�TiB�PiB�EiB�ZiB�YiBi)	r��kB�MB�GB�TB�PB�EB�ZB�YBr r)rz,.�fr?r=r�r@r)r�rCrqrBr*r!r8)rFr�rC� unit_and_suffix_calculation_baser#r$�	precision�completed_ratio�
completed_strrq�total_ratio�	total_str�download_status�
download_textrIrIrJr�cs2
�
��

zDownloadColumn.render)FN)rarbrcrdr�rr6rEr8r�rgrIrIrGrJr�Vs����r�c@r)�TransferSpeedColumnz&Renders human readable transfer speed.r�r�rKcCs@|jp|j}|durtddd�St�t|��}t|�d�dd�S)zShow data transfer speed.Nr?zprogress.data.speedrz/s)r'r�r8r*r8r�)rFr�r�r%rIrIrJr��s
zTransferSpeedColumn.renderNrrIrIrIrJr\�rr\c@s$eZdZUdZeed<	eed<dS)�ProgressSamplez$Sample of progress for a given time.r�rCN)rarbrcrdrer�rIrIrIrJr]�s
r]c@s�eZdZUdZeed<	eed<	eeed<	eed<	e	ed<	dZ
eeed<	d	Zeed
<	e
ed�Zeeefed<	e
dd
d
d�Zeeed<	e
dd
d
d�Zeeed<	dZeeed<	e
dd�d
d
d�Zeeed<e
d
ed�Zeed<	defdd�Zedefdd��Zedeefdd��Zedeefdd ��Zedefd!d"��Zedefd#d$��Z edeefd%d&��Z!edeefd'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.

    r�rprqrC�	_get_timeNrT�visible)�default_factory�fieldsF)�default�init�repr�
start_time�	stop_timer'cCs
tdd�S)Nr )�maxlenrrIrIrIrJ�<lambda>�s
z
Task.<lambda>)r`rcrd�	_progress)rdr`�_lockrKcCs|��S)z(float: Get the current time, in seconds.)r^rVrIrIrJru�r�z
Task.get_timecC�
|jduS)z#bool: Check if the task as started.N)rerVrIrIrJr��
zTask.startedcCs|jdurdS|j|jS)zPOptional[float]: Get the number of steps remaining, if a non-None total was set.N)rqrCrVrIrIrJ�	remaining�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)rerfrurVrIrIrJr�s


zTask.elapsedcCrk)zCheck if the task has finished.N)rrVrIrIrJr��rlz
Task.finishedcCs.|jsdS|j|jd}tdtd|��}|S)zOfloat: Get progress of task as a percentage. If a None total was set, returns 0��Y@)rqrC�minr)rFrCrIrIrJ�
percentage�s
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.Nr�rcs��|]}|jVqdSrSr�)�.0�samplerIrIrJ�	<genexpr>��zTask.speed.<locals>.<genexpr>)rerjrir��iterr�r�)rFr>�
total_time�
iter_progress�total_completedr�rIrIrJr��s"
��$�z
Task.speedcCs:|jrdS|j}|sdS|j}|durdSt||�}|S)zJOptional[float]: Get estimated time to completion, or ``None`` if no data.rnN)r�r�rmr)rFr�rm�estimaterIrIrJr0szTask.time_remainingcCs|j��d|_d|_dS)zReset progress.N)ri�clearrr'rVrIrIrJ�_resets

zTask._resetr`)$rarbrcrdr:r�r�rre�GetTimeCallablerr_r�r�dictrarrrerfr'rirr]rrjrur�rrmrr�rqr�r0r}rIrIrIrJr��sZ

�
r�c@speZdZdZddddddddddd�
deeefd	eed
e	de
de
d
e	de	de	deede	de	ddfdd�Ze
deedffdd��Zedefdd��Zedeefdd��Zedeefdd��Zede	fdd ��Zdmd!d"�Zdmd#d$�Zdnd%d&�Zd'eeed(eed)eeddfd*d+�Z			,	-dod.eee e!e fd/ee
d0eed1ed2e
dee fd3d4�Z"	dpdd5d6�d7e#d/ee$d0eed1ede#f
d8d9�Z%e&j'	:			dqddd5d;�d7eed<e(fd=e)d>d?e$d@eedAeedBeed/ee$d0eed1ede#fdCdD��Z*e&j'	:			dqddd5d;�d7eed<e(fd=ee)dEe)dFfd?e$d@eedAeedBeed/ee$d0eed1ede+fdGdD��Z*	E	:			drddd5d;�d7eed<e(fd=ee)d>e)dFe)dEfd?e$d@eedAeedBeed/ee$d0eed1edee#e+ffdHdD�Z*d0eddfdIdJ�Z,d0eddfdKdL�Z-dddddddM�d0ed/ee
dNee
dOee
d1eedPee	dQe	dRe.ddfdSdT�Z/dddUdddV�d0edWe	d/ee
dNe$dPee	d1eedRe.ddfdXdY�Z0dsd0edOe
ddfd[d\�Z1dmd]d^�Z2de3fd_d`�Z4dee3fdadb�Z5dceede6fddde�Z7de3fdfdg�Z8		h	U	dtd1edWe	d/ee
dNe$dPe	dRe.defdidj�Z9d0eddfdkdl�Z:dS)ur?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.
    NTrig>@F)
rsrrrv�speed_estimate_periodrt�redirect_stdout�redirect_stderrrur{�expandr�rsrrrvr�rtr�r�rur{r�rKc
	Gs�|dksJd��t�|_|p|��|_||_|	|_|
|_i|_td�|_	t
|p)t�||||||jd�|_
|p9|jj|_|jj|_|jj|_dS)Nrzrefresh_per_second must be > 0)rsrrrvrtr�r��get_renderable)rrj�get_default_columnsr�r�r{r��_tasksr:�_task_indexr2r+r��liversru�print�log)rFrsrrrvr�rtr�r�rur{r�r�rIrIrJrE*s(
�	
zProgress.__init__.cCstd�t�t�t�fS)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�)r"rIrIrJr�Ns
�zProgress.get_default_columnscCr�rS)r�rsrVrIrIrJrsmr�zProgress.consolecC�8|j�t|j���Wd�S1swYdS)zGet a list of Task instances.N)rj�listr��valuesrVrIrIrJ�tasksq�$�zProgress.taskscCr�)zA list of task IDs.N)rjr�r��keysrVrIrIrJ�task_idswr�zProgress.task_idscCsZ|j� |js	Wd�dStdd�|j��D��Wd�S1s&wYdS)z'Check if all tasks have been completed.NTcsrrrS)r�)rsr�rIrIrJru�rvz$Progress.finished.<locals>.<genexpr>)rjr��allr�rVrIrIrJr�}s�$�zProgress.finishedcCs|js|jjdd�dSdS)zStart the progress display.T)rLN)r{r�rUrVrIrIrJrU�s�zProgress.startcCs$|j��|jjs|j��dSdS)zStop the progress display.N)r�r�rs�is_interactiver�rVrIrIrJr��s
�z
Progress.stopcCrRrSrTrVrIrIrJrW�rXzProgress.__enter__rYrZr[cCr�rS)r�r^rIrIrJr_�r�zProgress.__exit__rhrnrorqr@rprAccs��d}|durt|t�rtt|��}n|}|dur!|j||d�}n|j||d�|jjrTt|||��}|D]}|V|j	d7_	q5Wd�dS1sMwYdS|j
}	|j}
|D]
}|V|	|d�|
�q\dS)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�rqr))r�rrer��add_taskrOr�rrr=rCrMrL)rFrorqr@rprA�
task_total�track_thread�valuerMrLrIrIrJr��s0�
��"�
�zProgress.trackr�)r@rpr�cCs�d}|dur	|}n|dur&|j�|j|j}Wd�n1s!wY|dur.td��|dur:|j||d�}n|j||d�t|||dd�S)ajTrack 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�)rjr�rq�
ValueErrorr�rOr�)rFr�rqr@rp�total_bytesrIrIrJr��s��zProgress.wrap_filer�)rqr@rpr�r�r�r�r�r�r�c
Cr�rSrI�
rFr�r�r�r�r�r�rqr@rprIrIrJr���z
Progress.openr�r�c
Cr�rSrIr�rIrIrJr�r�cCs�d�t|dd��}
|
dvrtd�|���|dk}|
dkr)|dkr)t�dt�d	}n|
d
ks1|
dkr?|dkr9td
��|dkr?d	}|durHt|�j}|durT|j	|	|d�}n|j
||d�tj|d|d�}t
|||dd�}
|dkss|d
kr}tj|
||||d�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�zinvalid mode {!r}r)r�zaline buffering (buffering=1) isn't supported in binary mode, the default buffer size will be usedr�r�r�rzcan't have unbuffered text I/ONr�r�)r�Tr�)r�r�r��line_buffering)r]�sortedr�r�warnings�warn�RuntimeWarningr�st_sizer�rO�ior�r��
TextIOWrapper)rFr�r�r�r�r�r�rqr@rp�_moder�r�r�rIrIrJr�s>!�
�cCsZ|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)rjr�reru)rFr@r�rIrIrJ�
start_taskas	

�"�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)rjr�rurerf)rFr@r�r�rIrIrJ�	stop_taskos

"�zProgress.stop_task)rqrCrMrpr_rLrCrMr_rLracKsH|j��|j|}	|	j}
|dur||	jkr||	_|	��|dur'|	j|7_|dur.||	_|dur5||	_|dur<||	_|	j�|�|	j|
}|�	�}||j
}
|	j}|j}|rk|dj
|
krk|�|rk|dj
|
ks_|dkrw|�t||��|	jdur�|	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.
        Nr)rjr�rCrqr}rpr_rarOrur�ri�popleftr��appendr]rrrL)rFr@rqrCrMrpr_rLrar��completed_start�update_completedr��old_sample_timerir�rIrIrJrO~sD


�

��"�zProgress.updater)rUrqrCr_rprUc
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.
            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)rurjr�r}rerqrCr_rarprrL)
rFr@rUrqrCr_rprar�r�rIrIrJ�reset�s"
�zProgress.resetr)c
Cs*|��}|j��|j|}|j}|j|7_|j|}||j}|j}|j}	|r<|dj|kr<|	�|r<|dj|ks0t|�dkrK|	�t|�dksB|�	t
||��|jdurs|j|jkr{|jdur�|j
|_|j|_Wd�dSWd�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)rurjr�rCr�rir�r�r�r�r]rqrrr�r')
rFr@rMr�r�r�r�r�rir�rIrIrJrM�s8


��


���"�zProgress.advancecCs$|js|jjr|j��dSdSdS)z*Refresh (render) the progress information.N)r{r��
is_startedrLrVrIrIrJrLs�zProgress.refreshcCst|���}|S)z*Get a renderable for the progress display.)r-�get_renderables)rFr�rIrIrJr�szProgress.get_renderableccs�|�|j�}|VdS)z5Get a number of renderables for the progress display.N)�make_tasks_tabler�)rF�tablerIrIrJr�
s�
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)TrN)r�r�r6r��copy)rs�_columnrIrIrJrus���

�z,Progress.make_tasks_table.<locals>.<genexpr>)rr))�paddingr�c3s.�|]}t|t�r|j�d�n|��VqdS)rN)r�r�r)rs�columnrrIrJru%s���
�)r�r7�gridr�r_�add_row)rFr��
table_columnsr�rIrrJr�s	�
���
zProgress.make_tasks_tablecCs2|j�|��Wd�S1swYdS)z+Makes the Progress class itself renderable.N)rjr�rVrIrIrJ�__rich__0s$�zProgress.__rich__roc	Ks�|j�2t|j||||||j|jd�}||j|j<|r!|�|j�|j}tt|j�d�|_Wd�n1s8wY|��|S)aAdd 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_rar^rjr)N)	rjr�r�rur�r�r:r�rL)	rFrprUrqrCr_rar��new_task_indexrIrIrJr�5s&�
�zProgress.add_taskcCs4|j�
|j|=Wd�dS1swYdS)z]Delete a task if it exists.

        Args:
            task_id (TaskID): A task ID.

        N)rjr�)rFr@rIrIrJ�remove_task`s
"�zProgress.remove_taskr`)rKr?)NNrhrnrS�r�NNN�r�r�NNN)r))TrorT);rarbrcrdr%r�r�rr,r�rer~rEr(r"r�r�rsrr�r�r:r�r�rUr�rWr#rfrr_rr;r r�rr�r��typing�overloadr�r(r�r!r�r�rrOr�rMrLr/r�r�r7r�r�r�r�rIrIrIrJr?s�
�������	�
���
�$



���
�������
�1������
�*�	�������	�
����	�������	�
����	�������	�
��

�M�������	�
�
�A�������	�

�'
!�������
�+r?�__main__)�Panel)�Rule)�Syntax)r7a~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_numbersZfoo�barZbaz�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...ZexamplezPretty printed)�typer�z	Syntax...zGive it a try!)�cycle)�record)rsrtz[red]Downloadingr r�z[green]Processingz[yellow]Thinkingr)r�g333333�?g{�G�z�?�d)rhNTNFNrirjrkrlrmrnFTr�r�)�r��sysr�r��abcrr�collectionsr�collections.abcr�dataclassesrr�datetimer	r
r�mathrr
�osrr�	threadingrrr�typesrrrrrrrrrrrrrr r!r"r#r$r%�version_infor(Zpip._vendor.typing_extensionsr�r*r+rsr,r-r.r/rr0�jupyterr1r�r2�progress_barr3r�r4rwr5r�r6r7r�r8r9r�r:r;rer~r<r=r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r6r;r<r�r\r]r�r?ra�random�time�panelr��ruler��syntaxr�r�Zprogress_renderables�	itertoolsr�Zexamplesr�r>r�Ztask1Ztask2Ztask3r�rO�sleep�randintr�r�rIrIrIrJ�<module>s�P

*���������	�
���
���
�Fd��������	�
���
��
�A���������	�
���
�����������������	�
���
�����������������	�
���
�������
�V*2*I0		1	}
U��
����

��$��