o
    h                     @  s  d dl m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/m0Z0m1Z1 erd 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ZOe0dZPe"g eQf ZRe0de-e!ZSG dd deZT	 		 	!		"		#	$	%	&	'	(	"	!dddCdDZUG dEdF dFee!ZVG dGdH dHe#eS e&eS ZWdId!dd"dd#d$d%d&d'd"dJddNdOZXejY	P			dddId!dd"dd#d$d%d&d'd"dQdd\d]ZZejY	P			dddId!dd"dd#d$d%d&d'd"dQdd_d]ZZ	`	P			dddId!dd"dd#d$d%d&d'd"dQddcd]ZZG ddde deeZ[G dfdg dge[Z\G dhdi die[Z]G djdk dke[Z^G dldm dme[Z_G dndo doe[Z`G dpdq dqe^ZaG drds dse[ZbG dtdu due[ZcG dvdw dwe[ZdG dxdy dye[ZeG dzd{ d{e[ZfG d|d} d}e[ZgG d~d de*ZheG dd dZiG dd de?Zjekdkrd dllZld dlmZmddlnmoZo ddlpmqZq ddlrmsZs ddlHmJZJ esddd!dZreJdddZHeHtddd deoddeHdddddereqdg	Zud dlvmwZw eweuZxe8d!dZ7eje] gejy e` R e7d"dQZzezj{dddZ|ezj{dddZ}ezj{dddZ~ezjsezje|dd ezje}dd emd eld ddk rezeex ezjrW d   dS W d   dS 1 sw   Y  dS dS )    )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                      s@   e Zd ZdZd fdd	ZdddZdddZdddZ  ZS )_TrackThreadz)A thread to periodically update progress.progress
'Progress'task_id'TaskID'update_periodfloatc                   s2   || _ || _|| _t | _d| _t jdd d S )Nr   T)daemon)r>   r@   rB   r   done	completedsuper__init__)selfr>   r@   rB   	__class__ L/var/www/html/venv/lib/python3.10/site-packages/pip/_vendor/rich/progress.pyrH   C   s   z_TrackThread.__init__returnNonec                 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)
r@   r>   advancerB   rE   waitlive
is_startedrF   update)rI   r@   rQ   rB   last_completedrR   rF   rL   rL   rM   runL   s   z_TrackThread.run'_TrackThread'c                 C     |    | S NstartrI   rL   rL   rM   	__enter__Z      z_TrackThread.__enter__exc_typeOptional[Type[BaseException]]exc_valOptional[BaseException]exc_tbOptional[TracebackType]c                 C  s   | j   |   d S rZ   )rE   setjoinrI   r`   rb   rd   rL   rL   rM   __exit__^   s   
z_TrackThread.__exit__)r>   r?   r@   rA   rB   rC   rN   rO   )rN   rX   r`   ra   rb   rc   rd   re   rN   rO   )	__name__
__module____qualname____doc__rH   rW   r^   ri   __classcell__rL   rL   rJ   rM   r=   @   s    
	
r=   
Working...TF
   bar.backbar.completebar.finished	bar.pulse皙?sequenceIterable[ProgressType]descriptionstrtotalOptional[float]rF   intauto_refreshboolconsoleOptional[Console]	transientget_timeOptional[Callable[[], float]]refresh_per_secondrC   styler5   complete_stylefinished_stylepulse_stylerB   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.

    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_finishedrr   r   r   r   r   r   r   )r|   rF   rz   rB   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnProgresstrack)rx   rz   r|   rF   r   r   r   r   r   r   r   r   r   rB   r   r   columnsr>   rL   rL   rM   r   h   s@   ,
"r   c                   @  s  e Zd ZdZ	dQdRddZdSddZdTddZdUddZdVddZe	dWdd Z
dXd"d#ZdWd$d%Ze	dYd'd(Ze	dYd)d*ZdWd+d,ZdWd-d.ZdWd/d0ZdZd[d3d4Zd\d7d8ZdZd[d9d:ZdZd]d=d>Zd^d?d@Zd_d`dDdEZdXdFdGZdadJdKZdbdNdOZdPS )c_Readerz9A reader that tracks progress while it's being read from.Thandler   r>   r?   taskr:   close_handler   rN   rO   c                 C  s"   || _ || _|| _|| _d| _d S NF)r   r>   r   r   _closed)rI   r   r>   r   r   rL   rL   rM   rH      s
   
z_Reader.__init__	'_Reader'c                 C  s   | j   | S rZ   )r   r^   r]   rL   rL   rM   r^      s   
z_Reader.__enter__r`   ra   rb   rc   rd   re   c                 C     |    d S rZ   )closerh   rL   rL   rM   ri         z_Reader.__exit__c                 C  s   | S rZ   rL   r]   rL   rL   rM   __iter__      z_Reader.__iter__bytesc                 C  s$   t | j}| jj| jt|d |S NrQ   )nextr   r>   rQ   r   len)rI   linerL   rL   rM   __next__   s   
z_Reader.__next__c                 C     | j S rZ   )r   r]   rL   rL   rM   closed   s   z_Reader.closedr~   c                 C  
   | j  S rZ   )r   filenor]   rL   rL   rM   r         
z_Reader.filenoc                 C  r   rZ   )r   isattyr]   rL   rL   rM   r      r   z_Reader.isattyr{   c                 C     | j jS rZ   )r   moder]   rL   rL   rM   r         z_Reader.modec                 C  r   rZ   )r   namer]   rL   rL   rM   r      r   z_Reader.namec                 C  r   rZ   )r   readabler]   rL   rL   rM   r      r   z_Reader.readablec                 C  r   rZ   )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>   rQ   r   r   )rI   r   blockrL   rL   rM   r         z_Reader.readb"Union[bytearray, memoryview, mmap]c                 C  s"   | j |}| jj| j|d |S r   )r   readintor>   rQ   r   )rI   r   nrL   rL   rM   r      s   z_Reader.readintoc                 C  r   r   )r   readliner>   rQ   r   r   )rI   r   r   rL   rL   rM   r      r   z_Reader.readlinehintList[bytes]c                 C  s,   | j |}| jj| jttt|d |S r   )r   	readlinesr>   rQ   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>   rU   r   )rI   r   r   posrL   rL   rM   r     s   z_Reader.seekc                 C  r   rZ   )r   tellr]   rL   rL   rM   r     r   z_Reader.tellsr   c                 C     t d)Nwriter   )rI   r   rL   rL   rM   r        z_Reader.writer   Iterable[Any]c                 C  r   )N
writelinesr   )rI   r   rL   rL   rM   r     r   z_Reader.writelinesN)T)
r   r   r>   r?   r   r:   r   r   rN   rO   )rN   r   rk   )rN   r   )rN   r   rN   r   )rN   r~   )rN   r{   )r   )r   r~   rN   r   )r   r   )r   r~   rN   r   rj   )r   )r   r~   r   r~   rN   r~   )r   r   rN   r~   )r   r   rN   rO   )rl   rm   rn   ro   rH   r^   ri   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rL   rL   rL   rM   r      s8    












r   c                   @  s.   e Zd ZdZddd	Zdd
dZdddZdS )_ReadContextzEA utility class to handle a context for both a reader and a progress.r>   r?   readerr<   rN   rO   c                 C  s   || _ || _d S rZ   )r>   r   )rI   r>   r   rL   rL   rM   rH      s   
z_ReadContext.__init__c                 C  s   | j   | j S rZ   )r>   r\   r   r^   r]   rL   rL   rM   r^   $  s   

z_ReadContext.__enter__r`   ra   rb   rc   rd   re   c                 C  s   | j   | j||| d S rZ   )r>   stopr   ri   rh   rL   rL   rM   ri   (  s   
z_ReadContext.__exit__N)r>   r?   r   r<   rN   rO   )rN   r<   rk   )rl   rm   rn   ro   rH   r^   ri   rL   rL   rL   rM   r     s
    

r   
Reading...)rz   r   r   r   r   r   r   r   r   r   r   filer   ContextManager[BinaryIO]c             	   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   rr   r   )r|   rz   )r   r   r   DownloadColumnr   r   	wrap_filer   )r   r|   rz   r   r   r   r   r   r   r   r   r   r   r   r>   r   rL   rL   rM   r   2  s0   %

r   r   )r|   rz   r   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                C     d S rZ   rL   r   r   r   r   r   r   r|   rz   r   r   r   r   r   r   r   r   r   r   rL   rL   rM   opens     r   Literal['rb']c                C  r   rZ   rL   r   rL   rL   rM   r     r   r1Union[Literal['rb'], Literal['rt'], Literal['r']]7Union[ContextManager[BinaryIO], ContextManager[TextIO]]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   rr   r   )r   r   r   r   r   r|   rz   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r|   rz   r   r   r   r   r   r   r   r   r   r   r   r>   r   rL   rL   rM   r     sB   1


c                   @  sL   e Zd ZU dZdZded< ddd	d
ZdddZdddZe	dddZ
dS )ProgressColumnz3Base class for a widget to use in progress display.Nr}   max_refreshtable_columnOptional[Column]rN   rO   c                 C  s   || _ i | _d | _d S rZ   )_table_column_renderable_cache_update_time)rI   r   rL   rL   rM   rH      s   
zProgressColumn.__init__r6   c                 C  s   | j pt S )z.Get a table column, used to build tasks table.)r   r6   r]   rL   rL   rM   get_table_column  s   zProgressColumn.get_table_columnr   'Task'r/   c                 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)r   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.renderrZ   )r   r   rN   rO   )rN   r6   r   r   rN   r/   )rl   rm   rn   ro   r   __annotations__rH   r   r  r   r   rL   rL   rL   rM   r     s   
 

r   c                      s6   e Zd ZdZ	dddd fd	d
Zd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/   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   rZ   )r  r  rL   rL   rM   r   2  s   zRenderableColumn.render)r  )r  r/   r   r   r  rl   rm   rn   ro   rH   r   rp   rL   rL   rJ   rM   r  %  s    r  c                      sH   e Zd ZdZ					dd fddZ		dd ddZd!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{   r   Optional[StyleType]speedrC   finished_textr9   r   r   c                   s<   t |||d| _t|trt|n|| _t j|d d S )Nr   r  r  )	r4   spinner
isinstancer{   r8   from_markupr  rG   rH   )rI   r  r   r  r  r   rJ   rL   rM   rH   @  s   zSpinnerColumn.__init__spinner_stylerN   rO   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)r4   r  )rI   r  r  r  rL   rL   rM   set_spinnerP  s   zSpinnerColumn.set_spinnerr   r   r/   c                 C  s$   |j r| j}|S | j| }|S rZ   )finishedr  r  r   r   )rI   r   textrL   rL   rM   r   _  s   zSpinnerColumn.render)r  r  r  r  N)
r  r{   r   r  r  rC   r  r9   r   r   )r  r  )r  r{   r  r  r  rC   rN   rO   r  )rl   rm   rn   ro   rH   r  r   rp   rL   rL   rJ   rM   r  6  s    r  c                      s8   e Zd ZdZ					dd fddZdddZ  ZS )r   zA column containing text.noneleftTNtext_formatr{   r   r5   justifyr.   markupr   highlighterOptional[Highlighter]r   r   rN   rO   c                   s:   || _ || _|| _|| _|| _t j|ptddd d S )NTno_wrapr  )r   r!  r   r"  r#  rG   rH   r6   )rI   r   r   r!  r"  r#  r   rJ   rL   rM   rH   k  s   	zTextColumn.__init__r   r   r8   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"  r8   r  r   r!  r#  	highlight)rI   r   _textr  rL   rL   rM   r   {  s   zTextColumn.render)r  r  TNN)r   r{   r   r5   r!  r.   r"  r   r#  r$  r   r   rN   rO   r   r   rN   r8   r  rL   rL   rJ   rM   r   h  s    r   c                      s:   e Zd ZdZ						dd fddZd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".
    (   rs   rt   ru   rv   N	bar_widthr   r   r5   r   r   r   r   r   rN   rO   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   r3   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)   )	r|   rF   widthpulseanimation_timer   r   r   r   )r3   r|   maxrF   r.  startedr   r   r   r   r   r  rL   rL   rM   r     s   
zBarColumn.render)r-  rs   rt   ru   rv   N)r.  r   r   r5   r   r5   r   r5   r   r5   r   r   rN   rO   )r   r   rN   r3   r  rL   rL   rJ   rM   r     s    r   c                   @     e Zd ZdZd	ddZdS )
TimeElapsedColumnzRenders time elapsed.r   r   rN   r8   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elapsedr8   r	   r2  r~   r{   )rI   r   r;  deltarL   rL   rM   r     s
   zTimeElapsedColumn.renderNr,  rl   rm   rn   ro   r   rL   rL   rL   rM   r5        r5  c                      sL   e Zd ZdZ								d$d% fddZed&ddZd'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   r{   text_format_no_percentager   r5   r!  r.   r"  r   r#  r$  r   r   r   rN   rO   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  r}   r8   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.percentager8  )r  u   ×10³u   ×10⁶u   ×10⁹u   ×10¹²  z.1fz it/s)r8   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'  )r|   r   rG  finished_speedr  r@  r   r)  r"  r8   r  r   r!  r#  r*  )rI   r   r   r+  r  rL   rL   rM   r     s   zTaskProgressColumn.render)r?  r  r  r  TNNF)r   r{   r@  r{   r   r5   r!  r.   r"  r   r#  r$  r   r   r   r   rN   rO   )r  r}   rN   r8   r,  )	rl   rm   rn   ro   rH   classmethodrG  r   rp   rL   rL   rJ   rM   r     s    r   c                      s8   e Zd ZdZdZ			dd fd
dZd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   r   r   c                   s   || _ || _t j|d d S r
  )rK  r   rG   rH   )rI   rK  r   r   rJ   rL   rM   rH     s   zTimeRemainingColumn.__init__r   r   rN   r8   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.r7  zprogress.remainingNr  r8  z--:--r6  <   02d:d)	r   r  r:  time_remainingr|   r8   rK  divmodr~   )rI   r   	task_timer   minutesr9  hours	formattedrL   rL   rM   r     s   

zTimeRemainingColumn.render)FFN)rK  r   r   r   r   r   r,  )rl   rm   rn   ro   r   rH   r   rp   rL   rL   rJ   rM   r     s    
r   c                   @  r4  )
FileSizeColumnzRenders completed filesize.r   r   rN   r8   c                 C  s   t t|j}t|ddS )Show data completed.zprogress.filesizer8  )r*   decimalr~   rF   r8   rI   r   	data_sizerL   rL   rM   r   7  s   zFileSizeColumn.renderNr,  r=  rL   rL   rL   rM   rV  4  r>  rV  c                   @  r4  )
TotalFileSizeColumnzRenders total filesize.r   r   rN   r8   c                 C  s*   |j durtt|j nd}t|ddS )rW  Nr  zprogress.filesize.totalr8  )r|   r*   rX  r~   r8   rY  rL   rL   rM   r   @  s   zTotalFileSizeColumn.renderNr,  r=  rL   rL   rL   rM   r[  =  r>  r[  c                      s.   e Zd ZdZdd fdd	Zd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{   r   r   c                   r	  r
  )r^  rG   rH   )rI   r^  r   rJ   rL   rM   rH   R  s   zMofNCompleteColumn.__init__r   r   rN   r8   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?rO  progress.downloadr8  )r~   rF   r|   r   r{   r8   r^  )rI   r   rF   r|   total_widthrL   rL   rM   r   V  s   
zMofNCompleteColumn.render)r]  N)r^  r{   r   r   r,  r  rL   rL   rJ   rM   r\  F  s    r\  c                      s0   e Zd ZdZ	dd fd
dZd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   r   r   rN   rO   c                   r	  r
  )rb  rG   rH   )rI   rb  r   rJ   rL   rM   rH   h  r  zDownloadColumn.__init__r   r   r8   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YBrA  r)   r   z,.fr_  r]  r  r`  r8  )r~   rF   r|   rb  r*   rB  r8   )rI   r   rF    unit_and_suffix_calculation_baserD  rE  	precisioncompleted_ratiocompleted_strr|   total_ratio	total_strdownload_statusdownload_textrL   rL   rM   r   n  s2   



zDownloadColumn.render)FN)rb  r   r   r   rN   rO   r,  r  rL   rL   rJ   rM   r   a  s
    r   c                   @  r4  )
TransferSpeedColumnz&Renders human readable transfer speed.r   r   rN   r8   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.Nr_  zprogress.data.speedr8  z/s)rH  r  r8   r*   rX  r~   )rI   r   r  rF  rL   rL   rM   r     s
   zTransferSpeedColumn.renderNr,  r=  rL   rL   rL   rM   r|    r>  r|  c                   @  s$   e Zd ZU dZded< 	 ded< dS )ProgressSamplez$Sample of progress for a given time.rC   r   rF   N)rl   rm   rn   ro   r  rL   rL   rL   rM   r}    s   
 r}  c                   @  sX  e Zd ZU dZded< 	 ded< 	 ded< 	 ded	< 	 d
ed< 	 dZded< 	 dZded< 	 eedZ	ded< 	 eddddZ
ded< 	 eddddZded< 	 dZded< 	 edd dddZded< ededZded < 	 d5d"d#Zed6d$d%Zed7d&d'Zed7d(d)Zed6d*d+Zed5d,d-Zed7d.d/Zed7d0d1Zd8d3d4ZdS )9TaskzInformation regarding a progress task.

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

    r:   r   r{   rz   r}   r|   rC   rF   GetTimeCallable	_get_timeNr:  Tr   visible)default_factoryzDict[str, Any]fieldsF)defaultinitrepr
start_time	stop_timerH  c                   C  s
   t ddS )NrA  )maxlenr   rL   rL   rL   rM   <lambda>  s   
 zTask.<lambda>)r  r  r  zDeque[ProgressSample]	_progress)r  r  r   _lockrN   c                 C  s   |   S )z(float: Get the current time, in seconds.)r  r]   rL   rL   rM   r     r   zTask.get_timec                 C  
   | j duS )z#bool: Check if the task as started.N)r  r]   rL   rL   rM   r3       
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r|   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)r  r  r   r]   rL   rL   rM   r;    s
   

zTask.elapsedc                 C  r  )zCheck if the task has finished.N)r:  r]   rL   rL   rM   r    r  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@)r|   rF   minr2  )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 rZ   r   ).0samplerL   rL   rM   	<genexpr>      zTask.speed.<locals>.<genexpr>)r  r  r  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.r  N)r  r  r  r   )rI   r  r  estimaterL   rL   rM   rP    s   zTask.time_remainingrO   c                 C  s   | j   d| _d| _dS )zReset progress.N)r  clearr:  rH  r]   rL   rL   rM   _reset  s   

zTask._reset)rN   rC   r   )rN   r}   rj   )rl   rm   rn   ro   r  r:  r  r   dictr  r  r  rH  r  r   r  r   r   r3  r  r;  r  r  r  rP  r  rL   rL   rL   rM   r~    sZ   
 

r~  c                   @  s  e Zd ZdZddddddddddd
dddZedddZedd d!Zedd#d$Z	edd&d'Z
edd(d)Zdd*d+Zdd,d-Zdd/d0Zdd7d8Z		9		:	;dddGdHZ	dddIdJddNdOZej	P			ddddIdQddZd[Zej	P			ddddIdQdd^d[Z	_	P			ddddIdQddbd[ZddddeZddfdgZdddddddhddodpZddd9dddqddsdtZdddvdwZddxdyZdd{d|Zdd~dZdddZdddZ			9	ddddZdddZ dS )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.
    NTrr   g      >@F)
r   r   r   speed_estimate_periodr   redirect_stdoutredirect_stderrr   r   expandr   Union[str, ProgressColumn]r   r   r   r   r   rC   r  r   r  r  r   Optional[GetTimeCallable]r   r  rN   rO   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)r   r   r   r   r  r  get_renderable)r   r  get_default_columnsr   r  r   r  _tasksr:   _task_indexr2   r+   r  rS   r   r   printlog)rI   r   r   r   r  r   r  r  r   r   r  r   rL   rL   rM   rH   5  s(   
	
zProgress.__init__Tuple[ProgressColumn, ...]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   )rC  rL   rL   rM   r  Y  s
   zProgress.get_default_columnsr,   c                 C  r   rZ   )rS   r   r]   rL   rL   rM   r   x  r   zProgress.console
List[Task]c                 C  8   | j  t| j W  d   S 1 sw   Y  dS )zGet a list of Task instances.N)r  listr  valuesr]   rL   rL   rM   tasks|     $zProgress.tasksList[TaskID]c                 C  r  )zA list of task IDs.N)r  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  rZ   )r  )r  r   rL   rL   rM   r    r  z$Progress.finished.<locals>.<genexpr>)r  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)rP   N)r   rS   r\   r]   rL   rL   rM   r\     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)rS   r   r   is_interactive
is_jupyterr  r]   rL   rL   rM   r     s   
zProgress.stopr(   c                 C  rY   rZ   r[   r]   rL   rL   rM   r^     r_   zProgress.__enter__r`   ra   rb   rc   rd   re   c                 C  r   rZ   )r   rh   rL   rL   rM   ri     r   zProgress.__exit__r   rq   rw   rx   ry   r|   r}   rF   r~   r@   Optional[TaskID]rz   r{   rB   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 )aC  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 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)   )
rC   r   add_taskrU   rS   r   r=   rF   rQ   rP   )rI   rx   r|   rF   r@   rz   rB   track_threadvaluerQ   rP   rL   rL   rM   r     s(   "
zProgress.trackr   )r@   rz   r   r   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'r|   Fr   )r  r  r|   
ValueErrorr  rU   r   )rI   r   r|   r@   rz   total_bytesrL   rL   rM   r     s   zProgress.wrap_filer   )r|   r@   rz   r   r   r   r   r   r   r   r   c          
      C  r   rZ   rL   
rI   r   r   r   r   r   r   r|   r@   rz   rL   rL   rM   r        zProgress.open"Union[Literal['r'], Literal['rt']]r#   c          
      C  r   rZ   rL   r  rL   rL   rM   r     r  r   r   Union[BinaryIO, TextIO]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)brrtr   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  rb)r   Tr  )r   r  )r   r   r   line_buffering)rg   sortedr  warningswarnRuntimeWarningr   st_sizer  rU   ior   r   TextIOWrapper)rI   r   r   r   r   r   r   r|   r@   rz   _moder  r   r   rL   rL   rM   r     s>   !
r:   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)r  r  r  r   )rI   r@   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)r  r  r   r  r  )rI   r@   r   r   rL   rL   rM   	stop_tasky  s   

"zProgress.stop_task)r|   rF   rQ   rz   r  rP   rQ   r  Optional[bool]rP   r  r   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   )r  r  rF   r|   r  rz   r  r  rU   r   r  r  popleftr   appendr}  r:  r;  rP   )rI   r@   r|   rF   rQ   rz   r  rP   r  r   completed_startupdate_completedr   old_sample_timer  r  rL   rL   rM   rU     sD   




"zProgress.update)r\   r|   rF   r  rz   r\   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)r   r  r  r  r  r|   rF   r  r  rz   r:  rP   )
rI   r@   r\   r|   rF   r  rz   r  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   rA  N)r   r  r  rF   r  r  r  r   r   r  r}  r|   r:  r;  r  rH  )
rI   r@   rQ   r   r   r  r  r  r  r  rL   rL   rM   rQ     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   rS   rT   rP   r]   rL   rL   rM   rP   
  s   zProgress.refreshr/   c                 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_renderableIterable[RenderableType]c                 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  Iterable[Task]r7   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{   r6   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   r7   gridr  r  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)r  r  r]   rL   rL   rM   __rich__:  s   $zProgress.__rich__r  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`.
        )r  r  r  r  r)   N)	r  r~  r  r   r  r  r:   r~   rP   )	rI   rz   r\   r|   rF   r  r  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)r  r  )rI   r@   rL   rL   rM   remove_taskj  s   
"zProgress.remove_task)r   r  r   r   r   r   r   rC   r  rC   r   r   r  r   r  r   r   r  r   r   r  r   rN   rO   )rN   r  )rN   r,   )rN   r  )rN   r  r   rj   )rN   r(   rk   )Nr   Nrq   rw   )rx   ry   r|   r}   rF   r~   r@   r  rz   r{   rB   rC   rN   ry   rZ   )
r   r   r|   r   r@   r  rz   r{   rN   r   r   NNN)r   r   r   r   r   r~   r   r   r   r   r   r   r|   r   r@   r  rz   r{   rN   r   )r   r   r   r  r   r~   r   r   r   r   r   r   r|   r   r@   r  rz   r{   rN   r#   r   r   NNN)r   r   r   r   r   r~   r   r   r   r   r   r   r|   r   r@   r  rz   r{   rN   r  )r@   r:   rN   rO   )r@   r:   r|   r}   rF   r}   rQ   r}   rz   r   r  r  rP   r   r  r   rN   rO   )r@   r:   r\   r   r|   r}   rF   r~   r  r  rz   r   r  r   rN   rO   )r)   )r@   r:   rQ   rC   rN   rO   )rN   r/   )rN   r  )r  r  rN   r7   )Tr  r   T)rz   r{   r\   r   r|   r}   rF   r~   r  r   r  r   rN   r:   )!rl   rm   rn   ro   rH   rI  r  r   r   r  r  r  r\   r   r^   ri   r   r   typingoverloadr   r  r  rU   r  rQ   rP   r  r  r  r  r  r  rL   rL   rL   rM   r   %  s    $



0*			
M
A'




!+r   __main__)Panel)Rule)Syntax)r7   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)r   r   z[red]DownloadingrA  r  z[green]Processingz[yellow]ThinkingrJ  r   g333333?g{Gz?d   )rq   Nr   TNFNrr   rs   rt   ru   rv   rw   FT)"rx   ry   rz   r{   r|   r}   rF   r~   r   r   r   r   r   r   r   r   r   rC   r   r5   r   r5   r   r5   r   r5   rB   rC   r   r   r   r   rN   ry   )r   r   r|   r~   rz   r{   r   r   r   r   r   r   r   r   r   rC   r   r5   r   r5   r   r5   r   r5   r   r   rN   r   r  )&r   r   r   r   r   r~   r   r   r   r   r   r   r|   r   rz   r{   r   r   r   r   r   r   r   r   r   rC   r   r5   r   r5   r   r5   r   r5   r   r   rN   r   )&r   r   r   r   r   r~   r   r   r   r   r   r   r|   r   rz   r{   r   r   r   r   r   r   r   r   r   rC   r   r5   r   r5   r   r5   r   r5   r   r   rN   r   r  )&r   r   r   r   r   r~   r   r   r   r   r   r   r|   r   rz   r{   r   r   r   r   r   r   r   r   r   rC   r   r5   r   r5   r   r5   r   r5   r   r   rN   r   )
__future__r   r  r  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&   r'   typing_extensionsr(   r  r*   r+   r   r,   r-   r.   r/   r#  r0   jupyterr1   rS   r2   progress_barr3   r  r4   r   r5   r  r6   r7   r  r8   r9   r~   r:   r;   rC   r  r<   r=   r   r   r   r   r  r   r   r  r  r   r   r5  r   r   rV  r[  r\  r   r|  r}  r~  r   rl   randomtimepanelr  ruler  syntaxr  r  progress_renderables	itertoolsr  examplesr  r>   r  task1task2task3r  rU   sleeprandintr  r   rL   rL   rL   rM   <module>   s   T
*NgAV*2*H0		1	}    
T


$