HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/site-packages/pip/_vendor/rich/__pycache__/progress.cpython-311.pyc
�

�mi�����ddlmZddlZddlZddlZddlmZmZddlm	Z	ddl
mZmZddl
mZddlmZmZddlmZdd	lmZdd
lmZddlmZmZddlmZmZmZdd
lmZddlmZm 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/m0Z0m1Z1erddl2m3Z3ddl4m5Z5m6Z6ddl7m8Z8m9Z9m:Z:m;Z;ddl<m=Z=ddl>m?Z?ddl@mAZAddlBmCZCddlDmEZEddlFmGZGddlHmIZImJZJddlKmLZLmMZMe+deN��ZOe0d��ZPe"geQfZRej0de-e!��ZSGd�de��ZT															d�d�dC�ZUGdD�dEee!��ZVGdF�dGe#eSe&eS��ZWdHd!dd"dd#d$d%d&d'd"dI�d�dM�ZXejY				d�ddHd!dd"dd#d$d%d&d'd"dO�d�dZ���ZZejY				d�ddHd!dd"dd#d$d%d&d'd"dO�d�d\���ZZ					d�ddHd!dd"dd#d$d%d&d'd"dO�d�d`�ZZGda�dbe��Z[Gdc�dde[��Z\Gde�dfe[��Z]Gdg�dhe[��Z^Gdi�dje[��Z_Gdk�dle[��Z`Gdm�dne^��ZaGdo�dpe[��ZbGdq�dre[��ZcGds�dte[��ZdGdu�dve[��ZeGdw�dxe[��ZfGdy�dze[��ZgGd{�d|e*��ZheGd}�d~����ZiGd�d�e?��Zjekd�k�r�ddllZlddlmZmdd�lnmoZodd�lpmqZqdd�lrmsZsdd�lHmJZJesd�d�d!����ZreJd�d�d���ZHeH�td�d�d���d�eod���d�eHd�d�d�d��d�ereqd���g	Zudd�lvmwZweweu��Zxe8d!����Z7eje]��gej�y���e`���Re7d"d���5Zzez�{d�d�����Z|ez�{d�d�����Z}ez�{d�d����Z~ezjsxez��e|d�����ez��e}d�����emj�d���elj�dd���dkrez��e�ex����ezj�xddd��dS#1swxYwYdSdS)��)�annotationsN)�ABC�abstractmethod��deque)�	dataclass�field)�	timedelta)�	RawIOBase�UnsupportedOperation)�ceil)�mmap)�length_hint)�PathLike�stat)�Event�RLock�Thread)�
TracebackType)�
TYPE_CHECKING�Any�BinaryIO�Callable�ContextManager�Deque�Dict�Generic�Iterable�List�Literal�
NamedTuple�NewType�Optional�TextIO�Tuple�Type�TypeVar�Union)�Self�)�filesize�get_console)�Console�Group�
JustifyMethod�RenderableType)�Highlighter)�JupyterMixin)�Live)�ProgressBar)�Spinner)�	StyleType)�Column�Table)�Text�TextType�TaskID�ProgressType�_Ic�<��eZdZdZd�fd�Zdd�Zdd
�Zdd�Z�xZS)�_TrackThreadz)A thread to periodically update progress.�progress�
'Progress'�task_id�'TaskID'�
update_period�floatc���||_||_||_t��|_d|_t
���d���dS)NrT)�daemon)r@rBrDr�done�	completed�super�__init__)�selfr@rBrD�	__class__s    ��;D:\Python311\Lib\site-packages\pip/_vendor/rich/progress.pyrKz_TrackThread.__init__CsL��� ��
����*����G�G��	����
�������%�%�%�%�%��return�Nonec�P�|j}|jj}|j}d}|jj}||��sK|jjjr:|j}||kr||||z
��|}||��s|jjj�:|j�	|j|jd���dS)NrT)rI�refresh)
rBr@�advancerDrH�wait�live�
is_startedrI�update)rLrBrTrD�last_completedrUrIs       rN�runz_TrackThread.runLs����,���-�'���*�
����y�~���$�}�%�%�	+�$�-�*<�*G�	+���I���*�
+�����^�!;�<�<�<�!*��	�$�}�%�%�	+�$�-�*<�*G�	+�	
�
���T�\�T�^�T��R�R�R�R�RrO�'_TrackThread'c�.�|���|S�N��start�rLs rN�	__enter__z_TrackThread.__enter__Z����
�
�����rO�exc_type�Optional[Type[BaseException]]�exc_val�Optional[BaseException]�exc_tb�Optional[TracebackType]c�`�|j���|���dSr])rH�set�join�rLrcrergs    rN�__exit__z_TrackThread.__exit__^s$��	
�	�
�
�����	�	�����rO)r@rArBrCrDrE�rPrQ)rPr[�rcrdrerfrgrhrPrQ)	�__name__�
__module__�__qualname__�__doc__rKrZrarm�
__classcell__�rMs@rNr?r?@s��������3�3�&�&�&�&�&�&�S�S�S�S������������rOr?�
Working...TF�
�bar.back�bar.complete�bar.finished�	bar.pulse皙�����?�sequence�Iterable[ProgressType]�description�str�total�Optional[float]rI�int�auto_refresh�bool�console�Optional[Console]�	transient�get_time�Optional[Callable[[], float]]�refresh_per_secondrE�styler6�complete_style�finished_style�pulse_stylerD�disable�
show_speedrPc
#�XK�|rtd��gng}|�t|	|
||���t|���t	d���f��t||||||pd|d��}|5|�|||||
���Ed	{V��d	d	d	��d	S#1swxYwYd	S)
a�Track progress by iterating over a sequence.

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

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

    �([progress.description]{task.description}�r�r�r�r�)r�T)�elapsed_when_finishedrw�r�r�r�r�r�r�)r�rIrrDN)�
TextColumn�extend�	BarColumn�TaskProgressColumn�TimeRemainingColumn�Progress�track)r}rr�rIr�r�r�r�r�r�r�r�r�rDr�r��columnsr@s                  rNr�r�hsg����XEP�W��>�	?�	?�@�@�UW���N�N���-�-�'�	
�
�
�
�*�5�5�5��d�;�;�;�		
�����	�!����-�3������H�
�
�
��>�>����#�'�"�
�
�	
�	
�	
�	
�	
�	
�	
�
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
s�1!B�B#�&B#c��eZdZdZ	d;d<d
�Zd=d�Zd>d�Zd?d�Zd@d�Ze	dAd���Z
dBd�ZdAd�Ze	dCd���Z
e	dCd ���ZdAd!�ZdAd"�ZdAd#�ZdDdEd&�ZdFd)�ZdDdEd*�ZdDdGd-�ZdHd.�ZdIdJd2�ZdBd3�ZdKd6�ZdLd9�Zd:S)M�_Readerz9A reader that tracks progress while it's being read from.T�handlerr@rA�taskr;�close_handler�rPrQc�L�||_||_||_||_d|_dS�NF)r�r@r�r��_closed)rLr�r@r�r�s     rNrKz_Reader.__init__�s,����� ��
���	�(�������rO�	'_Reader'c�8�|j���|Sr])r�rar`s rNraz_Reader.__enter__�s����������rOrcrdrerfrgrhc�.�|���dSr])�closerls    rNrmz_Reader.__exit__�s��	
�
�
�����rOc��|Sr]�r`s rN�__iter__z_Reader.__iter__�s���rO�bytesc��t|j��}|j�|jt|�����|S�N�rT)�nextr�r@rTr��len)rL�lines  rN�__next__z_Reader.__next__�s9���D�K� � ���
���d�i��T����;�;�;��rOc��|jSr])r�r`s rN�closedz_Reader.closed�s
���|�rOr�c�4�|j���Sr])r��filenor`s rNr�z_Reader.fileno�����{�!�!�#�#�#rOc�4�|j���Sr])r��isattyr`s rNr�z_Reader.isatty�r�rOr�c��|jjSr])r��moder`s rNr�z_Reader.mode��
���{��rOc��|jjSr])r��namer`s rNr�z_Reader.name�r�rOc�4�|j���Sr])r��readabler`s rNr�z_Reader.readable�����{�#�#�%�%�%rOc�4�|j���Sr])r��seekabler`s rNr�z_Reader.seekable�r�rOc��dSr�r�r`s rN�writablez_Reader.writable�s���urO����sizec��|j�|��}|j�|jt|�����|Sr�)r��readr@rTr�r�)rLr��blocks   rNr�z_Reader.read�s?���� � ��&�&���
���d�i��U����<�<�<��rO�b�"Union[bytearray, memoryview, mmap]c�|�|j�|��}|j�|j|���|Sr�)r��readintor@rTr�)rLr��ns   rNr�z_Reader.readinto�s9���K� � ��#�#���
���d�i���3�3�3��rOc��|j�|��}|j�|jt|�����|Sr�)r��readliner@rTr�r�)rLr�r�s   rNr�z_Reader.readline�s?���{�#�#�D�)�)���
���d�i��T����;�;�;��rO�hint�List[bytes]c	��|j�|��}|j�|jtt
t|�������|Sr�)r��	readlinesr@rTr��sum�mapr�)rLr��liness   rNr�z_Reader.readlinessI����%�%�d�+�+���
���d�i��S��e�_�_�1E�1E��F�F�F��rOc�T�|jr|j���d|_dS)NT)r�r�r�r�r`s rNr�z
_Reader.close	s,����	 ��K����������rOr�offset�whencec�~�|j�||��}|j�|j|���|S)N�rI)r��seekr@rXr�)rLr�r��poss    rNr�z_Reader.seeks;���k���v�v�.�.���
���T�Y�#��6�6�6��
rOc�4�|j���Sr])r��tellr`s rNr�z_Reader.tells���{���!�!�!rO�src� �td���)N�write�r)rLr�s  rNr�z
_Reader.writes��"�7�+�+�+rOr��
Iterable[Any]c� �td���)N�
writelinesr�)rLr�s  rNr�z_Reader.writeliness��"�<�0�0�0rON)T)
r�rr@rAr�r;r�r�rPrQ)rPr�ro)rPr)rPr��rPr�)rPr�)rPr�)r�)r�r�rPr�)r�r�)r�r�rPr�rn)r)r�r�r�r�rPr�)r�rrPr�)r�r�rPrQ)rprqrrrsrKrarmr�r��propertyr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rOrNr�r��s������C�C�"����������������������
�����X��$�$�$�$�$�$�$�$�� � � ��X� �� � � ��X� �&�&�&�&�&�&�&�&����������
����
�����
�����
����
�����
"�"�"�"�,�,�,�,�1�1�1�1�1�1rOr�c�*�eZdZdZdd�Zdd	�Zdd�ZdS)�_ReadContextzEA utility class to handle a context for both a reader and a progress.r@rA�readerr=rPrQc�"�||_||_dSr])r@r�)rLr@r�s   rNrKz_ReadContext.__init__ s�� ��
� ����rOc�f�|j���|j���Sr])r@r_r�rar`s rNraz_ReadContext.__enter__$s*���
�������{�$�$�&�&�&rOrcrdrerfrgrhc�p�|j���|j�|||��dSr])r@�stopr�rmrls    rNrmz_ReadContext.__exit__(s8��	
�
����������X�w��7�7�7�7�7rON)r@rAr�r=rPrQ)rPr=ro)rprqrrrsrKrarmr�rOrNr�r�sV������O�O�!�!�!�!�'�'�'�'�8�8�8�8�8�8rOr��
Reading...)rr�r�r�r�r�r�r�r�r�r��filer�ContextManager[BinaryIO]c
�"�|rtd��gng}
|
�t||	|
|���t��t	��f��t|
|||||pd|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�rwr�)r�r)r�r�r��DownloadColumnr�r��	wrap_filer�)r�r�rr�r�r�r�r�r�r�r�r�r�r�r@r�s                rNr�r�2s���JEP�W��>�	?�	?�@�@�UW���N�N���-�-�'�	
�
�
�
����!�!�		
�����	�!����-�3������H��
�
��E�{�
�
K�
K�F���&�)�)�)rOr�)r�rr�r�r�r�r�r�r�r�r�r��"Union[str, 'PathLike[str]', bytes]r��"Union[Literal['rt'], Literal['r']]�	buffering�encoding�
Optional[str]�errors�newline�
Optional[int]�ContextManager[TextIO]c��dSr]r��r�r�r�r�rrr�rr�r�r�r�r�r�r�r�r�r�s                  rN�openrs�	��,	�DrO�
Literal['rb']c��dSr]r�rs                  rNrr�rrO�r�1Union[Literal['rb'], Literal['rt'], Literal['r']]�7Union[ContextManager[BinaryIO], ContextManager[TextIO]]c
�,�|rtd��gng}|�t|
|||���t��t	��f��t|||	|
||pd|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�rwr�)r�r�r�rrr�r)r�r�r�r�r�r�rr�)r�r�r�r�rrr�rr�r�r�r�r�r�r�r�r�r�r�r@r�s                     rNrr�s���bEP�W��>�	?�	?�@�@�UW���N�N���-�-�'�	
�
�
�
����!�!�		
�����	�!����-�3������H��]�]��
��������	�	�F���&�)�)�)rOc�T�eZdZUdZdZded<ddd	�Zdd�Zdd�Ze	dd���Z
dS)�ProgressColumnz3Base class for a widget to use in progress display.Nr��max_refresh�table_column�Optional[Column]rPrQc�0�||_i|_d|_dSr])�
_table_column�_renderable_cache�_update_time)rLrs  rNrKzProgressColumn.__init__s ��)���MO���-1����rOr7c�,�|jp
t��S)z.Get a table column, used to build tasks table.)rr7r`s rN�get_table_columnzProgressColumn.get_table_columns���!�-�V�X�X�-rOr��'Task'r0c��|���}|j�>|js7	|j|j\}}||jz|kr|Sn#t
$rYnwxYw|�|��}||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).
        )r�rrIr�id�KeyError�render)rLr��current_time�	timestamp�
renderables     rN�__call__zProgressColumn.__call__	s����}�}������	&���	&�
&�(,�(>�t�w�(G�%�	�:��t�/�/�,�>�&�%�%�&���
�
�
���
�����[�[��&�&�
�+7��*D���t�w�'��s�A
�

A�Ac��dS)z"Should return a renderable object.Nr��rLr�s  rNrzProgressColumn.render s���rOr])rrrPrQ)rPr7�r�rrPr0)rprqrrrsr�__annotations__rKrr!rrr�rOrNrr�s��������=�=�#'�K�'�'�'�'�2�2�2�2�2�
.�.�.�.�����.�1�1�1��^�1�1�1rOrc�6��eZdZdZ	ddd�d�fd	�Zdd
�Z�xZS)�RenderableColumnz�A column to insert an arbitrary column.

    Args:
        renderable (RenderableType, optional): Any renderable. Defaults to empty string.
    �N�rr r0rrc�Z��||_t���|���dS�Nr))r rJrK)rLr rrMs   �rNrKzRenderableColumn.__init__,s-���%���
�����l��3�3�3�3�3rOr�rrPc��|jSr])r r#s  rNrzRenderableColumn.render2s
����rO)r()r r0rrr$�rprqrrrsrKrrtrus@rNr'r'%sr���������,.�4�SW�4�4�4�4�4�4�4�4��������rOr'c�F��eZdZdZ					dd�fd�
Z		ddd�Zdd�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 " ".
    �dots�progress.spinner��?� N�spinner_namer�r��Optional[StyleType]�speedrE�
finished_textr:rrc����t|||���|_t|t��rt	j|��n||_t���|���dS)N�r�r6r))	r5�spinner�
isinstancer�r9�from_markupr7rJrK)rLr4r�r6r7rrMs      �rNrKzSpinnerColumn.__init__@sm����|�5��F�F�F����-��-�-�
�D��]�+�+�+��	
��
	�����l��3�3�3�3�3rO�
spinner_stylerPrQc�4�t|||���|_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.
        r9N)r5r:)rLr4r=r6s    rN�set_spinnerzSpinnerColumn.set_spinnerPs���|�=��N�N�N����rOr�rr0c�z�|jr|jn+|j�|�����}|Sr])�finishedr7r:rr�)rLr��texts   rNrzSpinnerColumn.render_s=���}�
6�D�����$�$�T�]�]�_�_�5�5�	
�
�rO)r0r1r2r3N)
r4r�r�r5r6rEr7r:rr)r1r2)r4r�r=r5r6rErPrQr$)rprqrrrsrKr?rrtrus@rNr/r/6s����������#�%7��"%�)-�
4�4�4�4�4�4�4�&.@��	
O�
O�
O�
O�
O��������rOr/c�8��eZdZdZ					dd�fd�
Zdd�Z�xZS)r�zA column containing text.�none�leftTN�text_formatr�r�r6�justifyr/�markupr��highlighter�Optional[Highlighter]rrrPrQc���||_||_||_||_||_t���|ptd������dS)NT��no_wrapr))rFrGr�rHrIrJrKr7)rLrFr�rGrHrIrrMs       �rNrKzTextColumn.__init__ks[���'���&-�����
����&���
�����l�&J�f�T�6J�6J�6J��K�K�K�K�KrOr�rr9c��|j�|���}|jr"tj||j|j���}nt||j|j���}|jr|j�|��|S�N�r�)r�rG)	rF�formatrHr9r<r�rGrI�	highlight)rLr��_textrBs    rNrzTextColumn.render{s���� �'�'�T�'�2�2���;�	G��#�E���T�\�R�R�R�D�D���T�Z���F�F�F�D���	-���&�&�t�,�,�,��rO)rDrETNN)rFr�r�r6rGr/rHr�rIrJrrrPrQ�r�rrPr9r-rus@rNr�r�hst�������#�#�
"�!'��-1�)-�L�L�L�L�L�L�L� �������rOr�c�:��eZdZdZ						dd�fd�
Zdd�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".
    �(rxryrzr{N�	bar_widthrr�r6r�r�r�rrrPrQc���||_||_||_||_||_t���|���dSr+)rWr�r�r�r�rJrK)rLrWr�r�r�r�rrMs       �rNrKzBarColumn.__init__�sL���#�����
�,���,���&���
�����l��3�3�3�3�3rOr�rr4c� �t|j�td|j��ndtd|j��|j�dntd|j��|j|���|j|j|j	|j
��	�	S)z&Gets a progress bar widget for a task.Nrr*)	r�rI�width�pulse�animation_timer�r�r�r�)r4r��maxrIrW�startedr�r�r�r�r�r#s  rNrzBarColumn.render�s����(,�
�H�#�a���$�$�$�D��!�T�^�,�,��.�L�$�$�c�!�T�^�6L�6L��l�"��=�=�?�?��*��.��.��(�

�

�

�
	
rO)rVrxryrzr{N)rWrr�r6r�r6r�r6r�r6rrrPrQ)r�rrPr4r-rus@rNr�r��st���������$&�%�$2�$2�!,�)-�4�4�4�4�4�4�4� 
�
�
�
�
�
�
�
rOr�c��eZdZdZdd�ZdS)	�TimeElapsedColumnzRenders time elapsed.r�rrPr9c���|jr|jn|j}|�tdd���St	tdt
|�������}tt|��d���S)zShow time elapsed.N�-:--:--�progress.elapsed�r�r)�seconds)rA�
finished_time�elapsedr9r
r]r�r�)rLr�rg�deltas    rNrzTimeElapsedColumn.render�sn��(,�
�G�$�$�$�4�<���	=��	�);�<�<�<�<��#�a��W���"6�"6�7�7�7���C��J�J�&8�9�9�9�9rONrT�rprqrrrsrr�rOrNr`r`�s.��������:�:�:�:�:�:rOr`c�V��eZdZdZ								d!d"�fd�
Zed#d���Zd$d �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.
    �-[progress.percentage]{task.percentage:>3.0f}%r(rDrETNFrFr��text_format_no_percentager�r6rGr/rHr�rIrJrrr�rPrQc	�r��||_||_t���||||||���dS)N)rFr�rGrHrIr)rlr�rJrK)
rLrFrlr�rGrHrIrr�rMs
         �rNrKzTaskProgressColumn.__init__�sR���*C��&�$���
�����#����#�%�
	�	
�	
�	
�	
�	
rOr6r�r9c��|�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.
        Nr(zprogress.percentagerd)r(u×10³u×10⁶u×10⁹u×10¹²��z.1fz it/s)r9r+�pick_unit_and_suffixr�)�clsr6�unit�suffix�
data_speeds     rN�render_speedzTaskProgressColumn.render_speed�s{���	9���"7�8�8�8�8��4���J�J�<�<�<��
�
���f�
�T�\�
��z�4�4�v�4�4�4�<Q�R�R�R�RrOr�rc��|j�(|jr!|�|jp|j��S|j�|jn|j}|�|���}|jr"tj
||j|j���}nt||j|j���}|j
r|j
�|��|SrO)r�r�ru�finished_speedr6rlrFrQrHr9r<r�rGrIrR)rLr�rFrSrBs     rNrzTaskProgressColumn.render�s����:�	H�$�/�	H��$�$�T�%8�%F�D�J�G�G�G�.2�j�V�D�*�*�d�FV�	��"�"��"�-�-���;�	G��#�E���T�\�R�R�R�D�D���T�Z���F�F�F�D���	-���&�&�t�,�,�,��rO)rkr(rDrETNNF)rFr�rlr�r�r6rGr/rHr�rIrJrrr�r�rPrQ)r6r�rPr9rT)	rprqrrrsrK�classmethodrurrtrus@rNr�r��s����������K�)+�!�!'��-1�)-� �
�
�
�
�
�
�
�,�S�S�S��[�S�&
�
�
�
�
�
�
�
rOr�c�8��eZdZdZdZ			dd�fd
�
Zdd�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.
    ��?FN�compactr�r�rrc�h��||_||_t���|���dSr+)r{r�rJrK)rLr{r�rrMs    �rNrKzTimeRemainingColumn.__init__s5������%:��"�
�����l��3�3�3�3�3rOr�rrPr9c�t�|jr|jr
|j}d}n	|j}d}|j�td|���S|�t|jrdnd|���Stt|��d��\}}t|d��\}}|jr|s
|d	�d
|d	��}n
|d�d
|d	�d
|d	��}t||���S)zShow time remaining.rczprogress.remainingNr(rdz--:--rb�<�02d�:�d)	r�rArf�time_remainingr�r9r{�divmodr�)rLr��	task_timer��minutesre�hours�	formatteds        rNrzTimeRemainingColumn.renders
���%�	)�$�-�	)��*�I�&�E�E��+�I�(�E��:�	)���%�(�(�(�(��	M��4�<�>���Y�e�L�L�L�L�"�#�i�.�.�"�5�5�������,�,���w��<�	A��	A�"�6�6�6��6�6�6�I�I� �@�@�@�W�@�@�@�7�@�@�@�I��I�U�+�+�+�+rO)FFN)r{r�r�r�rrrT)rprqrrrsrrKrrtrus@rNr�r�sr����������K��&+�)-�	4�4�4�4�4�4�4�,�,�,�,�,�,�,�,rOr�c��eZdZdZdd�ZdS)	�FileSizeColumnzRenders completed filesize.r�rrPr9c�p�tjt|j����}t	|d���S)�Show data completed.zprogress.filesizerd)r+�decimalr�rIr9�rLr��	data_sizes   rNrzFileSizeColumn.render7s0���$�S���%8�%8�9�9�	��I�%8�9�9�9�9rONrTrir�rOrNr�r�4s.������%�%�:�:�:�:�:�:rOr�c��eZdZdZdd�ZdS)	�TotalFileSizeColumnzRenders total filesize.r�rrPr9c��|j�&tjt|j����nd}t	|d���S)r�Nr(zprogress.filesize.totalrd)r�r+r�r�r9r�s   rNrzTotalFileSizeColumn.render@s;��9=��W�H�$�S���_�_�5�5�5�UW�	��I�%>�?�?�?�?rONrTrir�rOrNr�r�=s4������!�!�@�@�@�@�@�@rOr�c�.��eZdZdZdd�fd�
Zdd
�Z�xZS)�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�rrc�Z��||_t���|���dSr+)r�rJrK)rLr�rrMs   �rNrKzMofNCompleteColumn.__init__Rs+���"���
�����l��3�3�3�3�3rOr�rrPr9c���t|j��}|j�t|j��nd}tt	|����}t||�d��|j�|��d���S)zShow completed/total.N�?r��progress.downloadrd)r�rIr�r�r�r9r�)rLr�rIr��total_widths     rNrzMofNCompleteColumn.renderVst�����'�'�	�#'�:�B��D�J����s���#�e�*�*�o�o����+�@�@�@�@���@��@�@�%�
�
�
�	
rO)r�N)r�r�rrrTr-rus@rNr�r�Fs`�������	�	�4�4�4�4�4�4�4�
�
�
�
�
�
�
�
rOr�c�0��eZdZdZ	dd�fd
�
Zdd�Z�xZS)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�rrrPrQc�Z��||_t���|���dSr+)r�rJrK)rLr�rrMs   �rNrKzDownloadColumn.__init__hs.���)���
�����l��3�3�3�3�3rOr�rr9c��t|j��}|j�t|j��n|}|jrt	j|gd�d��\}}nt	j|gd�d��\}}|dkrdnd}||z}|d|�d	��}|j�"t|j��}	|	|z}
|
d|�d	��}nd
}|�d|�d|��}t
|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�YBror*rz,.�fr�r�r3r�rd)r�rIr�r�r+rpr9)rLr�rI� unit_and_suffix_calculation_baserrrs�	precision�completed_ratio�
completed_strr��total_ratio�	total_str�download_status�
download_texts              rNrzDownloadColumn.renderns.�����'�'�	� $�z�D�C��
�O�O�O�9�	)���	�#�8�0�Q�Q�Q����L�D�&�&�$�8�0�I�I�I����L�D�&�
���)�A�A��	�#�d�*��*�;�i�;�;�;�;�
��:�	���
�O�O�E��$�,�K�&�7�)�7�7�7�7�I�I��I�*�A�A�Y�A�A��A�A���_�4G�H�H�H�
��rO)FN)r�r�rrrPrQrTr-rus@rNr�r�asg���������LP�4�4�4�4�4�4�4�!�!�!�!�!�!�!�!rOr�c��eZdZdZdd�ZdS)	�TransferSpeedColumnz&Renders human readable transfer speed.r�rrPr9c��|jp|j}|�tdd���Stjt|����}t|�d�d���S)zShow data transfer speed.Nr�zprogress.data.speedrdz/s)rwr6r9r+r�r�)rLr�r6rts    rNrzTransferSpeedColumn.render�s`���#�1�t�z���	:���#8�9�9�9�9��%�c�%�j�j�1�1�
��z�%�%�%�-B�C�C�C�CrONrTrir�rOrNr�r��s4������0�0�D�D�D�D�D�DrOr�c�*�eZdZUdZded<	ded<dS)�ProgressSamplez$Sample of progress for a given time.rErrIN)rprqrrrsr%r�rOrNr�r��s3�������.�.����������$�$rOr�c��eZdZUdZded<	ded<	ded<	ded	<	d
ed<	dZded
<	dZded<	ee���Z	ded<	eddd���Z
ded<	eddd���Zded<	dZded<	ed�dd���Z
ded<ede���Zded<	d+d!�Zed,d"���Zed-d#���Zed-d$���Zed,d%���Zed+d&���Zed-d'���Zed-d(���Zd.d*�ZdS)/�Taskz�Information regarding a progress task.

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

    r;rr�rr�r�rErI�GetTimeCallable�	_get_timeNrfTr��visible)�default_factoryzDict[str, Any]�fieldsF)�default�init�repr�
start_time�	stop_timerwc�"�td���S)Nro)�maxlenrr�rOrN�<lambda>z
Task.<lambda>�s���T� 2� 2� 2�rO)r�r�r�zDeque[ProgressSample]�	_progress)r�r�r�_lockrPc�*�|���S)z(float: Get the current time, in seconds.)r�r`s rNr�z
Task.get_time�s���~�~���rOc��|jduS)z#bool: Check if the task as started.N)r�r`s rNr^zTask.started�s����d�*�*rOc�2�|j�dS|j|jz
S)zPOptional[float]: Get the number of steps remaining, if a non-None total was set.N�r�rIr`s rN�	remainingzTask.remaining�s"���:�	��4��z�D�N�*�*rOc�x�|j�dS|j�|j|jz
S|���|jz
S)z]Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started.N)r�r�r�r`s rNrgzTask.elapsed�sA���?�	��4��>�	4��>�D�O�3�3��}�}�����0�0rOc��|jduS)zCheck if the task has finished.N)rfr`s rNrAz
Task.finished�s���!��-�-rOc�x�|jsdS|j|jzdz}tdtd|����}|S)zOfloat: Get progress of task as a percentage. If a None total was set, returns 0��Y@)r�rI�minr])rLrIs  rN�
percentagezTask.percentage�sE���z�	��3��^�d�j�0�E�9�	���s�3�	�2�2�3�3�	��rOc�^�|j�dS|j5|j}|s	ddd��dS|dj|djz
}|dkr	ddd��dSt	|��}t|��t
d�|D����}||z}|cddd��S#1swxYwYdS)z=Optional[float]: Get the estimated speed in steps per second.Nr�rc3�$K�|]}|jV��dSr]r�)�.0�samples  rN�	<genexpr>zTask.speed.<locals>.<genexpr>s%����!O�!O�v�&�"2�!O�!O�!O�!O�!O�!OrO)r�r�r�r�iterr�r�)rLr@�
total_time�
iter_progress�total_completedr6s      rNr6z
Task.speed�sN���?�	��4�
�Z�	�	��~�H��
��	�	�	�	�	�	�	�	�"�"��/�(�1�+�2G�G�J��Q��
��
	�	�	�	�	�	�	�	�!��N�N�M������!�!O�!O��!O�!O�!O�O�O�O�#�j�0�E��	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�B"�"B"�=B"�"B&�)B&c�h�|jrdS|j}|sdS|j}|�dSt||z��}|S)zJOptional[float]: Get estimated time to completion, or ``None`` if no data.r�N)rAr6r�r
)rLr6r��estimates    rNr�zTask.time_remainingsR���=�	��3��
���	��4��N�	��	��4��	�E�)�*�*���rOrQc�T�|j���d|_d|_dS)zReset progress.N)r��clearrfrwr`s rN�_resetzTask._resets,���������!���"����rO)rPrEr�)rPr�rn)rprqrrrsr%rfr�r	�dictr�r�r�rwr�rr�r�r�r^r�rgrAr�r6r�r�r�rOrNr�r��sr����������J�J�J�G�����'�����>�����*�����+�%)�M�)�)�)�)�(��G�����J�"�U�4�8�8�8�F�8�8�8�8�?�"'�%��5�u�"M�"M�"M�J�M�M�M�M�N�!&��t�%�e�!L�!L�!L�I�L�L�L�L�N�&*�N�*�*�*�*�>�',�u�2�2��U�(�(�(�I������5�e�U�;�;�;�E�;�;�;�;�� � � � ��+�+�+��X�+��+�+�+��X�+��1�1�1��X�1��.�.�.��X�.������X�������X��"�����X��#�#�#�#�#�#rOr�c��eZdZdZddddddddddd�
dsd�Zedtd���Zedud���Zedvd ���Z	edwd"���Z
edxd#���Zdyd$�Zdyd%�Z
dzd'�Zd{d.�Z					d|d}d=�Z	d~dd>d?�ddC�Zej				d�ddd>dE�d�dN���Zej				d�ddd>dE�d�dQ���Z					d�ddd>dE�d�dU�Zd�dW�Zd�dX�ZdddddddY�d�d`�Zddd/ddda�d�dc�Zd�d�de�Zdydf�Zd�dh�Zd�dj�Zd�dn�Zd�do�Z				d�d�dq�Zd�dr�Z dS)�r�a�Renders an auto-updating progress bar(s).

    Args:
        console (Console, optional): Optional Console instance. Defaults to an internal Console instance writing to stdout.
        auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()`.
        refresh_per_second (Optional[float], optional): Number of times per second to refresh the progress information or None to use default (10). Defaults to None.
        speed_estimate_period: (float, optional): Period (in seconds) used to calculate the speed estimate. Defaults to 30.
        transient: (bool, optional): Clear the progress on exit. Defaults to False.
        redirect_stdout: (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True.
        redirect_stderr: (bool, optional): Enable redirection of stderr. Defaults to True.
        get_time: (Callable, optional): A callable that gets the current time, or None to use Console.get_time. Defaults to None.
        disable (bool, optional): Disable progress display. Defaults to False
        expand (bool, optional): Expand tasks table to fit width. Defaults to False.
    NTrwg>@F)
r�r�r��speed_estimate_periodr��redirect_stdout�redirect_stderrr�r��expandr��Union[str, ProgressColumn]r�r�r�r�r�rEr�r�r�r�r��Optional[GetTimeCallable]r�r�rPrQc
	��|dks
Jd���t��|_|p|���|_||_|	|_|
|_i|_td��|_	t|p
t��||||||j���|_
|p|jj|_|jj|_|jj|_dS)Nrzrefresh_per_second must be > 0)r�r�r�r�r�r��get_renderable)rr��get_default_columnsr�r�r�r��_tasksr;�_task_indexr3r,r�rVr�r��print�log)rLr�r�r�r�r�r�r�r�r�r�r�s            rNrKzProgress.__init__5s���"�A�%�G�G�'G�G�G�G��W�W��
��<�$�":�":�"<�"<���%:��"�������*,���#)�!�9�9�����,�{�}�}�%�1��+�+��.�
�
�
��	�!�9�D�L�$9��
��\�'��
��<�#����rO�Tuple[ProgressColumn, ...]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�)rqs rNr�zProgress.get_default_columnsYs3��2
�A�B�B��K�K�� � ��!�!�	
�	
rOr-c��|jjSr])rVr�r`s rNr�zProgress.consolexs
���y� � rO�
List[Task]c��|j5t|j�����cddd��S#1swxYwYdS)zGet a list of Task instances.N)r��listr��valuesr`s rN�taskszProgress.tasks|s����Z�	.�	.����*�*�,�,�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�	.�	.�
�&;�?�?�List[TaskID]c��|j5t|j�����cddd��S#1swxYwYdS)zA list of task IDs.N)r�r�r��keysr`s rN�task_idszProgress.task_ids�s����Z�	,�	,����(�(�*�*�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,r�c���|j5|js	ddd��dStd�|j���D����cddd��S#1swxYwYdS)z'Check if all tasks have been completed.NTc3�$K�|]}|jV��dSr])rA)r�r�s  rNr�z$Progress.finished.<locals>.<genexpr>�s$����F�F��t�}�F�F�F�F�F�FrO)r�r��allr�r`s rNrAzProgress.finished�s����Z�	G�	G��;�
��	G�	G�	G�	G�	G�	G�	G�	G��F�F���1C�1C�1E�1E�F�F�F�F�F�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G�	G�	Gs�	A�/A�A�!Ac�N�|js|j�d���dSdS)zStart the progress display.T)rSN)r�rVr_r`s rNr_zProgress.start�s2���|�	*��I�O�O�D�O�)�)�)�)�)�	*�	*rOc��|j���|jjs'|jjs|j���dSdSdS)zStop the progress display.N)rVr�r��is_interactive�
is_jupyterr�r`s rNr�z
Progress.stop�s[���	�������|�*�	!�4�<�3J�	!��L��� � � � � �	!�	!�	!�	!rOr)c�.�|���|Sr]r^r`s rNrazProgress.__enter__�rbrOrcrdrerfrgrhc�.�|���dSr])r�rls    rNrmzProgress.__exit__�s��	
�	�	�����rOrrvr|r}r~r�r�rIr�rB�Optional[TaskID]rr�rDc#�K�|�tt|����pd}|�|�|||���}n|�|||���|jjrFt
|||��5}|D]}|V�|xjdz
c_�	ddd��dS#1swxYwYdS|j}	|j	}
|D]}|V�|	|d��|
���dS)aCTrack progress by iterating over a sequence.

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

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

        Returns:
            Iterable[ProgressType]: An iterable of values taken from the provided sequence.
        Nr�r*)
rEr�add_taskrXrVr�r?rIrTrS)rLr}r�rIrBrrD�track_thread�valuerTrSs           rNr�zProgress.track�si����0�	9��+�h�/�/�0�0�8�D�E��	C��m�m�K�u�	�m�R�R�G�G��K�K��u�	�K�B�B�B��9�!�	��d�G�]�;�;�
0�|�%�0�0�E��K�K�K� �*�*�a�/�*�*�*�0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0�
0�
0�
�l�G��l�G�!�
�
����������#�#�#���	�	�	�	�
�
s�3B�B�"Br�)rBrr�rrc� �d}|�|}n3|�1|j5|j|j}ddd��n#1swxYwY|�td���|�|�||���}n|�||���t
|||d���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�)r�r�r��
ValueErrorrrXr�)rLr�r�rBr�total_bytess      rNr�zProgress.wrap_file�s���.(,���	9��K�K�
�	9���
9�
9�"�k�'�2�8��
9�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9����
9�
9�
9�
9��	��R���
�
�	4��m�m�K�{�m�C�C�G�G��K�K��{�K�3�3�3��t�T�7��?�?�?�?s�0�4�4r�)r�rBrr�r�rr�r�r�rrc��dSr]r��
rLr�r�r�r�rrr�rBrs
          rNrz
Progress.open��	��	
�rO�"Union[Literal['r'], Literal['rt']]r$c��dSr]r�rs
          rNrz
Progress.openrrOr
r�Union[BinaryIO, TextIO]c�6�d�t|d�����}
|
dvrtd|�����|dk}|
dkr#|dkrtjdt
��d	}n!|
d
vr|dkrtd���|dkrd	}|�t
|��j}|�|�|	|���}n|�	||���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.
        r(F)�reverse)�br�rtr
z
invalid mode r*rzaline 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�rb)r�Tr)r
r )r�rr�line_buffering)rk�sortedr�warnings�warn�RuntimeWarningr�st_sizerrX�iorr��
TextIOWrapper)rLr�r�r�r�rrr�rBr�_moder"r�r�s              rNrz
Progress.opens���B����t�U�3�3�3�4�4���)�)�	7��5�T�5�5�6�6�6�#�a����D�=�
	�Y�!�^�
	��M�s��
�
�
��I�I�
�k�
!�	��A�~�
� �!A�B�B�B��a��
��	��	'���J�J�&�E��	.��m�m�K�u�m�=�=�G�G��K�K��u�K�-�-�-����t�y�9�9�9�����w�T�B�B�B���;��	��#��!���-����
��
rOr;c��|j5|j|}|j�|���|_ddd��dS#1swxYwYdS)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�r�)rLrBr�s   rN�
start_taskzProgress.start_taskks����Z�	2�	2��;�w�'�D���
2�"&�-�-�/�/���	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2s�.A�A�
Ac��|j5|j|}|���}|j�||_||_ddd��dS#1swxYwYdS)z�Stop a task.

        This will freeze the elapsed time on the task.

        Args:
            task_id (TaskID): ID of task.
        N)r�r�r�r�r�)rLrBr�rs    rN�	stop_taskzProgress.stop_taskys����Z�	*�	*��;�w�'�D��=�=�?�?�L���
/�".���)�D�N�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*s�7A�A�A)r�rIrTrr�rSrTr��Optional[bool]rSr�rc���|j5|j|}	|	j}
|�&||	jkr||	_|	���|�|	xj|z
c_|�||	_|�||	_|�||	_|	j�|��|	j|
z
}|�	��}||j
z
}
|	j}|j}|r.|dj
|
kr|��|r|dj
|
k�|dkr#|�t||����|	j�#|	j|	jkr|	j�|	j|	_ddd��n#1swxYwY|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)r�r�rIr�r�rr�r�rXr�r�r��popleftr�appendr�rfrgrS)rLrBr�rIrTrr�rSr�r��completed_start�update_completedr�old_sample_timer�r1s                rNrXzProgress.update�s���0�Z� 	2� 	2��;�w�'�D�"�n�O��
�U�d�j�%8�
�"��
����
�
�
��
*����'�)����
+�!*����
/�#.�� ��
'�&����K���v�&�&�&�#�~��?���=�=�?�?�L�*�T�-G�G�O���I��'�G��
�	�!�� 6�� H�
���	�	�	��
�	�!�� 6�� H�
��!�#�
Q�� � ���>N�!O�!O�P�P�P��
�
2��N�d�j�0�
2��&�
2�
&*�\��"�A 	2� 	2� 	2� 	2� 	2� 	2� 	2� 	2� 	2� 	2� 	2���� 	2� 	2� 	2� 	2�D�	��L�L�N�N�N�N�N�	�	s�D=E�E�E)r_r�rIr�rr_c�P�|���}|j5|j|}	|	���|r|nd|	_|�||	_||	_|�||	_|r||	_|�||	_	d|	_
ddd��n#1swxYwY|���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)r�r�r�r�r�r�rIr�r�rrfrS)
rLrBr_r�rIr�rr�rr�s
          rN�resetzProgress.reset�s���,�}�}����
�Z�
	&�
	&��;�w�'�D��K�K�M�M�M�.3�=�l�l��D�O��
#�"��
�&�D�N��
'�&����
%�$����
/�#.�� �!%�D��
	&�
	&�
	&�
	&�
	&�
	&�
	&�
	&�
	&�
	&�
	&����
	&�
	&�
	&�
	&�	
�������s�AB�B�Br*c�l�|���}|j5|j|}|j}|xj|z
c_|j|z
}||jz
}|j}|j}	|r.|dj|kr|	��|r|dj|k�t|��dkr|	��t|��dk�|�	t||����|j�/|j|jkr|j�|j
|_|j|_ddd��dS#1swxYwYdS)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.
        rroN)r�r�r�rIr�r�r1rr�r2r�r�rfrgr6rw)
rLrBrTrr�r3r4r5r�r1s
          rNrTzProgress.advance�s����}�}����
�Z�	1�	1��;�w�'�D�"�n�O��N�N�g�%�N�N�#�~��?��*�T�-G�G�O���I��'�G��
�	�!�� 6�� H�
���	�	�	��
�	�!�� 6�� H�
��i�.�.�4�'�
���	�	�	��i�.�.�4�'�
����^�L�:J�K�K�L�L�L��
�
1��N�d�j�0�
1��&�
1�
&*�\��"�&*�j��#�)	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s�DD)�)D-�0D-c�f�|js'|jjr|j���dSdSdS)z*Refresh (render) the progress information.N)r�rVrWrSr`s rNrSzProgress.refresh
sF���|�	 ��	� 4�	 ��I��������	 �	 �	 �	 rOr0c�<�t|����}|S)z*Get a renderable for the progress display.)r.�get_renderables)rLr s  rNr�zProgress.get_renderables���D�0�0�2�2�3�
��rO�Iterable[RenderableType]c#�FK�|�|j��}|V�dS)z5Get a number of renderables for the progress display.N)�make_tasks_tabler�)rL�tables  rNr;zProgress.get_renderabless(�����%�%�d�j�1�1�������rOr��Iterable[Task]r8c���d�|jD��}tj|d|jd��}|D]$��jr|j�fd�|jD����%|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�|]O}t|t��rtd���n%|������V��PdS)TrLN)r;r�r7r�copy)r��_columns  rNr�z,Progress.make_tasks_table.<locals>.<genexpr>"sr����
�
���g�s�+�+�7��t�$�$�$�$��-�-�/�/�4�4�6�6�	
�
�
�
�
�
rO)rr*)�paddingr�c3��K�|]:}t|t��r|�����n
|���V��;dS)rPN)r;r�rQ)r��columnr�s  �rNr�z,Progress.make_tasks_table.<locals>.<genexpr>/sf�������#� *�&�#�6�6�.�F�M�M�t�M�4�4�4�!'�����	�����rO)r�r8�gridr�r��add_row)rLr��
table_columnsr?r�s    @rNr>zProgress.make_tasks_tables����
�
� �<�

�
�
�
��
�M�6�$�+�N�N�N���	�	�D��|�

���
�����'+�l�
���	�	���rOc�l�|j5|���cddd��S#1swxYwYdS)z+Makes the Progress class itself renderable.N)r�r�r`s rN�__rich__zProgress.__rich__:s}��
�Z�	)�	)��&�&�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s�)�-�-r�c�n�|j5t|j||||||j|j���}||j|j<|r|�|j��|j}t
t|j��dz��|_ddd��n#1swxYwY|���|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�r�r�r�r*N)	r�r�r�r�r�r,r;r�rS)	rLrr_r�rIr�r�r��new_task_indexs	         rNrzProgress.add_task?s��0�Z�	A�	A��� �������-��j�	�	�	�D�-1�D�K��(�)��
2����� 0�1�1�1�!�-�N�%�c�$�*:�&;�&;�a�&?�@�@�D��	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A� 	
�������s�BB�B�Bc�V�|j5|j|=ddd��dS#1swxYwYdS)z]Delete a task if it exists.

        Args:
            task_id (TaskID): A task ID.

        N)r�r�)rLrBs  rN�remove_taskzProgress.remove_taskjsz���Z�	%�	%���G�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	%�	%s�	�"�")r�r�r�r�r�r�r�rEr�rEr�r�r�r�r�r�r�r�r�r�r�r�rPrQ)rPr�)rPr-)rPr�)rPrr�rn)rPr)ro)NrNrvr|)r}r~r�r�rIr�rBr
rr�rDrErPr~r])
r�rr�rrBr
rr�rPr�r�NNN)r�r�r�rr�r�r�r�rr�rr�r�rrBr
rr�rPr)r�r�r�rr�r�r�r�rr�rr�r�rrBr
rr�rPr$�r
r�NNN)r�r�r�rr�r�r�r�rr�rr�r�rrBr
rr�rPr)rBr;rPrQ)rBr;r�r�rIr�rTr�rr�r�r/rSr�r�rrPrQ)rBr;r_r�r�r�rIr�r�r/rr�r�rrPrQ)r*)rBr;rTrErPrQ)rPr0)rPr<)r�r@rPr8)Tr�rT)rr�r_r�r�r�rIr�r�r�r�rrPr;)!rprqrrrsrKrxr�r�r�r�rrAr_r�rarmr�r��typing�overloadrr,r.rXr7rTrSr�r;r>rLrrPr�rOrNr�r�%s�������
�
�$&*�!�$&�'+�� $� $�.2���"$�"$�"$�"$�"$�"$�H�
�
�
��[�
�<�!�!�!��X�!��.�.�.��X�.�
�,�,�,��X�,�
�G�G�G��X�G�*�*�*�*�
!�!�!�!���������"&��$(�'�"�+�+�+�+�+�` $�(@�
%)�'�
(@�(@�(@�(@�(@�(@�T�_�
�"&� $�!%�

� $�$(�'�

�

�

�

�

��_�

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

� $�$(�'�

�

�

�

�

��_�

�$CF��"&� $�!%�K� $�$(�'�K�K�K�K�K�K�Z2�2�2�2�
*�
*�
*�
*�&"&�%)�#'�%)�"&��;�;�;�;�;�;�B�!%��"&�%)�%�%�%�%�%�%�N1�1�1�1�1�< � � � �
����
����
����B)�)�)�)��!&���
)�)�)�)�)�V%�%�%�%�%�%rOr��__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)�typerBz	Syntax...zGive it a try!)�cycle)�record)r�r�z[red]Downloadingrorz[green]Processingz[yellow]Thinkingrzr�g333333�?g{�G�z�?�d)rvNrTNFNrwrxryrzr{r|FT)"r}r~rr�r�r�rIr�r�r�r�r�r�r�r�r�r�rEr�r6r�r6r�r6r�r6rDrEr�r�r�r�rPr~)r�rr�r�rr�r�r�r�r�r�r�r�r�r�rEr�r6r�r6r�r6r�r6r�r�rPr�rQ)&r�r�r�r�r�r�r�r�rr�rr�r�rrr�r�r�r�r�r�r�r�r�r�rEr�r6r�r6r�r6r�r6r�r�rPr)&r�r�r�rr�r�r�r�rr�rr�r�rrr�r�r�r�r�r�r�r�r�r�rEr�r6r�r6r�r6r�r6r�r�rPr�rR)&r�r�r�rr�r�r�r�rr�rr�r�rrr�r�r�r�r�r�r�r�r�r�rEr�r6r�r6r�r6r�r6r�r�rPr)��
__future__rr(rSr$�abcrr�collectionsr�dataclassesrr	�datetimer
rr�mathr
r�operatorr�osrr�	threadingrrr�typesrrrrrrrrrrrr r!r"r#r$r%r&r'r(�typing_extensionsr)r(r+r,r�r-r.r/r0rIr1�jupyterr2rVr3�progress_barr4r:r5r�r6r?r7r8rBr9r:r�r;r<rEr�r=r?r�r�r�r�rTrrr'r/r�r�r`r�r�r�r�r�r�r�r�r�r�rp�random�time�panelrV�rulerW�syntaxrXrI�progress_renderables�	itertoolsrc�examplesr�r@r�task1�task2�task3rArX�sleep�randintr�r�r�rOrN�<module>r�s#��"�"�"�"�"�"�	�	�	�	�
�
�
�
�����#�#�#�#�#�#�#�#�������(�(�(�(�(�(�(�(�������.�.�.�.�.�.�.�.������������� � � � � � ���������*�*�*�*�*�*�*�*�*�*�������������������������������������������������,�'�&�&�&�&�&�&�#�#�#�#�#�#�#�#�B�B�B�B�B�B�B�B�B�B�B�B�$�$�$�$�$�$�!�!�!�!�!�!�������%�%�%�%�%�%������������� � � � � � � � � � � � � � � � �	���3�	�	���w�~�&�&���2�u�9�%���V�^�D�&�(�+�+��%�%�%�%�%�6�%�%�%�T$�!���!%��.2� "�!� .� .�(����!K
�K
�K
�K
�K
�\d1�d1�d1�d1�d1�i��d1�d1�d1�N8�8�8�8�8�>�"�%�w�r�{�8�8�8�2$��!%��.2� "�!� .� .�(��>*�>*�>*�>*�>*�>*�B���"� �!�
	� �#��!%��.2� "�!� .� .�(��'	�	�	�	�	���	�0���"� �!�
	� �#��!%��.2� "�!� .� .�(��'	�	�	�	�	���	�4?B��"� �!�
S*� �#��!%��.2� "�!� .� .�(��'S*�S*�S*�S*�S*�S*�l'1�'1�'1�'1�'1�S�'1�'1�'1�T�����~����"/�/�/�/�/�N�/�/�/�d���������<'
�'
�'
�'
�'
��'
�'
�'
�T	:�	:�	:�	:�	:��	:�	:�	:�E�E�E�E�E��E�E�E�P-,�-,�-,�-,�-,�.�-,�-,�-,�`:�:�:�:�:�^�:�:�:�@�@�@�@�@�.�@�@�@�
�
�
�
�
��
�
�
�6.�.�.�.�.�^�.�.�.�b	D�	D�	D�	D�	D�.�	D�	D�	D�%�%�%�%�%�Z�%�%�%��z#�z#�z#�z#�z#�z#�z#���z#�zM	%�M	%�M	%�M	%�M	%�|�M	%�M	%�M	%�`�z��>-��M�M�M��K�K�K�������������������������
�V�
	"�	�����F� 
�E�%���&�&�E�	�M�M�#�s�C� � � �	E�
��8�9�9�'�
�&��$4�5�5�����
���
�� �������u�)�*�*�H��g�T�"�"�"�G�	���
���
�	�	%�	%�	'�	'�
�	����
�
���
�
�
�-�
��!�!�"4�D�!�A�A���!�!�"5�T�!�B�B���!�!�"4�D�!�A�A���#�	-��O�O�E�3�O�/�/�/��O�O�E�3�O�/�/�/��D�J�t�����v�~�a��%�%��)�
-����T�T�(�^�^�,�,�,��#�	-�-�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-�-�-�]>-�>-s�9CQ�Q�Q