o
    Rh                  +   @   s*  d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ d dl	m
Z
mZ d dlmZ d dl mZmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZ d dlmZmZmZ d dlmZ d dlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ej0dkrd dlm1Z1 nd dl2m1Z1 ej0dkrd dlm3Z3 nd dl2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZG ddlHmIZImJZJ ddlKmLZLmMZM e(deNZOe.dZPe g eQf ZRe.de+eZSG d d! d!eZT	"		 	#		$		%	&	'	(	)	*	$	#dd+e/e*eP e%eP f d,eUd-e)eQ d.eNd/eVd0e)e8 d1eVd2e)e g eQf  d3eQd4eGd5eGd6eGd7eGd8eQd9eVd:eVd;e%eP f"d<d=ZWG d>d? d?eeZXG d@dA dAe!eS e$eS ZYdBd#dd$dd%d&d'd(d)d$dCdDed-eNd,eUd/eVd0e)e8 d1eVd2e)e g eQf  d3eQd4eGd5eGd6eGd7eGd9eVd;e!e fdEdFZZej[	G			dddBd#dd$dd%d&d'd(d)d$dHdDe/eUdIe\f dJe/e1dK e1dL f dMeNdNe)eU dOe)eU dPe)eU d-e)eN d,eUd/eVd0e)e8 d1eVd2e)e g eQf  d3eQd4eGd5eGd6eGd7eGd9eVd;e!e+ f&dQdRZ]ej[	G			dddBd#dd$dd%d&d'd(d)d$dHdDe/eUdIe\f dJe1dS dMeNdNe)eU dOe)eU dPe)eU d-e)eN d,eUd/eVd0e)e8 d1eVd2e)e g eQf  d3eQd4eGd5eGd6eGd7eGd9eVd;e!e f&dTdRZ]	L	G			dddBd#dd$dd%d&d'd(d)d$dHdDe/eUdIe\f dJe/e1dS e1dK e1dL f dMeNdNe)eU dOe)eU dPe)eU d-e)eN d,eUd/eVd0e)e8 d1eVd2e)e g eQf  d3eQd4eGd5eGd6eGd7eGd9eVd;e/e!e e!e+ f f&dUdRZ]G dVdW dWeZ^G dXdY dYe^Z_G dZd[ d[e^Z`G d\d] d]e^ZaG d^d_ d_e^ZbG d`da dae^ZcG dbdc dceaZdG ddde dee^ZeG dfdg dge^ZfG dhdi die^ZgG djdk dke^ZhG dldm dme^ZiG dndo doe^ZjG dpdq dqe'Zke
G drds dsZlG dtdu due?Zmendvkrd dloZod dlpZpddwlqmrZr ddxlsmtZt ddylumvZv ddzlHmJZJ evd{d|d#d}ZueJd~ddZHeHwddd derddeHdddddeuetdg	Zxd dlymzZz ezexZ{e8d#dZ7eme` gem| ec R e7d$dQZ}e}j~dddZe}j~dddZe}j~dddZe}js e}jedd e}jedd epd eod ddk re}ee{ e}jrW d   dS W d   dS 1 sw   Y  dS dS )    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)r&      )Self   )filesizeget_console)ConsoleGroupJustifyMethodRenderableType)Highlighter)JupyterMixin)Live)ProgressBar)Spinner)	StyleType)ColumnTable)TextTextTypeTaskIDProgressType_Ic                       sl   e Zd ZdZdddddef fddZdddZdddZdee	e
  dee
 dee d	d
fddZ  ZS )_TrackThreadz)A thread to periodically update progress.progressProgresstask_idr<   update_periodc                    s2   || _ || _|| _t | _d| _t jdd d S )Nr   T)daemon)r@   rB   rC   r   done	completedsuper__init__)selfr@   rB   rC   	__class__ O/home/air/sanwanet/backup_V2/venv/lib/python3.10/site-packages/rich/progress.pyrH   G   s   z_TrackThread.__init__returnNc                 C   s~   | j }| jj}| j}d}| jj}||s2| jjjr2| j}||kr)||||  |}||s2| jjjs| jj	| j | jdd d S )Nr   T)rF   refresh)
rB   r@   advancerC   rE   waitlive
is_startedrF   update)rI   rB   rP   rC   last_completedrQ   rF   rL   rL   rM   runP   s   z_TrackThread.runc                 C      |    | S NstartrI   rL   rL   rM   	__enter__^      z_TrackThread.__enter__exc_typeexc_valexc_tbc                 C   s   | j   |   d S rX   )rE   setjoinrI   r^   r_   r`   rL   rL   rM   __exit__b   s   
z_TrackThread.__exit__rN   N)rN   r?   )__name__
__module____qualname____doc__floatrH   rV   r\   r   r#   BaseExceptionr   rd   __classcell__rL   rL   rJ   rM   r?   D   s    
	

r?   
Working...TF
   bar.backbar.completebar.finished	bar.pulse皙?sequencedescriptiontotalrF   auto_refreshconsole	transientget_timerefresh_per_secondstylecomplete_stylefinished_stylepulse_stylerC   disable
show_speedrN   c              	   c   s    |rt dgng }|t|	|
||dt|dtddf t||||||p'd|d}| |j| ||||dE d	H  W d	   d	S 1 sGw   Y  d	S )
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).
        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_finishedrn   rw   rx   ry   rz   r{   r   )rv   rF   ru   rC   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnrA   track)rt   ru   rv   rF   rw   rx   ry   rz   r{   r|   r}   r~   r   rC   r   r   columnsr@   rL   rL   rM   r   l   s@   *
"r   c                   @   s  e Zd ZdZ	dBdedddededd	f
d
dZdCddZde	e
e  de	e de	e dd	fddZdefddZdefddZedefddZdefddZdefddZedefddZedefdd Zdefd!d"Zdefd#d$Zdefd%d&ZdDd(edefd)d*Zd+eeee f fd,d-Z!dDd(edefd.d/Z"dDd0ede#e fd1d2Z$dEd3d4Z%dFd6ed7edefd8d9Z&defd:d;Z'd<e(defd=d>Z)d?e*e( dd	fd@dAZ+d	S )G_Readerz9A reader that tracks progress while it's being read from.Thandler@   rA   taskclose_handlerN   Nc                 C   s"   || _ || _|| _|| _d| _d S NF)r   r@   r   r   _closed)rI   r   r@   r   r   rL   rL   rM   rH      s
   
z_Reader.__init__c                 C   s   | j   | S rX   )r   r\   r[   rL   rL   rM   r\      s   
z_Reader.__enter__r^   r_   r`   c                 C      |    d S rX   )closerc   rL   rL   rM   rd         z_Reader.__exit__c                 C   s   | S rX   rL   r[   rL   rL   rM   __iter__      z_Reader.__iter__c                 C   s$   t | j}| jj| jt|d |S NrP   )nextr   r@   rP   r   len)rI   linerL   rL   rM   __next__   s   
z_Reader.__next__c                 C      | j S rX   )r   r[   rL   rL   rM   closed   s   z_Reader.closedc                 C   
   | j  S rX   )r   filenor[   rL   rL   rM   r         
z_Reader.filenoc                 C   r   rX   )r   isattyr[   rL   rL   rM   r      r   z_Reader.isattyc                 C      | j jS rX   )r   moder[   rL   rL   rM   r         z_Reader.modec                 C   r   rX   )r   namer[   rL   rL   rM   r      r   z_Reader.namec                 C   r   rX   )r   readabler[   rL   rL   rM   r      r   z_Reader.readablec                 C   r   rX   )r   seekabler[   rL   rL   rM   r      r   z_Reader.seekablec                 C      dS r   rL   r[   rL   rL   rM   writable   r   z_Reader.writablesizec                 C   &   | j |}| jj| jt|d |S r   )r   readr@   rP   r   r   )rI   r   blockrL   rL   rM   r         z_Reader.readbc                 C   s"   | j |}| jj| j|d |S r   )r   readintor@   rP   r   )rI   r   nrL   rL   rM   r      s   z_Reader.readintoc                 C   r   r   )r   readliner@   rP   r   r   )rI   r   r   rL   rL   rM   r     r   z_Reader.readlinehintc                 C   s,   | j |}| jj| jttt|d |S r   )r   	readlinesr@   rP   r   summapr   )rI   r   linesrL   rL   rM   r     s   z_Reader.readlinesc                 C   s   | j r| j  d| _d S )NT)r   r   r   r   r[   rL   rL   rM   r     s   

z_Reader.closer   offsetwhencec                 C   s$   | j ||}| jj| j|d |S )NrF   )r   seekr@   rT   r   )rI   r   r   posrL   rL   rM   r     s   z_Reader.seekc                 C   r   rX   )r   tellr[   rL   rL   rM   r     r   z_Reader.tellsc                 C      t d)Nwriter
   )rI   r   rL   rL   rM   r        z_Reader.writer   c                 C   r   )N
writelinesr   )rI   r   rL   rL   rM   r     r   z_Reader.writelines)T)rN   r   )r   re   )r   ),rf   rg   rh   ri   r   r<   boolrH   r\   r   r#   rk   r   rd   r   bytesr   propertyr   intr   r   strr   r   r   r   r   r   r%   	bytearray
memoryviewr   r   r   r   r   r   r   r   r   r   r   r   rL   rL   rL   rM   r      s\    




r   c                   @   s^   e Zd ZdZdddeddfddZdefd	d
Zdeee	  dee	 dee
 ddfddZdS )_ReadContextzEA utility class to handle a context for both a reader and a progress.r@   rA   readerrN   Nc                 C   s   || _ || _d S rX   )r@   r   )rI   r@   r   rL   rL   rM   rH   "  s   
z_ReadContext.__init__c                 C   s   | j   | j S rX   )r@   rZ   r   r\   r[   rL   rL   rM   r\   &  s   

z_ReadContext.__enter__r^   r_   r`   c                 C   s   | j   | j||| d S rX   )r@   stopr   rd   rc   rL   rL   rM   rd   *  s   
z_ReadContext.__exit__)rf   rg   rh   ri   r>   rH   r\   r   r#   rk   r   rd   rL   rL   rL   rM   r     s    
r   
Reading...)ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   filec             	   C   sh   |rt dgng }|t||	|
|dt t f t||||||p"d|d}|j| ||d}t||S )a  Read bytes from a file while tracking progress.

    Args:
        file (Union[str, PathLike[str], BinaryIO]): The path to the file to read, or a file-like object in binary mode.
        total (int): Total number of bytes to read.
        description (str, optional): Description of task show next to progress bar. Defaults to "Reading".
        auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
        transient: (bool, optional): Clear the progress on exit. Defaults to False.
        console (Console, optional): Console to write to. Default creates internal Console instance.
        refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
        style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
        complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
        finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
        disable (bool, optional): Disable display of progress.
    Returns:
        ContextManager[BinaryIO]: A context manager yielding a progress reader.

    r   r   rn   r   )rv   ru   )r   r   r   DownloadColumnr   rA   	wrap_filer   )r   rv   ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r@   r   rL   rL   rM   r   4  s0   %

r   r   )rv   ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   PathLike[str]r   rtr	bufferingencodingerrorsnewlinec                C      d S rX   rL   r   r   r   r   r   r   rv   ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   rL   rL   rM   openu     r   rbc                C   r   rX   rL   r   rL   rL   rM   r     r   c             
   C   sr   |rt dgng }|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   rn   r   )r   r   r   r   r   rv   ru   )r   r   r   r   r   rA   r   r   )r   r   r   r   r   r   rv   ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r@   r   rL   rL   rM   r     sB   1


c                   @   sp   e Zd ZU dZdZee ed< ddee ddfddZ	defdd	Z
d
ddefddZed
ddefddZdS )ProgressColumnz3Base class for a widget to use in progress display.Nmax_refreshtable_columnrN   c                 C   s   || _ i | _d | _d S rX   )_table_column_renderable_cache_update_time)rI   r   rL   rL   rM   rH     s   
zProgressColumn.__init__c                 C   s   | j pt S )z.Get a table column, used to build tasks table.)r   r8   r[   rL   rL   rM   get_table_column  s   zProgressColumn.get_table_columnr   Taskc                 C   sp   |  }| jdur)|js)z
| j|j \}}W n	 ty   Y n
w || j |kr)|S | |}||f| j|j< |S )a  Called by the Progress object to return a renderable for the given task.

        Args:
            task (Task): An object containing information regarding the task.

        Returns:
            RenderableType: Anything renderable (including str).
        N)rz   r   rF   r   idKeyErrorrender)rI   r   current_time	timestamp
renderablerL   rL   rM   __call__  s   	
zProgressColumn.__call__c                 C   r   )z"Should return a renderable object.NrL   rI   r   rL   rL   rM   r   "  s    zProgressColumn.renderrX   )rf   rg   rh   ri   r   r   rj   __annotations__r8   rH   r   r1   r   r   r   rL   rL   rL   rM   r     s   
 r   c                       sJ   e Zd ZdZ	ddddedee f fddZd	d
defddZ  Z	S )RenderableColumnzA column to insert an arbitrary column.

    Args:
        renderable (RenderableType, optional): Any renderable. Defaults to empty string.
     Nr   r   r   c                      || _ t j|d d S Nr   )r   rG   rH   )rI   r   r   rJ   rL   rM   rH   .     zRenderableColumn.__init__r   r   rN   c                 C   r   rX   )r   r   rL   rL   rM   r   4  s   zRenderableColumn.render)r   )
rf   rg   rh   ri   r1   r   r8   rH   r   rl   rL   rL   rJ   rM   r   '  s    r   c                       s   e Zd ZdZ					ddedee d	ed
edee	 f
 fddZ
		ddedee d	eddfddZdddefddZ  ZS )SpinnerColumna  A column with a 'spinner' animation.

    Args:
        spinner_name (str, optional): Name of spinner animation. Defaults to "dots".
        style (StyleType, optional): Style of spinner. Defaults to "progress.spinner".
        speed (float, optional): Speed factor of spinner. Defaults to 1.0.
        finished_text (TextType, optional): Text used when task is finished. Defaults to " ".
    dotsprogress.spinner      ? Nspinner_namer|   speedfinished_textr   c                    s<   t |||d| _t|trt|n|| _t j|d d S )Nr|   r   r   )	r6   spinner
isinstancer   r:   from_markupr   rG   rH   )rI   r   r|   r   r   r   rJ   rL   rM   rH   B  s   zSpinnerColumn.__init__spinner_stylerN   c                 C   s   t |||d| _dS )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)r6   r  )rI   r   r  r   rL   rL   rM   set_spinnerR  s   zSpinnerColumn.set_spinnerr   r   c                 C   s$   |j r| j}|S | j| }|S rX   )finishedr   r  r   rz   )rI   r   textrL   rL   rM   r   a  s   zSpinnerColumn.render)r   r   r   r   N)r   r   )rf   rg   rh   ri   r   r   r7   rj   r;   r8   rH   r  r1   r   rl   rL   rL   rJ   rM   r   8  s<    
r   c                       sd   e Zd ZdZ					ddededed	ed
ee	 dee
 ddf fddZdddefddZ  ZS )r   zA column containing text.noneleftTNtext_formatr|   justifymarkuphighlighterr   rN   c                    s:   || _ || _|| _|| _|| _t j|ptddd d S )NTno_wrapr   )r
  r  r|   r  r  rG   rH   r8   )rI   r
  r|   r  r  r  r   rJ   rL   rM   rH   m  s   	zTextColumn.__init__r   r   c                 C   sR   | j j|d}| jrtj|| j| jd}n	t|| j| jd}| jr'| j| |S Nr   )r|   r  )	r
  formatr  r:   r  r|   r  r  	highlight)rI   r   _textr  rL   rL   rM   r   }  s   zTextColumn.render)r  r	  TNN)rf   rg   rh   ri   r   r7   r0   r   r   r2   r8   rH   r:   r   rl   rL   rL   rJ   rM   r   j  s.    r   c                       sf   e Zd ZdZ						ddee d	ed
edededee ddf fddZddde	fddZ
  ZS )r   a  Renders a visual progress bar.

    Args:
        bar_width (Optional[int], optional): Width of bar or None for full width. Defaults to 40.
        style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
        complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
        finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
    (   ro   rp   rq   rr   N	bar_widthr|   r}   r~   r   r   rN   c                    s0   || _ || _|| _|| _|| _t j|d d S r   )r  r|   r}   r~   r   rG   rH   )rI   r  r|   r}   r~   r   r   rJ   rL   rM   rH     s   	zBarColumn.__init__r   r   c                 C   s^   t |jdurtd|jndtd|j| jdu rdntd| j|j | | j| j| j	| j
d	S )z&Gets a progress bar widget for a task.Nr   r+   )	rv   rF   widthpulseanimation_timer|   r}   r~   r   )r5   rv   maxrF   r  startedrz   r|   r}   r~   r   r   rL   rL   rM   r     s   
zBarColumn.render)r  ro   rp   rq   rr   N)rf   rg   rh   ri   r   r   r7   r8   rH   r5   r   rl   rL   rL   rJ   rM   r     s0    r   c                   @   "   e Zd ZdZdddefddZdS )TimeElapsedColumnzRenders time elapsed.r   r   rN   c                 C   sJ   |j r|jn|j}|du rtdddS ttdt|d}tt|ddS )zShow time elapsed.N-:--:--progress.elapsedr|   r   )seconds)r  finished_timeelapsedr:   r   r  r   r   )rI   r   r#  deltarL   rL   rM   r     s
   zTimeElapsedColumn.renderNrf   rg   rh   ri   r:   r   rL   rL   rL   rM   r        r  c                       s   e Zd ZdZ								dd	ed
ededededee	 dee
 deddf fddZedee defddZdddefddZ  ZS )r   a  Show task progress as a percentage.

    Args:
        text_format (str, optional): Format for percentage display. Defaults to "[progress.percentage]{task.percentage:>3.0f}%".
        text_format_no_percentage (str, optional): Format if percentage is unknown. Defaults to "".
        style (StyleType, optional): Style of output. Defaults to "none".
        justify (JustifyMethod, optional): Text justification. Defaults to "left".
        markup (bool, optional): Enable markup. Defaults to True.
        highlighter (Optional[Highlighter], optional): Highlighter to apply to output. Defaults to None.
        table_column (Optional[Column], optional): Table Column to use. Defaults to None.
        show_speed (bool, optional): Show speed if total is unknown. Defaults to False.
    -[progress.percentage]{task.percentage:>3.0f}%r   r  r	  TNFr
  text_format_no_percentager|   r  r  r  r   r   rN   c	           	         s(   || _ || _t j||||||d d S )N)r
  r|   r  r  r  r   )r(  r   rG   rH   )	rI   r
  r(  r|   r  r  r  r   r   rJ   rL   rM   rH     s   
zTaskProgressColumn.__init__r   c                 C   sN   |du r
t dddS tt|g dd\}}|| }t |d| dddS )	zRender the speed in iterations per second.

        Args:
            task (Task): A Task object.

        Returns:
            Text: Text object containing the task speed.
        Nr   zprogress.percentager   )r   u   ×10³u   ×10⁶u   ×10⁹u   ×10¹²  z.1fz it/s)r:   r,   pick_unit_and_suffixr   )clsr   unitsuffix
data_speedrL   rL   rM   render_speed  s   
zTaskProgressColumn.render_speedr   r   c                 C   s   |j d u r| jr| |jp|jS |j d u r| jn| j}|j|d}| jr0t	j
|| j| jd}n	t	|| j| jd}| jrB| j| |S r  )rv   r   r/  finished_speedr   r(  r
  r  r  r:   r  r|   r  r  r  )rI   r   r
  r  r  rL   rL   rM   r     s   zTaskProgressColumn.render)r'  r   r  r	  TNNF)rf   rg   rh   ri   r   r7   r0   r   r   r2   r8   rH   classmethodrj   r:   r/  r   rl   rL   rL   rJ   rM   r     s@    	
r   c                       sP   e Zd ZdZdZ			ddededee f fdd	Zd
dde	fddZ
  ZS )r   a  Renders estimated time remaining.

    Args:
        compact (bool, optional): Render MM:SS when time remaining is less than an hour. Defaults to False.
        elapsed_when_finished (bool, optional): Render time elapsed when the task is finished. Defaults to False.
          ?FNcompactr   r   c                    s   || _ || _t j|d d S r   )r3  r   rG   rH   )rI   r3  r   r   rJ   rL   rM   rH     s   zTimeRemainingColumn.__init__r   r   rN   c                 C   s   | j r|jr|j}d}n|j}d}|jdu rtd|dS |du r.t| jr)d|dS d|dS tt|d\}}t|d\}}| jrM|sM|d	d
|d	}n|dd
|d	d
|d	}t||dS )zShow time remaining.r  zprogress.remainingNr   r   z--:--r  <   02d:d)	r   r  r"  time_remainingrv   r:   r3  divmodr   )rI   r   	task_timer|   minutesr!  hours	formattedrL   rL   rM   r     s   

zTimeRemainingColumn.render)FFN)rf   rg   rh   ri   r   r   r   r8   rH   r:   r   rl   rL   rL   rJ   rM   r     s    
r   c                   @   r  )FileSizeColumnzRenders completed filesize.r   r   rN   c                 C   s   t t|j}t|ddS )Show data completed.zprogress.filesizer   )r,   decimalr   rF   r:   rI   r   	data_sizerL   rL   rM   r   9  s   zFileSizeColumn.renderNr%  rL   rL   rL   rM   r>  6  r&  r>  c                   @   r  )TotalFileSizeColumnzRenders total filesize.r   r   rN   c                 C   s*   |j durtt|j nd}t|ddS )r?  Nr   zprogress.filesize.totalr   )rv   r,   r@  r   r:   rA  rL   rL   rM   r   B  s   zTotalFileSizeColumn.renderNr%  rL   rL   rL   rM   rC  ?  r&  rC  c                       sB   e Zd ZdZddedee f fddZdd	d
efddZ	  Z
S )MofNCompleteColumnaH  Renders completed count/total, e.g. '  10/1000'.

    Best for bounded tasks with int quantities.

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

    Args:
        separator (str, optional): Text to separate completed and total values. Defaults to "/".
    /N	separatorr   c                    r   r   )rF  rG   rH   )rI   rF  r   rJ   rL   rM   rH   T  s   zMofNCompleteColumn.__init__r   r   rN   c                 C   sP   t |j}|jdurt |jnd}tt|}t|| d| j | ddS )zShow completed/total.N?r7  progress.downloadr   )r   rF   rv   r   r   r:   rF  )rI   r   rF   rv   total_widthrL   rL   rM   r   X  s   
zMofNCompleteColumn.render)rE  N)rf   rg   rh   ri   r   r   r8   rH   r:   r   rl   rL   rL   rJ   rM   rD  H  s    rD  c                       sH   e Zd ZdZ	ddedee ddf fddZd	d
defddZ	  Z
S )r   zRenders file size downloaded and total, e.g. '0.5/2.3 GB'.

    Args:
        binary_units (bool, optional): Use binary units, KiB, MiB etc. Defaults to False.
    FNbinary_unitsr   rN   c                    r   r   )rJ  rG   rH   )rI   rJ  r   rJ   rL   rM   rH   j  r   zDownloadColumn.__init__r   r   c                 C   s   t |j}|jdurt |jn|}| jr t|g dd\}}nt|g dd\}}|dkr1dnd}|| }|d| d	}|jdurVt |j}	|	| }
|
d| d	}nd
}| 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+   r   z,.frG  rE  r   rH  r   )r   rF   rv   rJ  r,   r*  r:   )rI   r   rF    unit_and_suffix_calculation_baser,  r-  	precisioncompleted_ratiocompleted_strrv   total_ratio	total_strdownload_statusdownload_textrL   rL   rM   r   p  s2   



zDownloadColumn.render)FN)rf   rg   rh   ri   r   r   r8   rH   r:   r   rl   rL   rL   rJ   rM   r   c  s    r   c                   @   r  )TransferSpeedColumnz&Renders human readable transfer speed.r   r   rN   c                 C   s@   |j p|j}|du rtdddS tt|}t| dddS )zShow data transfer speed.NrG  zprogress.data.speedr   z/s)r0  r   r:   r,   r@  r   )rI   r   r   r.  rL   rL   rM   r     s
   zTransferSpeedColumn.renderNr%  rL   rL   rL   rM   rd    r&  rd  c                   @   s$   e Zd ZU dZeed< 	 eed< dS )ProgressSamplez$Sample of progress for a given time.r   rF   N)rf   rg   rh   ri   rj   r   rL   rL   rL   rM   re    s   
 re  c                   @   s  e Zd ZU dZeed< 	 eed< 	 ee ed< 	 eed< 	 e	ed< 	 dZ
ee ed< 	 d	Zeed
< 	 eedZeeef ed< 	 eddddZee ed< 	 eddddZee ed< 	 dZee ed< 	 edd dddZee ed< ededZeed< 	 defddZedefddZedee fddZedee fdd Zedefd!d"Zedefd#d$Z edee fd%d&Z!edee fd'd(Z"d+d)d*Z#dS ),r   zInformation regarding a progress task.

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

    r   ru   rv   rF   	_get_timeNr"  Tvisible)default_factoryfieldsF)defaultinitrepr
start_time	stop_timer0  c                   C   s
   t ddS )Nr)  )maxlenr   rL   rL   rL   rM   <lambda>  s   
 zTask.<lambda>)rh  rk  rl  	_progress)rl  rh  _lockrN   c                 C   s   |   S )z(float: Get the current time, in seconds.)rf  r[   rL   rL   rM   rz     r   zTask.get_timec                 C   
   | j duS )z#bool: Check if the task as started.N)rm  r[   rL   rL   rM   r       
zTask.startedc                 C   s   | j du rdS | j | j S )zPOptional[float]: Get the number of steps remaining, if a non-None total was set.Nrv   rF   r[   rL   rL   rM   	remaining  s   
zTask.remainingc                 C   s2   | j du rdS | jdur| j| j  S |  | j  S )z]Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started.N)rm  rn  rz   r[   rL   rL   rM   r#    s
   

zTask.elapsedc                 C   rs  )zCheck if the task has finished.N)r"  r[   rL   rL   rM   r    rt  zTask.finishedc                 C   s.   | j sdS | j| j  d }tdtd|}|S )zOfloat: Get progress of task as a percentage. If a None total was set, returns 0              Y@)rv   rF   minr  )rI   rF   rL   rL   rM   
percentage  s
   zTask.percentagec                 C   s   | j du rdS | jD | j}|s	 W d   dS |d j|d j }|dkr0	 W d   dS t|}t| tdd |D }|| }|W  d   S 1 sQw   Y  dS )z=Optional[float]: Get the estimated speed in steps per second.Nr   r   c                 s       | ]}|j V  qd S rX   r   ).0samplerL   rL   rM   	<genexpr>      zTask.speed.<locals>.<genexpr>)rm  rr  rq  r   iterr   r   )rI   r@   
total_timeiter_progresstotal_completedr   rL   rL   rM   r      s"   
$z
Task.speedc                 C   s:   | j rdS | j}|sdS | j}|du rdS t|| }|S )zJOptional[float]: Get estimated time to completion, or ``None`` if no data.rw  N)r  r   rv  r   )rI   r   rv  estimaterL   rL   rM   r8    s   zTask.time_remainingc                 C   s   | j   d| _d| _dS )zReset progress.N)rq  clearr"  r0  r[   rL   rL   rM   _reset   s   

zTask._resetre   )$rf   rg   rh   ri   r<   r   r   r   rj   GetTimeCallabler"  rg  r   r   dictri  r   r   rm  rn  r0  rq  r   re  r   rr  rz   r   r  rv  r#  r  rz  r   r8  r  rL   rL   rL   rM   r     sZ   
 
r   c                   @   sz  e Zd ZdZddddddddddd
deeef d	ee d
e	de
de
de	de	de	dee de	de	ddfddZedeedf fddZedefddZedee fddZedee fddZede	fdd Zdmd!d"Zdmd#d$Zdefd%d&Zd'eee  d(ee d)ee ddfd*d+Z		,		-	.dnd/ee e! e"e! f d0ee
 d1e#d2ee d3ed4e
de e! fd5d6Z$	dodd7d8d9e%d0ee# d2ee d3ede%f
d:d;Z&e'j(	<			dpddd7d=d9eed>e)f d?e*d@ dAe#dBee dCee dDee d0ee# d2ee d3ede%fdEdFZ+e'j(	<			dpddd7d=d9eed>e)f d?ee*dG e*dH f dAe#dBee dCee dDee d0ee# d2ee d3ede,fdIdFZ+	G	<			dqddd7d=d9eed>e)f d?ee*d@ e*dH e*dG f dAe#dBee dCee dDee d0ee# d2ee d3edee%e,f fdJdFZ+d2eddfdKdLZ-d2eddfdMdNZ.dddddddOd2ed0ee
 d1ee
 dPee
 d3ee dQee	 dRe	dSe/ddfdTdUZ0ddd,dddVd2edWe	d0ee
 d1e#dQee	 d3ee dSe/ddfdXdYZ1drd2edPe
ddfd[d\Z2dmd]d^Z3de4fd_d`Z5de e4 fdadbZ6dce e de7fdddeZ8de4fdfdgZ9		h	,	dsd3edWe	d0ee
 d1e#dQe	dSe/defdidjZ:d2eddfdkdlZ;dS )trA   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.
    NTrn   g      >@F)
rx   rw   r{   speed_estimate_periodry   redirect_stdoutredirect_stderrrz   r   expandr   rx   rw   r{   r  ry   r  r  rz   r   r  rN   c       
      	   G   s   |dksJ dt  | _|p|  | _|| _|	| _|
| _i | _td| _	t
|p)t |||||| jd| _|p9| jj| _| jj| _| jj| _d S )Nr   zrefresh_per_second must be > 0)rx   rw   r{   ry   r  r  get_renderable)r   rr  get_default_columnsr   r  r   r  _tasksr<   _task_indexr4   r-   r  rR   rx   rz   printlog)rI   rx   rw   r{   r  ry   r  r  rz   r   r  r   rL   rL   rM   rH   7  s(   
	
zProgress.__init__.c                 C   s   t dt t t fS )a  Get the default columns used for a new Progress instance:
           - a text column for the description (TextColumn)
           - the bar itself (BarColumn)
           - a text column showing completion percentage (TextColumn)
           - an estimated-time-remaining column (TimeRemainingColumn)
        If the Progress instance is created without passing a columns argument,
        the default columns defined here will be used.

        You can also create a Progress instance using custom columns before
        and/or after the defaults, as in this example:

            progress = Progress(
                SpinnerColumn(),
                *Progress.get_default_columns(),
                "Elapsed:",
                TimeElapsedColumn(),
            )

        This code shows the creation of a Progress display, containing
        a spinner to the left, the default columns, and a labeled elapsed
        time column.
        r   )r   r   r   r   )r+  rL   rL   rM   r  [  s
   zProgress.get_default_columnsc                 C   r   rX   )rR   rx   r[   rL   rL   rM   rx   z  r   zProgress.consolec                 C   8   | j  t| j W  d   S 1 sw   Y  dS )zGet a list of Task instances.N)rr  listr  valuesr[   rL   rL   rM   tasks~     $zProgress.tasksc                 C   r  )zA list of task IDs.N)rr  r  r  keysr[   rL   rL   rM   task_ids  r  zProgress.task_idsc                 C   sZ   | j   | js	 W d   dS tdd | j D W  d   S 1 s&w   Y  dS )z'Check if all tasks have been completed.NTc                 s   r{  rX   )r  )r|  r   rL   rL   rM   r~    r  z$Progress.finished.<locals>.<genexpr>)rr  r  allr  r[   rL   rL   rM   r    s   $zProgress.finishedc                 C   s   | j s| jjdd dS dS )zStart the progress display.T)rO   N)r   rR   rZ   r[   rL   rL   rM   rZ     s   zProgress.startc                 C   s0   | j   | jjs| jjs| j  dS dS dS )zStop the progress display.N)rR   r   rx   is_interactive
is_jupyterr  r[   rL   rL   rM   r     s   
zProgress.stopc                 C   rW   rX   rY   r[   rL   rL   rM   r\     r]   zProgress.__enter__r^   r_   r`   c                 C   r   rX   )r   rc   rL   rL   rM   rd     r   zProgress.__exit__r   rm   rs   rt   rv   rF   rB   ru   rC   c                 c   s    |du rt t|pd}|du r| j|||d}n| j|||d | jjrNt| ||}|D ]}|V  | jd7  _q/W d   dS 1 sGw   Y  dS | j}	| j	}
|D ]}|V  |	|d |
  qVdS )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).
            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.
        Nru  r+   )
rj   r   add_taskrT   rR   rw   r?   rF   rP   rO   )rI   rt   rv   rF   rB   ru   rC   track_threadvaluerP   rO   rL   rL   rM   r     s(   "
zProgress.trackr   )rB   ru   r   c                C   s   d}|dur	|}n|dur&| j  | j| j}W d   n1 s!w   Y  |du r.td|du r:| j||d}n| j||d t|| |ddS )aj  Track progress file reading from a binary file.

        Args:
            file (BinaryIO): A file-like object opened in binary mode.
            total (int, optional): Total number of bytes to read. This must be provided unless a task with a total is also given.
            task_id (TaskID): Task to track. Default is new task.
            description (str, optional): Description of task, if new task is created.

        Returns:
            BinaryIO: A readable file-like object in binary mode.

        Raises:
            ValueError: When no total value can be extracted from the arguments or the task.
        Nz?unable to get the total number of bytes, please specify 'total'rv   Fr   )rr  r  rv   
ValueErrorr  rT   r   )rI   r   rv   rB   ru   total_bytesrL   rL   rM   r     s   zProgress.wrap_filer   )rv   rB   ru   r   r   r   r   r   r   r   c          
      C   r   rX   rL   
rI   r   r   r   r   r   r   rv   rB   ru   rL   rL   rM   r        zProgress.openr   r   c          
      C   r   rX   rL   r  rL   rL   rM   r     r  c                C   s   d t|dd}
|
dvrtd||dk}|
dkr)|dkr)tdt d	}n|
d
v r;|dkr5td|dkr;d	}|du rDt|j}|du rP| j|	|d}n| j	||d t
j|d|d}t|| |dd}|dv rut
j|||||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   zinvalid mode r+   r  zaline buffering (buffering=1) isn't supported in binary mode, the default buffer size will be usedr   )r   r   r   zcan't have unbuffered text I/ONr  r   )r   Tr  )r   r   )r   r   r   line_buffering)rb   sortedr  warningswarnRuntimeWarningr   st_sizer  rT   ior   r   TextIOWrapper)rI   r   r   r   r   r   r   rv   rB   ru   _moder  r   r   rL   rL   rM   r     s>   !
c                 C   sZ   | j   | j| }|jdu r|  |_W d   dS W d   dS 1 s&w   Y  dS )zStart a task.

        Starts a task (used when calculating elapsed time). You may need to call this manually,
        if you called ``add_task`` with ``start=False``.

        Args:
            task_id (TaskID): ID of task.
        N)rr  r  rm  rz   )rI   rB   r   rL   rL   rM   
start_taskk  s   	

"zProgress.start_taskc                 C   sT   | j  | j| }|  }|jdu r||_||_W d   dS 1 s#w   Y  dS )zStop a task.

        This will freeze the elapsed time on the task.

        Args:
            task_id (TaskID): ID of task.
        N)rr  r  rz   rm  rn  )rI   rB   r   r   rL   rL   rM   	stop_tasky  s   

"zProgress.stop_task)rv   rF   rP   ru   rg  rO   rP   rg  rO   ri  c                K   sH  | j  | j| }	|	j}
|dur||	jkr||	_|	  |dur'|	 j|7  _|dur.||	_|dur5||	_|dur<||	_|	j| |	j|
 }| 	 }|| j
 }|	j}|j}|rk|d j|k rk|  |rk|d j|k s_|dkrw|t|| |	jdur|	j|	jkr|	jdu r|	j|	_W d   n1 sw   Y  |r|   dS dS )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   )rr  r  rF   rv   r  ru   rg  ri  rT   rz   r  rq  popleftr   appendre  r"  r#  rO   )rI   rB   rv   rF   rP   ru   rg  rO   ri  r   completed_startupdate_completedr   old_sample_timerq  r  rL   rL   rM   rT     sD   




"zProgress.update)rZ   rv   rF   rg  ru   rZ   c          
      K   s   |   }| j8 | j| }	|	  |r|nd|	_|dur||	_||	_|dur)||	_|r.||	_|dur5||	_	d|	_
W d   n1 sBw   Y  |   dS )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)rz   rr  r  r  rm  rv   rF   rg  ri  ru   r"  rO   )
rI   rB   rZ   rv   rF   rg  ru   ri  r   r   rL   rL   rM   reset  s"   
zProgress.resetr+   c           
      C   s*  |   }| j | j| }|j}| j|7  _|j| }|| j }|j}|j}	|r<|d j|k r<|	  |r<|d j|k s0t|dkrK|	  t|dksB|	t
|| |jdurs|j|jkr{|jdu r|j|_|j|_W d   dS W d   dS W d   dS W d   dS 1 sw   Y  dS )zAdvance task by a number of steps.

        Args:
            task_id (TaskID): ID of task.
            advance (float): Number of steps to advance. Default is 1.
        r   r)  N)rz   rr  r  rF   r  rq  r  r   r   r  re  rv   r"  r#  r   r0  )
rI   rB   rP   r   r   r  r  r  rq  r  rL   rL   rM   rP     s8   





"zProgress.advancec                 C   s$   | j s| jjr| j  dS dS dS )z*Refresh (render) the progress information.N)r   rR   rS   rO   r[   rL   rL   rM   rO   
  s   zProgress.refreshc                 C   s   t |   }|S )z*Get a renderable for the progress display.)r/   get_renderables)rI   r   rL   rL   rM   r    s   zProgress.get_renderablec                 c   s    |  | j}|V  dS )z5Get a number of renderables for the progress display.N)make_tasks_tabler  )rI   tablerL   rL   rM   r    s   
zProgress.get_renderablesr  c                    sR   dd | j D }tj|d| jd}|D ]  jr&|j fdd| j D   q|S )zGet a table to render the Progress display.

        Args:
            tasks (Iterable[Task]): An iterable of Task instances, one per row of the table.

        Returns:
            Table: A table instance.
        c                 s   s0    | ]}t |trtd dn|  V  qdS )Tr  N)r  r   r8   r   copy)r|  _columnrL   rL   rM   r~  "  s    

z,Progress.make_tasks_table.<locals>.<genexpr>)r   r+   )paddingr  c                 3   s.    | ]}t |tr|j d n| V  qdS )r  N)r  r   r  )r|  columnr  rL   rM   r~  /  s    
)r   r9   gridr  rg  add_row)rI   r  table_columnsr  rL   r  rM   r    s   	

zProgress.make_tasks_tablec                 C   s2   | j  |  W  d   S 1 sw   Y  dS )z+Makes the Progress class itself renderable.N)rr  r  r[   rL   rL   rM   __rich__:  s   $zProgress.__rich__rx  c           	      K   s   | j 2 t| j|||||| j| j d}|| j| j< |r!| | j | j}tt| jd | _W d   n1 s8w   Y  |   |S )a  Add a new 'task' to the Progress display.

        Args:
            description (str): A description of the task.
            start (bool, optional): Start the task immediately (to calculate elapsed time). If set to False,
                you will need to call `start` manually. Defaults to True.
            total (float, optional): Number of total steps in the progress if 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`.
        )rg  ri  rf  rr  r+   N)	rr  r   r  rz   r  r  r<   r   rO   )	rI   ru   rZ   rv   rF   rg  ri  r   new_task_indexrL   rL   rM   r  ?  s&   
zProgress.add_taskc                 C   s4   | j  | j|= W d   dS 1 sw   Y  dS )z]Delete a task if it exists.

        Args:
            task_id (TaskID): A task ID.

        N)rr  r  )rI   rB   rL   rL   rM   remove_taskj  s   
"zProgress.remove_taskre   )Nr   Nrm   rs   rX   r   NNNr   r   NNN)r+   )Trx  r   T)<rf   rg   rh   ri   r%   r   r   r   r.   r   rj   r  rH   r1  r"   r  r   rx   r   r   r  r<   r  r  rZ   r   r*   r\   r#   rk   r   rd   r   r=   r    r   r   r   r   typingoverloadr   r(   r   r!   r  r  r   rT   r  rP   rO   r1   r  r  r9   r  r  r  r  rL   rL   rL   rM   rA   '  s   
	

$




.
*		
		
		


M	

A	

'
!
+rA   __main__)Panel)Rule)Syntax)r9   a~  def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
    """Iterate and generate a tuple with a flag for last value."""
    iter_values = iter(values)
    try:
        previous_value = next(iter_values)
    except StopIteration:
        return
    for value in iter_values:
        yield False, previous_value
        previous_value = value
    yield True, previous_valuepython)line_numbersfoobarbaz123z:Text may be printed while the progress bars are rendering.z(In fact, [i]any[/i] renderable will workzSuch as [magenta]tables[/]...zPretty printed structures...examplezPretty printed)typer  z	Syntax...zGive it a try!)cycle)record)rx   ry   z[red]Downloadingr)  r  z[green]Processingz[yellow]Thinkingr2  r   g333333?g{Gz?d   )rm   Nr   TNFNrn   ro   rp   rq   rr   rs   FTr  r  )r  sysr  r  abcr   r   collectionsr   dataclassesr   r   datetimer   r	   r
   mathr   r   operatorr   osr   r   	threadingr   r   r   typesr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   version_infor(   typing_extensionsr*   r   r,   r-   rx   r.   r/   r0   r1   r  r2   jupyterr3   rR   r4   progress_barr5   r  r6   r|   r7   r  r8   r9   r  r:   r;   r   r<   r=   rj   r  r>   r?   r   r   r   r   r   r   r  r   r   r   r   r   r   r   r  r   r   r>  rC  rD  r   rd  re  r   rA   rf   randomtimepanelr  ruler  syntaxr  r  progress_renderables	itertoolsr  examplesr  r@   r  task1task2task3r  rT   sleeprandintr  r   rL   rL   rL   rM   <module>   s   P


*	

Lg	

A	
	
	

V*2*H0		1	}    
R


$