%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/rich/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/rich/__pycache__/progress.cpython-312.pyc

�

"T�e7��+�
�ddlZddlZddlZddlZddlmZmZddlmZddl	m
Z
mZddlm
Z
ddlmZmZddlmZddlmZdd	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/ej`dk\rddlm1Z1nddl2m1Z1ddl3m4Z4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:ddl;m<Z<ddl=m>Z>ddl?m@Z@ddlAmBZBddlCmDZDddlEmFZFddlGmHZHmIZIddlJmKZKmLZLe(deM�ZNe.d�ZOe gePfZQej\de+e�ZRGd�de�ZS														d�d'e/e*eOe%eOfd(eTd)e)ePd*eUd+e)e7d,eUd-e)e gePfd.ePd/eFd0eFd1eFd2eFd3ePd4eUd5eUd6e%eOf d7�ZVGd8�d9ee�ZWGd:�d;e!eRe$eR�ZXd<d dd!dd"d#d$d%d&d!d=�d>ed)eMd(eTd*eUd+e)e7d,eUd-e)e gePfd.ePd/eFd0eFd1eFd2eFd4eUd6e!efd?�ZYej�				d�dd<d dd!dd"d#d$d%d&d!d@�d>e/eTdAe[fdBe/e1dCe1dDfdEeMdFe)eTdGe)eTdHe)eTd)e)eMd(eTd*eUd+e)e7d,eUd-e)e gePfd.ePd/eFd0eFd1eFd2eFd4eUd6e!e+f&dI��Z\ej�				d�dd<d dd!dd"d#d$d%d&d!d@�d>e/eTdAe[fdBe1dJdEeMdFe)eTdGe)eTdHe)eTd)e)eMd(eTd*eUd+e)e7d,eUd-e)e gePfd.ePd/eFd0eFd1eFd2eFd4eUd6e!ef&dK��Z\					d�dd<d dd!dd"d#d$d%d&d!d@�d>e/eTdAe[fdBe/e1dJe1dCe1dDfdEeMdFe)eTdGe)eTdHe)eTd)e)eMd(eTd*eUd+e)e7d,eUd-e)e gePfd.ePd/eFd0eFd1eFd2eFd4eUd6e/e!ee!e+ff&dL�Z\GdM�dNe�Z]GdO�dPe]�Z^GdQ�dRe]�Z_GdS�dTe]�Z`GdU�dVe]�ZaGdW�dXe]�ZbGdY�dZe`�ZcGd[�d\e]�ZdGd]�d^e]�ZeGd_�d`e]�ZfGda�dbe]�ZgGdc�dde]�ZhGde�dfe]�ZiGdg�dhe'�Zje
Gdi�dj��ZkGdk�dle>�Zlemdmk(�rhddlnZnddloZoddnlpmqZqddolrmsZsddpltmuZuddqlGmIZIeudrdsd �t�ZteIdudvdw�ZGeGj�dxdydz�d{eqd|�d}eGd~dd�d��d�etesd��g	Zwdd�lxmyZyeyew�Zze7d ���Z6ele_�gelj���eb���e6d!d���5Z|e|j�d�d����Z~e|j�d�d����Ze|j�d�d���Z�e|�jsxe|�je~d����e|�jed����eo�jd��en�jdd��dkre|�je�ez��e|�js�xddd�yy#1swYyxYw)��N)�ABC�abstractmethod��deque)�	dataclass�field)�	timedelta)�	RawIOBase�UnsupportedOperation)�ceil)�mmap)�length_hint)�PathLike�stat)�Event�RLock�Thread)�
TracebackType)�Any�BinaryIO�Callable�ContextManager�Deque�Dict�Generic�Iterable�List�
NamedTuple�NewType�Optional�Sequence�TextIO�Tuple�Type�TypeVar�Union)��)�Literal�)�filesize�get_console)�Console�Group�
JustifyMethod�RenderableType)�Highlighter)�JupyterMixin)�Live)�ProgressBar)�Spinner)�	StyleType)�Column�Table)�Text�TextType�TaskID�ProgressType�_Ic�p��eZdZdZdddddef�fd�Zdd
�Zdd�Zdee	e
d
ee
deedd	fd�Z�xZ
S)�_TrackThreadz)A thread to periodically update progress.�progress�Progress�task_idr;�
update_periodc�x��||_||_||_t�|_d|_t�|��y)Nr)r@rBrCr�done�	completed�super�__init__)�selfr@rBrC�	__class__s    ��//usr/lib/python3/dist-packages/rich/progress.pyrHz_TrackThread.__init__Bs4��� ��
����*����G��	����
�����returnNc�T�|j}|jj}|j}d}|jj
}||�s(|j}||k7r||||z
�|}||�s�(|jj|j|jd��y)NrT)rF�refresh)rBr@�advancerCrE�waitrF�update)rIrBrPrC�last_completedrQrFs       rK�runz_TrackThread.runKs����,�,���-�-�'�'���*�*�
����y�y�~�~���}�%����I���*����^�!;�<�!*��	�}�%�	
�
�
���T�\�\�T�^�^�T��RrLc�&�|j�|S�N��start�rIs rK�	__enter__z_TrackThread.__enter__Y����
�
���rL�exc_type�exc_val�exc_tbc�X�|jj�|j�yrV)rE�set�join�rIr\r]r^s    rK�__exit__z_TrackThread.__exit__]s��	
�	�	�
�
���	�	�rL�rMN)rMr?)�__name__�
__module__�__qualname__�__doc__�floatrHrTrZr r$�
BaseExceptionrrc�
__classcell__�rJs@rKr?r??sj���3����h��u��S����4�
�.�/���-�(����'�	�

�rLr?TF�
�bar.back�bar.complete�bar.finished�	bar.pulse�sequence�description�total�auto_refresh�console�	transient�get_time�refresh_per_second�style�complete_style�finished_style�pulse_stylerC�disable�
show_speedrMc
#�*K�|rtd�gng}|jt||	|
|��t|��t	d��f�t||||||xsd|
d��}|5|j
||||��Ed	{���d	d	d	�y	7�
#1swYy	xYw�w)
a�Track progress by iterating over a sequence.

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

    �([progress.description]{task.description}�rzr{r|r})rT)�elapsed_when_finishedrm�rurvrwrxryr~)rtrsrCN)�
TextColumn�extend�	BarColumn�TaskProgressColumn�TimeRemainingColumnrA�track)rrrsrtrurvrwrxryrzr{r|r}rCr~r�columnsr@s                 rKr�r�gs�����PEP��>�	?�@�UW���N�N���-�-�'�	
�
�*�5��d�;�		
���	�!����-�3����H�
�
��>�>��E�{�-�"�
�	
�	
�
�
�	
��
�
�s0�AB�B�7B�8B�<	B�B�B�Bc��eZdZdZ	d'dedddededdf
d	�Zd(d
�Zde	e
ede	ed
e	eddfd�Z
defd�Zdefd�Zedefd��Zdefd�Zdefd�Zedefd��Zedefd��Zdefd�Zdefd�Zdefd�Zd)dedefd�Zdeeee ffd�Z!d)dedefd�Z"d)dede#efd�Z$d*d �Z%d+d!ed"edefd#�Z&defd$�Z'd%e(defd&�Z)y),�_Readerz9A reader that tracks progress while it's being read from.�handler@rA�task�close_handlerMNc�J�||_||_||_||_d|_y�NF)r�r@r�r��_closed)rIr�r@r�r�s     rKrHz_Reader.__init__�s(����� ��
���	�(�����rLc�:�|jj�|SrV)r�rZrYs rKrZz_Reader.__enter__�s���������rLr\r]r^c�$�|j�yrV)�closerbs    rKrcz_Reader.__exit__�s
��	
�
�
�rLc��|SrV�rYs rK�__iter__z_Reader.__iter__�s���rLc��t|j�}|jj|jt|���|S�N�rP)�nextr�r@rPr��len)rI�lines  rK�__next__z_Reader.__next__�s4���D�K�K� ���
�
���d�i�i��T���;��rLc��|jSrV)r�rYs rK�closedz_Reader.closed�s���|�|�rLc�6�|jj�SrV)r��filenorYs rKr�z_Reader.fileno�����{�{�!�!�#�#rLc�6�|jj�SrV)r��isattyrYs rKr�z_Reader.isatty�r�rLc�.�|jjSrV)r��moderYs rKr�z_Reader.mode�����{�{���rLc�.�|jjSrV)r��namerYs rKr�z_Reader.name�r�rLc�6�|jj�SrV)r��readablerYs rKr�z_Reader.readable�����{�{�#�#�%�%rLc�6�|jj�SrV)r��seekablerYs rKr�z_Reader.seekable�r�rLc��yr�r�rYs rK�writablez_Reader.writable�s��rL�sizec��|jj|�}|jj|jt|���|Sr�)r��readr@rPr�r�)rIr��blocks   rKr�z_Reader.read�s:����� � ��&���
�
���d�i�i��U���<��rL�bc��|jj|�}|jj|j|��|Sr�)r��readintor@rPr�)rIr��ns   rKr�z_Reader.readinto�s6���K�K� � ��#���
�
���d�i�i���3��rLc��|jj|�}|jj|jt|���|Sr�)r��readliner@rPr�r�)rIr�r�s   rKr�z_Reader.readline�s:���{�{�#�#�D�)���
�
���d�i�i��T���;��rL�hintc	��|jj|�}|jj|jtt
t|����|Sr�)r��	readlinesr@rPr��sum�mapr�)rIr��liness   rKr�z_Reader.readlines�sA�����%�%�d�+���
�
���d�i�i��S��e�_�1E��F��rLc�^�|jr|jj�d|_y)NT)r�r�r�r�rYs rKr�z
_Reader.closes"������K�K������rL�offset�whencec��|jj||�}|jj|j|��|S)N�rF)r��seekr@rRr�)rIr�r��poss    rKr�z_Reader.seeks8���k�k���v�v�.���
�
���T�Y�Y�#��6��
rLc�6�|jj�SrV)r��tellrYs rKr�z_Reader.tell
s���{�{���!�!rL�sc��td��)N�write)r)rIr�s  rKr�z
_Reader.write
s
��"�7�+�+rL)T)rMr�)���rd)r)*rerfrgrhrr;�boolrHrZr r$rjrrcr��bytesr��propertyr��intr�r��strr�r�r�r�r�r�r&�	bytearray�
memoryviewr
r�r�rr�r�r�r�rr�r�rLrKr�r��s���C�"�������	�
��
�
����4�
�.�/���-�(����'�	�

���(���%��
������$��$�$��$�� �c� �� �� �c� �� �&�$�&�&�$�&��$�����e��
�%�	�:�t� ;�<��
�S��%��
�c��4��;��
�
�3����C��
"�c�"�,�s�,�s�,rLr�c�`�eZdZdZdddeddfd�Zdefd�Zd	eee	d
ee	dee
ddfd�Zy)
�_ReadContextzEA utility class to handle a context for both a reader and a progress.r@rA�readerrMNc� �||_||_yrV)r@r�)rIr@r�s   rKrHz_ReadContext.__init__s�� ��
� ��rLc�j�|jj�|jj�SrV)r@rXr�rZrYs rKrZz_ReadContext.__enter__s%���
�
�����{�{�$�$�&�&rLr\r]r^c�r�|jj�|jj|||�yrV)r@�stopr�rcrbs    rKrcz_ReadContext.__exit__s*��	
�
�
���������X�w��7rL)rerfrgrhr=rHrZr r$rjrrcr�rLrKr�r�sj��O�!��!�R�!�D�!�'�2�'�8��4�
�.�/�8��-�(�8���'�	8�

�8rLr��
Reading...)rsrurvrwrxryrzr{r|r}r~�filec
���|rtd�gng}
|
jt||	|
|��t�t	�f�t|
|||||xsd|d��}|j
|||��}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�rmr�)rtrs)r�r�r��DownloadColumnr�rA�	wrap_filer�)r�rtrsrurvrwrxryrzr{r|r}r~r�r@r�s                rKr�r�&s���JEP��>�	?�@�UW���N�N���-�-�'�	
�
���!�		
���	�!����-�3����H��
�
��E�{�
�
K�F���&�)�)rL)rtrsrurvrwrxryrzr{r|r}r~�
PathLike[str]r��rt�r�	buffering�encoding�errors�newlinec��yrVr��r�r�r�r�r�r�rtrsrurvrwrxryrzr{r|r}r~s                  rK�openr�g���,	rL�rbc��yrVr�r�s                  rKr�r��r�rLc
��|rtd�gng}|jt|
|||��t�t	�f�t|||	|
||xsd|d��}|j
||||||||��}t||�S)a�Read bytes from a file while tracking progress.

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

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

    r�r�rmr�)r�r�r�r�r�rtrs)r�r�r�r�r�rAr�r�)r�r�r�r�r�r�rtrsrurvrwrxryrzr{r|r}r~r�r@r�s                     rKr�r��s���bEP��>�	?�@�UW���N�N���-�-�'�	
�
���!�		
���	�!����-�3����H��]�]��
��������	�F���&�)�)rLc�t�eZdZUdZdZeeed<ddeeddfd�Z	defd�Z
dd	defd
�Ze
dd	defd��Zy)
�ProgressColumnz3Base class for a widget to use in progress display.N�max_refresh�table_columnrMc�.�||_i|_d|_yrV)�
_table_column�_renderable_cache�_update_time)rIr�s  rKrHzProgressColumn.__init__�s��)���MO���-1��rLc�2�|jxs
t�S)z.Get a table column, used to build tasks table.)r�r7rYs rK�get_table_columnzProgressColumn.get_table_column�s���!�!�-�V�X�-rLr��Taskc�.�|j�}|j�=|js1	|j|j\}}||jz|kDr|S|j
|�}||f|j|j<|S#t
$rY�9wxYw)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).
        )rxr�rFr��id�KeyError�render)rIr��current_time�	timestamp�
renderables     rK�__call__zProgressColumn.__call__�s����}�}������'����
&�(,�(>�(>�t�w�w�(G�%�	�:��t�/�/�/�,�>�%�%��[�[��&�
�+7��*D����t�w�w�'�����
��
�s�B�	B�Bc��y)z"Should return a renderable object.Nr��rIr�s  rKrzProgressColumn.renders�rLrV)rerfrgrhr�r ri�__annotations__r7rHr�r0rrrr�rLrKr�r��sl��=�#'�K��%��'�2�X�f�%5�2��2�
.�&�.��V����.�1�6�1�n�1��1rLr�c�L��eZdZdZ	ddd�dedeef�fd�Zddd	efd
�Z�xZ	S)�RenderableColumnz�A column to insert an arbitrary column.

    Args:
        renderable (RenderableType, optional): Any renderable. Defaults to empty string.
    N�r�rr�c�4��||_t�|�	|��y�Nr
)rrGrH)rIrr�rJs   �rKrHzRenderableColumn.__init__ s���%���
���l��3rLr�r�rMc��|jSrV)rrs  rKrzRenderableColumn.render&s�����rL)�)
rerfrgrhr0r r7rHrrkrls@rKr	r	sB����,.�4�SW�4�(�4�@H��@P�4��6��n�rLr	c���eZdZdZ					ddedeedededee	f
�fd�
Z
		dded	eeded
dfd�Zdd
d
efd�Z
�xZS)�
SpinnerColumna�A column with a 'spinner' animation.

    Args:
        spinner_name (str, optional): Name of spinner animation. Defaults to "dots".
        style (StyleType, optional): Style of spinner. Defaults to "progress.spinner".
        speed (float, optional): Speed factor of spinner. Defaults to 1.0.
        finished_text (TextType, optional): Text used when task is finished. Defaults to " ".
    N�spinner_namerz�speed�
finished_textr�c���t|||��|_t|t�rt	j
|�n||_t�|�!|��y)N�rzrr
)	r5�spinner�
isinstancer�r9�from_markuprrGrH)rIrrzrrr�rJs      �rKrHzSpinnerColumn.__init__4sN����|�5��F����-��-�
���]�+��	
��
	���l��3rL�
spinner_stylerMc�*�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.
        rN)r5r)rIrrrs    rK�set_spinnerzSpinnerColumn.set_spinnerDs���|�=��N��rLr�r�c��|jr|j}|S|jj|j	��}|SrV)�finishedrrrrx)rIr��texts   rKrzSpinnerColumn.renderSsH���}�}�
���	
�
�����$�$�T�]�]�_�5�	
�
�rL)�dots�progress.spinner��?� N)r r!)rerfrgrhr�r r6rir:r7rHrr0rrkrls@rKrr*s�����#�%7��"%�)-�
4��4��	�"�4��	4�
 �4��v�&�
4�&.@��	
O��
O� �	�*�
O��	
O�

�
O��6��n�rLrc�h��eZdZdZ					ddededededee	dee
d	df�fd
�
Zddd	efd
�Z
�xZS)r�zA column containing text.N�text_formatrz�justify�markup�highlighterr�rMc���||_||_||_||_||_t
�|�|xstd����y)NT��no_wrapr
)r$r%rzr&r'rGrHr7)rIr$rzr%r&r'r�rJs       �rKrHzTextColumn.__init___sD���'���&-�����
����&���
���l�&J�f�T�6J��KrLr�r�c�B�|jj|��}|jr-tj||j
|j��}n"t||j
|j��}|jr|jj|�|S�N�r�)rzr%)	r$�formatr&r9rrzr%r'�	highlight)rIr��_textrs    rKrzTextColumn.renderosv��� � �'�'�T�'�2���;�;��#�#�E����T�\�\�R�D���T�Z�Z����F�D�������&�&�t�,��rL)�none�leftTNN)rerfrgrhr�r6r/r�r r1r7rHr9rrkrls@rKr�r�\s����#�
"�!'��-1�)-�L��L��L��	L�
�L��k�*�
L��v�&�L�
�L� �6��d�rLr�c�j��eZdZdZ						ddeedededededeed	df�fd
�
Zddd	e	fd
�Z
�xZS)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".
    N�	bar_widthrzr{r|r}r�rMc�l��||_||_||_||_||_t
�|�|��yr)r4rzr{r|r}rGrH)rIr4rzr{r|r}r�rJs       �rKrHzBarColumn.__init__�s;���#�����
�,���,���&���
���l��3rLr�r�c�\�t|j�td|j�ndtd|j�|j�dntd|j�|j
|j
�|j|j|j|j��	S)z&Gets a progress bar widget for a task.Nrr*)	rtrF�width�pulse�animation_timerzr{r|r})r4rt�maxrFr4�startedrxrzr{r|r}rs  rKrzBarColumn.render�s����(,�
�
�(>�#�a����$�D��!�T�^�^�,��.�.�0�$�c�!�T�^�^�6L��l�l�"��=�=�?��*�*��.�.��.�.��(�(�

�
	
rL)�(rnrorprqN)rerfrgrhr r�r6r7rHr4rrkrls@rKr�r�zs�����$&�%�$2�$2�!,�)-�4��C�=�4��4�"�	4�
"�4��
4��v�&�4�
�4� 
�6�
�k�
rLr�c� �eZdZdZdddefd�Zy)�TimeElapsedColumnzRenders time elapsed.r�r�rMc���|jr|jn|j}|�
tdd��St	tdt
|����}tt|�d��S)zShow time elapsed.�-:--:--�progress.elapsed�rzr)�seconds)r�
finished_time�elapsedr9r	r:r�r�)rIr�rE�deltas    rKrzTimeElapsedColumn.render�sS��(,�
�
�$�$�$�4�<�<���?��	�);�<�<��#�a��W��"6�7���C��J�&8�9�9rLN�rerfrgrhr9rr�rLrKr>r>�s���:�6�:�d�:rLr>c���eZdZdZ								ddedededededee	d	ee
d
eddf�fd�
Zed
ee
defd��Zdddefd�Z�xZS)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.
    Nr$�text_format_no_percentagerzr%r&r'r�rrMc	�L��||_||_t�	|�
||||||��y)N)r$rzr%r&r'r�)rIrrGrH)
rIr$rIrzr%r&r'r�rrJs
         �rKrHzTaskProgressColumn.__init__�s9���*C��&�$���
���#����#�%�
	�	
rLrc��|�
tdd��Stjt|�gd�d�\}}||z}t|d�|�d�d��S)z�Render the speed in iterations per second.

        Args:
            task (Task): A Task object.

        Returns:
            Text: Text object containing the task speed.
        rzprogress.percentagerB)ru×10³u×10⁶u×10⁹u×10¹²��z.1fz it/s)r9r+�pick_unit_and_suffixr�)�clsr�unit�suffix�
data_speeds     rK�render_speedzTaskProgressColumn.render_speed�s_���=���"7�8�8��4�4���J�<��
���f�
�T�\�
��z�#�&�v�h�e�4�<Q�R�RrLr�r�c��|j�5|jr)|j|jxs|j�S|j�|j
n|j}|j|��}|jr-tj||j|j��}n"t||j|j��}|jr|jj|�|Sr,)rtrrR�finished_speedrrIr$r.r&r9rrzr%r'r/)rIr�r$r0rs     rKrzTaskProgressColumn.render�s����:�:��$�/�/��$�$�T�%8�%8�%F�D�J�J�G�G�.2�j�j�.@�D�*�*�d�FV�FV�	��"�"��"�-���;�;��#�#�E����T�\�\�R�D���T�Z�Z����F�D�������&�&�t�,��rL)z-[progress.percentage]{task.percentage:>3.0f}%rr1r2TNNF)rerfrgrhr�r6r/r�r r1r7rH�classmethodrir9rRrrkrls@rKr�r��s�����K�)+�!�!'��-1�)-� �
��
�$'�
��	
�
�
��

��k�*�
��v�&�
��
�
�
�,�S��%��S�T�S��S�&
�6�
�d�
rLr�c�R��eZdZdZdZ			ddededeef�fd�
Zddd	e	fd
�Z
�xZS)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.
    ��?�compactr�r�c�B��||_||_t�|�
|��yr)rXr�rGrH)rIrXr�r�rJs    �rKrHzTimeRemainingColumn.__init__s$������%:��"�
���l��3rLr�r�rMc��|jr|jr|j}d}n|j}d}|j�
td|��S|�!t|jrd|��Sd|��Stt|�d�\}}t|d�\}}|jr|s
|d�d	|d��}n
|d
�d	|d�d	|d��}t||��S)zShow time remaining.rAzprogress.remainingrrBz--:--r@�<�02d�:�d)	r�rrD�time_remainingrtr9rX�divmodr�)rIr��	task_timerz�minutesrC�hours�	formatteds        rKrzTimeRemainingColumn.render
s����%�%�$�-�-��*�*�I�&�E��+�+�I�(�E��:�:����%�(�(����4�<�<��e�L�L�Y�e�L�L�"�#�i�.�"�5�������,���w��<�<��"�3�-�q���
�6�I� ��)�1�W�S�M��7�3�-�@�I��I�U�+�+rL)FFN)rerfrgrhr�r�r r7rHr9rrkrls@rKr�r��sS�����K��&+�)-�	4��4� $�4��v�&�	4�,�6�,�d�,rLr�c� �eZdZdZdddefd�Zy)�FileSizeColumnzRenders completed filesize.r�r�rMc�l�tjt|j��}t	|d��S)�Show data completed.zprogress.filesizerB)r+�decimalr�rFr9�rIr��	data_sizes   rKrzFileSizeColumn.render+s)���$�$�S����%8�9�	��I�%8�9�9rLNrGr�rLrKrfrf(s��%�:�6�:�d�:rLrfc� �eZdZdZdddefd�Zy)�TotalFileSizeColumnzRenders total filesize.r�r�rMc��|j�(tjt|j��nd}t	|d��S)rhrzprogress.filesize.totalrB)rtr+rir�r9rjs   rKrzTotalFileSizeColumn.render4s4��9=���9O�H�$�$�S����_�5�UW�	��I�%>�?�?rLNrGr�rLrKrmrm1s��!�@�6�@�d�@rLrmc�D��eZdZdZd	dedeef�fd�
Zdddefd�Z	�xZ
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 "/".
    �	separatorr�c�4��||_t�|�	|��yr)rqrGrH)rIrqr�rJs   �rKrHzMofNCompleteColumn.__init__Fs���"���
���l��3rLr�r�rMc���t|j�}|j�t|j�nd}tt	|��}t||�d��|j�|��d��S)zShow completed/total.�?r^�progress.downloadrB)r�rFrtr�r�r9rq)rIr�rFrt�total_widths     rKrzMofNCompleteColumn.renderJsc������'�	�#'�:�:�#9��D�J�J��s���#�e�*�o����+��a��(����(8���@�%�
�	
rL)�/N)rerfrgrhr�r r7rHr9rrkrls@rKrprp:s3���	�4�#�4�8�F�;K�4�
�6�
�d�
rLrpc�J��eZdZdZ	d
dedeeddf�fd�
Zdddefd	�Z	�xZ
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.
    N�binary_unitsr�rMc�4��||_t�|�	|��yr)ryrGrH)rIryr�rJs   �rKrHzDownloadColumn.__init__\s���)���
���l��3rLr�r�c��t|j�}|j�t|j�n|}|jrt	j
|gd�d�\}}nt	j
|gd�d�\}}|dk(rdnd}||z}|d|�d��}|j�#t|j�}	|	|z}
|
d|�d��}nd	}|�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�YBrLr*rz,.�frtrwr"rurB)r�rFrtryr+rMr9)rIr�rF� unit_and_suffix_calculation_baserOrP�	precision�completed_ratio�
completed_strrt�total_ratio�	total_str�download_status�
download_texts              rKrzDownloadColumn.renderbs�������'�	� $�z�z�5�C��
�
�O�9�	)����#�8�8�0�Q���L�D�&�$�8�8�0�I���L�D�&�
���A��	�#�d�*��*�2�i�[��/�:�
��:�:�!���
�
�O�E��$�,�K�&�r�)��A�o�6�I��I�*�O�1�Y�K�q���A���_�4G�H�
��rL)FN)rerfrgrhr�r r7rHr9rrkrls@rKr�r�UsD����LP�4� �4�8@��8H�4�	
�4�!�6�!�d�!rLr�c� �eZdZdZdddefd�Zy)�TransferSpeedColumnz&Renders human readable transfer speed.r�r�rMc��|jxs|j}|�
tdd��Stjt|��}t|�d�d��S)zShow data transfer speed.rtzprogress.data.speedrBz/s)rTrr9r+rir�)rIr�rrQs    rKrzTransferSpeedColumn.render�sR���#�#�1�t�z�z���=���#8�9�9��%�%�c�%�j�1�
��z�l�"�%�-B�C�CrLNrGr�rLrKr�r��s��0�D�6�D�d�DrLr�c�(�eZdZUdZeed<	eed<y)�ProgressSamplez$Sample of progress for a given time.rrFN)rerfrgrhrirr�rLrKr�r��s��.������$rLr�c��eZdZUdZeed<	eed<	eeed<	eed<	e	ed<	dZ
eeed<	d	Zeed
<	e
e��Zeeefed<	e
dd
d
��Zeeed<	e
dd
d
��Zeeed<	dZeeed<	e
d�d
d
��Zeeed<e
d
e��Zeed<	defd�Zedefd��Zedeefd��Zedeefd��Zedefd��Zedefd��Z edeefd��Z!edeefd��Z"d!d �Z#y)"r�z�Information regarding a progress task.

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

    r�rsrtrF�	_get_timeNrDT�visible)�default_factory�fieldsF)�default�init�repr�
start_time�	stop_timerTc��td��S)NrL)�maxlenrr�rLrK�<lambda>z
Task.<lambda>�s���T� 2�rL)r�r�r��	_progress)r�r��_lockrMc�"�|j�S)z(float: Get the current time, in seconds.)r�rYs rKrxz
Task.get_time�s���~�~��rLc��|jduS)z#bool: Check if the task as started.N)r�rYs rKr;zTask.started�s�����d�*�*rLc�N�|j�y|j|jz
S)zPOptional[float]: Get the number of steps remaining, if a non-None total was set.N)rtrFrYs rK�	remainingzTask.remaining�s$���:�:����z�z�D�N�N�*�*rLc��|j�y|j�|j|jz
S|j�|jz
S)z]Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started.N)r�r�rxrYs rKrEzTask.elapsed�sC���?�?�"���>�>�%��>�>�D�O�O�3�3��}�}�����0�0rLc��|jduS)zCheck if the task has finished.N)rDrYs rKrz
Task.finished�s���!�!��-�-rLc��|jsy|j|jzdz}tdtd|��}|S)zOfloat: Get progress of task as a percentage. If a None total was set, returns 0��Y@)rtrF�minr:)rIrFs  rK�
percentagezTask.percentage�s>���z�z���^�^�d�j�j�0�E�9�	���s�3�	�2�3�	��rLc�J�|j�y|j5|j}|s
	ddd�y|dj|djz
}|dk(r
	ddd�yt	|�}t|�t
d�|D��}||z}|cddd�S#1swYyxYw)z=Optional[float]: Get the estimated speed in steps per second.Nr�rc3�4K�|]}|j���y�wrVr�)�.0�samples  rK�	<genexpr>zTask.speed.<locals>.<genexpr>s����!O�v�&�"2�"2�!O���)r�r�r�r�iterr�r�)rIr@�
total_time�
iter_progress�total_completedrs      rKrz
Task.speed�s����?�?�"��
�Z�Z�	��~�~�H���	�	�"�"��/�/�(�1�+�2G�2G�G�J��Q���
	�	�!��N�M����!�!O��!O�O�O�#�j�0�E��	�	�	�s�B�%B�!.B�B"c�x�|jry|j}|sy|j}|�yt||z�}|S)zJOptional[float]: Get estimated time to completion, or ``None`` if no data.r�N)rrr�r)rIrr��estimates    rKr_zTask.time_remainingsC���=�=���
�
�����N�N�	�����	�E�)�*���rLc�T�|jj�d|_d|_y)zReset progress.N)r��clearrDrTrYs rK�_resetzTask._resets"��������!���"��rLrd)$rerfrgrhr;rr�r ri�GetTimeCallablerDr�r�r�dictr�rrr�r�rTr�rr�rr�rxr�r;r�rErr�rr_r�r�rLrKr�r��s����	�J�G���'��E�?��>���*���+�%)�M�8�E�?�)�(��G�T��J�"�4�8�F�D��c��N�8�?�"'��5�u�"M�J����M�N�!&�t�%�e�!L�I�x���L�N�&*�N�H�U�O�*�>�',�2��U�(�I�u�^�$���e�U�;�E�5�;�� �%� ��+��+��+��+�8�E�?�+��+��1��%��1��1��.�$�.��.���E������x������"��������#rLr�c��eZdZdZddddddddddd�
deeefd	eed
e	de
de
d
e	de	de	deede	de	ddfd�Ze
deedffd��Zedefd��Zedeefd��Zedeefd��Zede	fd��ZdOd�ZdOd�ZdPd�Zdeeedeed eeddfd!�Z				dQd"eee e!e fd#ee
d$eed%ed&e
dee fd'�Z"	dRdd(d)�d*e#d#ee$d$eed%ede#f
d+�Z%e&jN				dSddd(d,�d*eed-e(fd.e)d/d0e$d1eed2eed3eed#ee$d$eed%ede#fd4��Z*e&jN				dSddd(d,�d*eed-e(fd.ee)d5e)d6fd0e$d1eed2eed3eed#ee$d$eed%ede+fd7��Z*					dTddd(d,�d*eed-e(fd.ee)d/e)d6e)d5fd0e$d1eed2eed3eed#ee$d$eed%edee#e+ffd8�Z*d$eddfd9�Z,d$eddfd:�Z-ddddddd;�d$ed#ee
d<ee
d=ee
d%eed>ee	d?e	d@e.ddfdA�Z/dddBdddC�d$edDe	d#ee
d<e$d>ee	d%eed@e.ddfdE�Z0dUd$ed=e
ddfdF�Z1dOdG�Z2de3fdH�Z4dee3fdI�Z5dJeede6fdK�Z7de3fdL�Z8				dVd%edDe	d#ee
d<e$d>e	d@e.defdM�Z9d$eddfdN�Z:y)WrAa�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.
    NTrmg>@F)
rvrury�speed_estimate_periodrw�redirect_stdout�redirect_stderrrxr~�expandr�rvruryr�rwr�r�rxr~r�rMc
	���|dkDsJd��t�|_|xs|j�|_||_|	|_|
|_i|_td�|_	t|xs
t�||||||j��|_
|xs|jj|_|jj |_|jj"|_y)Nrzrefresh_per_second must be > 0)rvruryrwr�r��get_renderable)rr��get_default_columnsr�r�r~r��_tasksr;�_task_indexr3r,r��livervrx�print�log)rIrvruryr�rwr�r�rxr~r�r�s            rKrHzProgress.__init__)s���"�A�%�G�'G�G�%��W��
��<�$�":�":�"<���%:��"�������*,���#)�!�9�����,�{�}�%�1��+�+��.�.�
��	�!�9�D�L�L�$9�$9��
��\�\�'�'��
��<�<�#�#��rL.c�P�td�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.get_default_columns(),
                "Elapsed:",
                TimeElapsedColumn(),
            )

        This code shows the creation of a Progress display, containing
        a spinner to the left, the default columns, and a labeled elapsed
        time column.
        r�)r�r�r�r�)rNs rKr�zProgress.get_default_columnsMs(��2
�A�B��K�� ��!�	
�	
rLc�.�|jjSrV)r�rvrYs rKrvzProgress.consolels���y�y� � � rLc��|j5t|jj��cddd�S#1swYyxYw)zGet a list of Task instances.N)r��listr��valuesrYs rK�taskszProgress.tasksps5���Z�Z�	.�����*�*�,�-�	.�	.�	.��	�#:�Ac��|j5t|jj��cddd�S#1swYyxYw)zA list of task IDs.N)r�r�r��keysrYs rK�task_idszProgress.task_idsvs5���Z�Z�	,�����(�(�*�+�	,�	,�	,�r�c���|j5|js
	ddd�ytd�|jj�D��cddd�S#1swYyxYw)z'Check if all tasks have been completed.NTc3�4K�|]}|j���y�wrV)r)r�r�s  rKr�z$Progress.finished.<locals>.<genexpr>�s����F��t�}�}�F�r�)r�r��allr�rYs rKrzProgress.finished|sW���Z�Z�	G��;�;��	G�	G��F����1C�1C�1E�F�F�	G�	G�	G�s�A�)A�A c�V�|js|jjd��yy)zStart the progress display.T)rON)r~r�rXrYs rKrXzProgress.start�s ���|�|��I�I�O�O�D�O�)�rLc��|jj�|jjs|jj	�yy)zStop the progress display.N)r�r�rv�is_interactiver�rYs rKr�z
Progress.stop�s2���	�	�����|�|�*�*��L�L��� �+rLc�&�|j�|SrVrWrYs rKrZzProgress.__enter__�r[rLr\r]r^c�$�|j�yrV)r�rbs    rKrczProgress.__exit__�s
��	
�	�	�rLrrrtrBrsrCc#�K�|�tt|��xsd}|�|j||��}n|j||��|jj
r8t
|||�5}|D]}|��|xjdz
c_�	ddd�y|j}|j}	|D]}|��||d�|	��y#1swYyxYw�w)a�Track progress by iterating over a sequence.

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

        Returns:
            Iterable[ProgressType]: An iterable of values taken from the provided sequence.
        N�rtr*)
rir�add_taskrRr�rur?rFrPrO)
rIrrrtrBrsrC�track_thread�valuerPrOs
          rKr�zProgress.track�s�����(�=��+�h�/�0�8�D�E��?��m�m�K�u�m�=�G��K�K��u�K�-��9�9�!�!��d�G�]�;�
0�|�%�0�E��K� �*�*�a�/�*�0�
0�
0�
�l�l�G��l�l�G�!�
�������#��	�
�
0�
0�s�A'C�)!C�=C�C�
Cr�)rBrsr�c��d}|�|}n0|�.|j5|j|j}ddd�|�td��|�|j	||��}n|j||��t
|||d��S#1swY�NxYw)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�)r�r�rt�
ValueErrorr�rRr�)rIr�rtrBrs�total_bytess      rKr�zProgress.wrap_file�s���.(,�����K�
�
 ����
9�"�k�k�'�2�8�8��
9����Q��
�
�?��m�m�K�{�m�C�G��K�K��{�K�3��t�T�7��?�?�
9�
9�s�A=�=B)rtrBrsr�r�r�r�r�r�r�c��yrVr��
rIr�r�r�r�r�r�rtrBrss
          rKr�z
Progress.open����	
rLr�r�c��yrVr�r�s
          rKr�z
Progress.open�r�rLc��djt|d���}
|
dvrtdj|���|dk(}|
dk(r"|dk(rt	j
dt�d	}n|
d
vr|dk(rtd��|dk(rd	}|�t|�j}|�|j|	|�
�}n|j||�
�tj|d|��}t|||d��}
|dvrtj|
||||��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.
        rF)�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/Or�r�)r�Tr�)r�r�)r�r�r��line_buffering)ra�sortedr�r.�warnings�warn�RuntimeWarningr�st_sizer�rR�ior�r��
TextIOWrapper)rIr�r�r�r�r�r�rtrBrs�_moder�r�r�s              rKr�z
Progress.opens(��B����t�U�3�4���)�)��0�7�7��=�>�>�#�a����D�=�Y�!�^��M�M�s��
��I�
�k�
!��A�~� �!A�B�B��a���	��=���J�&�&�E��?��m�m�K�u�m�=�G��K�K��u�K�-�����t�y�9�����w�T�B���;���#�#��!���-��
��
rLc��|j5|j|}|j�|j�|_ddd�y#1swYyxYw)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�r�r�rx)rIrBr�s   rK�
start_taskzProgress.start_task[sE���Z�Z�	2��;�;�w�'�D����&�"&�-�-�/���	2�	2�	2�s�1A�Ac��|j5|j|}|j�}|j�||_||_ddd�y#1swYyxYw)z�Stop a task.

        This will freeze the elapsed time on the task.

        Args:
            task_id (TaskID): ID of task.
        N)r�r�rxr�r�)rIrBr�rs    rK�	stop_taskzProgress.stop_taskisQ���Z�Z�	*��;�;�w�'�D��=�=�?�L����&�".���)�D�N�	*�	*�	*�s�:A�A)rtrFrPrsr�rOrFrPr�rOr�c�<�|j5|j|}	|	j}
|�&||	jk7r||	_|	j	�|�|	xj|z
c_|�||	_|�||	_|�||	_|	jj|�|	j|
z
}|j�}||jz
}
|	j}|j}|r.|dj|
kr|�|r|dj|
kr�|dkDr|jt||��|	j�6|	j|	jk\r|	j �|	j"|	_ddd�|r|j%�yy#1swY�xYw)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�rFrtr�rsr�r�rRrxr�r��popleftr�appendr�rDrErO)rIrBrtrFrPrsr�rOr�r��completed_start�update_completedr�old_sample_timer�rs                rKrRzProgress.updatexsy��0�Z�Z� 	2��;�;�w�'�D�"�n�n�O�� �U�d�j�j�%8�"��
����
��"����'�)���$�!*����&�#.�� ��"�&����K�K���v�&�#�~�~��?���=�=�?�L�*�T�-G�-G�G�O����I��'�'�G��	�!�� 6� 6�� H��	��	�!�� 6� 6�� H��!�#�� � ���>N�!O�P��
�
�&��N�N�d�j�j�0��&�&�.�%)�\�\��"�A 	2�D��L�L�N��E 	2� 	2�s�DF�A"F�Fr)rXrtrFr�rsrXc�>�|j�}|j5|j|}	|	j�|r|nd|	_|�||	_||	_|�||	_|r||	_|�||	_	d|	_
ddd�|j�y#1swY�xYw)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)rxr�r�r�r�rtrFr�r�rsrDrO)
rIrBrXrtrFr�rsr�rr�s
          rK�resetzProgress.reset�s���,�}�}���
�Z�Z�
	&��;�;�w�'�D��K�K�M�.3�l��D�O�� �"��
�&�D�N��"�&����$����&�#.�� �!%�D��
	&�	
����
	&�
	&�s�AB�Bc��|j�}|j5|j|}|j}|xj|z
c_|j|z
}||jz
}|j
}|j}	|r.|dj|kr|	�|r|dj|kr�t|�dkDr|	�t|�dkDr�|jt||��|j�G|j|jk\r.|j�"|j|_|j|_ddd�y#1swYyxYw)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.
        rrLN)rxr�r�rFr�r�rrr�rr�rtrDrErrT)
rIrBrPrr�rrrr�rs
          rKrPzProgress.advance�s%���}�}���
�Z�Z�	1��;�;�w�'�D�"�n�n�O��N�N�g�%�N�#�~�~��?��*�T�-G�-G�G�O����I��'�'�G��	�!�� 6� 6�� H��	��	�!�� 6� 6�� H��i�.�4�'��	��i�.�4�'����^�L�:J�K�L��
�
�&��N�N�d�j�j�0��&�&�.�%)�\�\��"�&*�j�j��#�)	1�	1�	1�s�BE�4#E�A.E�Ec��|js2|jjr|jj�yyy)z*Refresh (render) the progress information.N)r~r��
is_startedrOrYs rKrOzProgress.refresh�s,���|�|��	�	� 4� 4��I�I����!5�|rLc�2�t|j��}|S)z*Get a renderable for the progress display.)r.�get_renderables)rIrs  rKr�zProgress.get_renderable�s���D�0�0�2�3�
��rLc#�JK�|j|j�}|��y�w)z5Get a number of renderables for the progress display.N)�make_tasks_tabler�)rI�tables  rKr
zProgress.get_renderabless�����%�%�d�j�j�1����s�!#r�c����d�|jD�}tj|d|jd��}|D]1��js�|j
�fd�|jD���3|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.
        c3�K�|]>}t|t�rtd��n|j�j	����@y�w)Tr)N)rr�r7r��copy)r��_columns  rKr�z,Progress.make_tasks_table.<locals>.<genexpr>sE����
���g�s�+��t�$��-�-�/�4�4�6�7�
�s�AA)rr*)�paddingr�c3�r�K�|].}t|t�r|j���n|�����0y�w)r-N)rr�r.)r��columnr�s  �rKr�z,Progress.make_tasks_table.<locals>.<genexpr>s>������#� *�&�#�6�#�M�M�t�M�4�!'���.��s�47)r�r8�gridr�r��add_row)rIr��
table_columnsrr�s    @rKrzProgress.make_tasks_table	sn���
� �<�<�

�
��
�
�M�6�$�+�+�N���	�D��|�|���
�
��'+�l�l�
�	�	��rLc�f�|j5|j�cddd�S#1swYyxYw)z+Makes the Progress class itself renderable.N)r�r�rYs rK�__rich__zProgress.__rich__*s*��
�Z�Z�	)��&�&�(�	)�	)�	)�s�'�0c��|j5t|j||||||j|j��}||j|j<|r|j|j�|j}t
t|j�dz�|_ddd�|j�S#1swY�xYw)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�r�r�r�r*N)	r�r�r�rxr�r�r;r�rO)	rIrsrXrtrFr�r�r��new_task_indexs	         rKr�zProgress.add_task/s���0�Z�Z�	A��� � �������-�-��j�j�	�D�-1�D�K�K��(�(�)������ 0� 0�1�!�-�-�N�%�c�$�*:�*:�&;�a�&?�@�D��	A� 	
������#	A�	A�s�BC�C
c�`�|j5|j|=ddd�y#1swYyxYw)z]Delete a task if it exists.

        Args:
            task_id (TaskID): A task ID.

        N)r�r�)rIrBs  rK�remove_taskzProgress.remove_taskZs,���Z�Z�	%����G�$�	%�	%�	%�s�$�-rd)rMrA)NN�
Working...皙�����?rV�r�NNN�r�r�NNN)r*)Tr�rT);rerfrgrhr&r�r�r r-r�rir�rHrUr#r�r�rvrr�r�r;r�rrXr�rZr$rjrrcrr<r!r�rr�r��typing�overloadr�r)r�r"r�rrrRrrPrOr0r�r
r8rrr�r r�rLrKrArAs���
�$&*�!�$&�'+�� $� $�.2���"$���^�+�,�"$��'�"�"$��	"$�
"�"$� %�
"$��"$��"$��"$��?�+�"$��"$��"$�
�"$�H�
�E�.�#�*=�$>�
��
�<�!��!��!��.�t�D�z�.��.�
�,�$�v�,�,��,�
�G�$�G��G�*�
!����4�
�.�/���-�(����'�	�

��"&�$(�'�"�
'����.���0F�F�G�'����'��&�!�	'�
�'��
'�
�,�	�'�X $�(@�
%)�'�
(@��(@���}�(@�
�&�!�(@��
(@�
�(@�T�_�_�
�"&� $�!%�

� $�$(�'�

��C��%�/�0�

��d�m�

��	

�
�3�-�

���
�


��#��

���}�

��&�!�

��

�
�

��

��_�_�
�"&� $�!%�

� $�$(�'�

��C��%�/�0�

��G�C�L�'�$�-�/�0�

��	

�
�3�-�

���
�


��#��

���}�

��&�!�

��

�
�

��

�$CF��"&� $�!%�K� $�$(�'�K��C��%�/�0�K��G�D�M�7�4�=�'�#�,�>�?�K��	K�
�3�-�K���
�
K��#��K���}�K��&�!�K��K�
�x���	 �K�Z2�&�2�T�2�
*��
*�D�
*�&"&�%)�#'�%)�"&��;��;����	;�
�E�?�;��%��
;��c�]�;��$��;��;��;�
�;�B�!%��"&�%)�%��%��	%�
���%��
%��$��%��c�]�%��%�
�%�N1�v�1��1�d�1�< �
���
��.�!9��
�h�t�n����B)�.�)��!&���
)��)��)����	)�
�)��
)��)�
�)�V%�6�%�d�%rLrA�__main__)�Panel)�Rule)�Syntax)r8a~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)�typerz	Syntax...zGive it a try!)�cycle)�record)rvrwz[red]DownloadingrLr�z[green]Processingz[yellow]ThinkingrWr�g333333�?g{�G�z�?�d)r!NTNFNrmrnrorprqr"FTr#r$)�r��sysr%r��abcrr�collectionsr�dataclassesrr�datetimer	r
r�mathrr
�operatorr�osrr�	threadingrrr�typesrrrrrrrrrrrrr r!r"r#r$r%r&�version_infor)�typing_extensionsrr+r,rvr-r.r/r0r'r1�jupyterr2r�r3�progress_barr4rr5rzr6rr7r8rr9r:r�r;r<rir�r=r?r�r�r�r�r�r�r&r�r�r�r	rr�r�r>r�r�rfrmrpr�r�r�r�rAre�random�time�panelr(�ruler)�syntaxr*r�progress_renderables�	itertoolsr5�examplesr�r@r��task1�task2�task3rrR�sleep�randintr�r�r�rLrK�<module>rSsY	��	�
�
��#��(��.��� ��*�*�������*���v���)�#�B�B�$�!��%��� � �	��3�	���~�&���2�u�9�%���V�^�^�D�&�(�+��%�6�%�T$�!��!%��.2� "�!� .� .�(����C
��H�\�*�H�\�,B�B�C�C
��C
��E�?�C
��	C
�
�g�
�C
��
C
��x��E�	�*�+�C
��C
��C
��C
��C
��C
��C
��C
��C
� �l��!C
�La,�i��a,�H8�>�"�%�w�r�{�8�2$��!%��.2� "�!� .� .�(��>*�
�>*��>*��	>*�
�>*��g�
�
>*��>*��x��E�	�*�+�>*��>*��>*��>*��>*��>*��>*��H��>*�B����"� �!�
	� �#��!%��.2� "�!� .� .�(��'	�
��_�e�+�
,�	�
���
�w�s�|�+�
,�	��	��s�m�		�

�S�M�	��c�]�
	��C�=�	��	��	��g�
�	��	��x��E�	�*�+�	��	��	� �!	�"�#	�$�%	�&�'	�(�F��)	��	�0����"� �!�
	� �#��!%��.2� "�!� .� .�(��'	�
��_�e�+�
,�	�
�$�-�	��	��s�m�		�

�S�M�	��c�]�
	��C�=�	��	��	��g�
�	��	��x��E�	�*�+�	��	��	� �!	�"�#	�$�%	�&�'	�(�H��)	��	�4?B��"� �!�
S*� �#��!%��.2� "�!� .� .�(��'S*�
��_�e�+�
,�S*�
���
�w�t�}�g�c�l�:�
;�S*��S*��s�m�	S*�

�S�M�S*��c�]�
S*��C�=�S*��S*��S*��g�
�S*��S*��x��E�	�*�+�S*��S*��S*� �!S*�"�#S*�$�%S*�&�'S*�(�>�(�#�^�F�%;�;�<�)S*�l'1�S�'1�T�~��"/�N�/�d���<'
��'
�T	:��	:�E��E�P-,�.�-,�`:�^�:�@�.�@�
��
�6.�^�.�b	D�.�	D�%�Z�%��z#�z#��z#�zI	%�|�I	%�X�z��������
�
	"�	���F� 
�%���&�E�	�M�M�#�s�C� �	E�
�8�9�'�
�&��$4�5����
��
�� ��)�*�H��T�"�G�	���
�	�	%�	%�	'�
�	��
���
�-�
��!�!�"4�D�!�A���!�!�"5�T�!�B���!�!�"4�D�!�A���#�#��O�O�E�3�O�/��O�O�E�3�O�/��D�J�J�t���v�~�~�a��%��)����T�(�^�,��#�#�-�-�]�\-�-�s
�?B>U�U

Zerion Mini Shell 1.0