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__ _/home/www/facesmatcher.com/frenv_anti/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   Z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 rY   )rE   setjoinrI   r_   ra   rc   rL   rL   rM   __exit__^   s   
z_TrackThread.__exit__)r>   r?   r@   rA   rB   rC   rN   rO   )rN   rW   r_   r`   ra   rb   rc   rd   rN   rO   )	__name__
__module____qualname____doc__rH   rV   r]   rh   __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_finishedrq   r~   r   r   r   r   r   )r{   rF   ry   rB   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnProgresstrack)rw   ry   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 rY   )r   r]   r\   rL   rL   rM   r]      s   
z_Reader.__enter__r_   r`   ra   rb   rc   rd   c                 C     |    d S rY   )closerg   rL   rL   rM   rh         z_Reader.__exit__c                 C  s   | S rY   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 rY   )r   r\   rL   rL   rM   closed   s   z_Reader.closedr}   c                 C  
   | j  S rY   )r   filenor\   rL   rL   rM   r         
z_Reader.filenoc                 C  r   rY   )r   isattyr\   rL   rL   rM   r      r   z_Reader.isattyrz   c                 C     | j jS rY   )r   moder\   rL   rL   rM   r         z_Reader.modec                 C  r   rY   )r   namer\   rL   rL   rM   r      r   z_Reader.namec                 C  r   rY   )r   readabler\   rL   rL   rM   r      r   z_Reader.readablec                 C  r   rY   )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   rY   )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   rj   )rN   r   )rN   r   rN   r   )rN   r}   )rN   rz   )r   )r   r}   rN   r   )r   r   )r   r}   rN   r   ri   )r   )r   r}   r   r}   rN   r}   )r   r   rN   r}   )r   r   rN   rO   )rk   rl   rm   rn   rH   r]   rh   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 rY   )r>   r   )rI   r>   r   rL   rL   rM   rH      s   
z_ReadContext.__init__c                 C  s   | j   | j S rY   )r>   r[   r   r]   r\   rL   rL   rM   r]   $  s   

z_ReadContext.__enter__r_   r`   ra   rb   rc   rd   c                 C  s   | j   | j||| d S rY   )r>   stopr   rh   rg   rL   rL   rM   rh   (  s   
z_ReadContext.__exit__N)r>   r?   r   r<   rN   rO   )rN   r<   rj   )rk   rl   rm   rn   rH   r]   rh   rL   rL   rL   rM   r     s
    

r   
Reading...)ry   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   rq   r   )r{   ry   )r   r   r   DownloadColumnr   r   	wrap_filer   )r   r{   ry   r~   r   r   r   r   r   r   r   r   r   r   r>   r   rL   rL   rM   r   2  s0   %

r   r   )r{   ry   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 rY   rL   r   r   r   r   r   r   r{   ry   r~   r   r   r   r   r   r   r   r   r   rL   rL   rM   opens     r   Literal['rb']c                C  r   rY   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   rq   r   )r   r   r   r   r   r{   ry   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r{   ry   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 rY   )_table_column_renderable_cacheZ_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.renderrY   )r   r   rN   rO   )rN   r6   r   r   rN   r/   )rk   rl   rm   rn   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   rY   )r   r  rL   rL   rM   r   2  s   zRenderableColumn.render)r  )r   r/   r   r   r  rk   rl   rm   rn   rH   r   ro   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_namerz   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
isinstancerz   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 rY   )finishedr  r  r   r   )rI   r   textrL   rL   rM   r   _  s   zSpinnerColumn.render)r  r  r  r  N)
r  rz   r   r  r  rC   r  r9   r   r   )r  r  )r  rz   r  r  r  rC   rN   rO   r  )rk   rl   rm   rn   rH   r  r   ro   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_formatrz   r   r5   justifyr.   markupr   highlighterOptional[Highlighter]r   r   rN   rO   c                   s:   || _ || _|| _|| _|| _t j|ptddd d S )NTZ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  rz   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".
    (   rr   rs   rt   ru   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   widthZpulseZanimation_timer   r   r   r   )r3   r{   maxrF   r+  startedr   r   r   r   r   r  rL   rL   rM   r     s   
zBarColumn.render)r*  rr   rs   rt   ru   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	   r-  r}   rz   )rI   r   r6  deltarL   rL   rM   r     s
   zTimeElapsedColumn.renderNr)  rk   rl   rm   rn   r   rL   rL   rL   rM   r0        r0  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  rz   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.percentager3  )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   rB  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  rz   r;  rz   r   r5   r  r.   r   r   r!  r"  r   r   r   r   rN   rO   )r  r|   rN   r8   r)  )	rk   rl   rm   rn   rH   classmethodrB  r   ro   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  )rF  r   rG   rH   )rI   rF  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.r2  zprogress.remainingNr  r3  z--:--r1  <   Z02d:d)	r   r  r5  time_remainingr{   r8   rF  divmodr}   )rI   r   Z	task_timer   minutesr4  hours	formattedrL   rL   rM   r     s   

zTimeRemainingColumn.render)FFN)rF  r   r   r   r   r   r)  )rk   rl   rm   rn   r   rH   r   ro   rL   rL   rJ   rM   r     s    
r   c                   @  r/  )
FileSizeColumnzRenders completed filesize.r   r   rN   r8   c                 C  s   t t|j}t|ddS )Show data completed.zprogress.filesizer3  )r*   decimalr}   rF   r8   rI   r   	data_sizerL   rL   rM   r   7  s   zFileSizeColumn.renderNr)  r8  rL   rL   rL   rM   rO  4  r9  rO  c                   @  r/  )
TotalFileSizeColumnzRenders total filesize.r   r   rN   r8   c                 C  s*   |j durtt|j nd}t|ddS )rP  Nr  zprogress.filesize.totalr3  )r{   r*   rQ  r}   r8   rR  rL   rL   rM   r   @  s   zTotalFileSizeColumn.renderNr)  r8  rL   rL   rL   rM   rT  =  r9  rT  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	separatorrz   r   r   c                   r  r  )rW  rG   rH   )rI   rW  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?rI  progress.downloadr3  )r}   rF   r{   r   rz   r8   rW  )rI   r   rF   r{   Ztotal_widthrL   rL   rM   r   V  s   
zMofNCompleteColumn.render)rV  N)rW  rz   r   r   r)  r
  rL   rL   rJ   rM   rU  F  s    rU  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  )rZ  rG   rH   )rI   rZ  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   ZKiBZMiBZGiBZTiBZPiBZEiBZZiBZYiBi   )	r   ZkBZMBZGBZTBZPBZEBZZBZYBr<  r)   r   z,.frX  rV  r  rY  r3  )r}   rF   r{   rZ  r*   r=  r8   )rI   r   rF   Z unit_and_suffix_calculation_baser?  r@  Z	precisionZcompleted_ratioZcompleted_strr{   Ztotal_ratioZ	total_strZdownload_statusZdownload_textrL   rL   rM   r   n  s2   



zDownloadColumn.render)FN)rZ  r   r   r   rN   rO   r)  r
  rL   rL   rJ   rM   r   a  s
    r   c                   @  r/  )
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.NrX  zprogress.data.speedr3  z/s)rC  r  r8   r*   rQ  r}   )rI   r   r  rA  rL   rL   rM   r     s
   zTransferSpeedColumn.renderNr)  r8  rL   rL   rL   rM   r\    r9  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)rk   rl   rm   rn   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   rz   ry   r|   r{   rC   rF   GetTimeCallable	_get_timeNr5  Tr   visible)default_factoryzDict[str, Any]fieldsF)defaultinitrepr
start_time	stop_timerC  c                   C  s
   t ddS )Nr<  )maxlenr   rL   rL   rL   rM   <lambda>  s   
 zTask.<lambda>)rb  re  rf  zDeque[ProgressSample]	_progress)rf  rb  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)rg  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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)rg  rh  r   r\   rL   rL   rM   r6    s
   

zTask.elapsedc                 C  rm  )zCheck if the task has finished.N)r5  r\   rL   rL   rM   r    rn  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   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 rY   r   ).0samplerL   rL   rM   	<genexpr>      zTask.speed.<locals>.<genexpr>)rg  rl  rk  r   iterr   r   )rI   r>   Z
total_timeZiter_progressZ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.rq  N)r  r  rp  r   )rI   r  rp  ZestimaterL   rL   rM   rJ    s   zTask.time_remainingrO   c                 C  s   | j   d| _d| _dS )zReset progress.N)rk  clearr5  rC  r\   rL   rL   rM   _reset  s   

zTask._reset)rN   rC   r   )rN   r|   ri   )rk   rl   rm   rn   r  r5  ra  r   dictrc  rg  rh  rC  rk  r   rl  r   r   r.  rp  r6  r  rt  r  rJ  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.
    NTrq   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   rl  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   )r>  rL   rL   rM   r  Y  s
   zProgress.get_default_columnsr,   c                 C  r   rY   )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)rl  listr  valuesr\   rL   rL   rM   tasks|     $zProgress.tasksList[TaskID]c                 C  r  )zA list of task IDs.N)rl  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  ru  rY   )r  )rv  r   rL   rL   rM   rx    ry  z$Progress.finished.<locals>.<genexpr>)rl  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   Zis_interactiveZ
is_jupyterr  r\   rL   rL   rM   r     s   
zProgress.stopr(   c                 C  rX   rY   rZ   r\   rL   rL   rM   r]     r^   zProgress.__enter__r_   r`   ra   rb   rc   rd   c                 C  r   rY   )r   rg   rL   rL   rM   rh     r   zProgress.__exit__r   rp   rv   rw   rx   r{   r|   rF   r}   r@   Optional[TaskID]ry   rz   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.
        Nro  r)   )
rC   r   add_taskrU   rS   r~   r=   rF   rQ   rP   )rI   rw   r{   rF   r@   ry   rB   Ztrack_threadvaluerQ   rP   rL   rL   rM   r     s(   "
zProgress.trackr   )r@   ry   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   )rl  r  r{   
ValueErrorr  rU   r   )rI   r   r{   r@   ry   total_bytesrL   rL   rM   r     s   zProgress.wrap_filer   )r{   r@   ry   r   r   r   r   r   r   r   r   c          
      C  r   rY   rL   
rI   r   r   r   r   r   r   r{   r@   ry   rL   rL   rM   r        zProgress.open"Union[Literal['r'], Literal['rt']]r#   c          
      C  r   rY   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)rf   sortedr  warningswarnRuntimeWarningr   st_sizer  rU   ior   r   TextIOWrapper)rI   r   r   r   r   r   r   r{   r@   ry   _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)rl  r  rg  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)rl  r  r   rg  rh  )rI   r@   r   r   rL   rL   rM   	stop_tasky  s   

"zProgress.stop_task)r{   rF   rQ   ry   ra  rP   rQ   ra  Optional[bool]rP   rc  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   )rl  r  rF   r{   r|  ry   ra  rc  rU   r   r~  rk  popleftr   appendr]  r5  r6  rP   )rI   r@   r{   rF   rQ   ry   ra  rP   rc  r   completed_startupdate_completedr   old_sample_timerk  r  rL   rL   rM   rU     sJ   



"zProgress.update)r[   r{   rF   ra  ry   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   rl  r  r|  rg  r{   rF   ra  rc  ry   r5  rP   )
rI   r@   r[   r{   rF   ra  ry   rc  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)r   rl  r  rF   r~  rk  r  r   r   r  r]  r{   r5  r6  r  rC  )
rI   r@   rQ   r   r   r  r  r  rk  r  rL   rL   rM   rQ     s>   




"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  rz   r6   r   copy)rv  Z_columnrL   rL   rM   rx  "  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  rz   r&  )rv  columnr%  rL   rM   rx  /  s    
)r   r7   Zgridr  ra  add_row)rI   r  Z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)rl  r  r\   rL   rL   rM   __rich__:  s   $zProgress.__rich__rr  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`.
        )ra  rc  r`  rl  r)   N)	rl  r^  r  r   r  r  r:   r}   rP   )	rI   ry   r[   r{   rF   ra  rc  r   Z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)rl  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   ri   )rN   r(   rj   )Nr   Nrp   rv   )rw   rx   r{   r|   rF   r}   r@   r  ry   rz   rB   rC   rN   rx   rY   )
r   r   r{   r   r@   r  ry   rz   rN   r   r   NNN)r   r   r   r   r   r}   r   r   r   r   r   r   r{   r   r@   r  ry   rz   rN   r   )r   r   r   r  r   r}   r   r   r   r   r   r   r{   r   r@   r  ry   rz   rN   r#   r   r   NNN)r   r   r   r   r   r}   r   r   r   r   r   r   r{   r   r@   r  ry   rz   rN   r  )r@   r:   rN   rO   )r@   r:   r{   r|   rF   r|   rQ   r|   ry   r   ra  r  rP   r   rc  r   rN   rO   )r@   r:   r[   r   r{   r|   rF   r}   ra  r  ry   r   rc  r   rN   rO   )r)   )r@   r:   rQ   rC   rN   rO   )rN   r/   )rN   r  )r  r  rN   r7   )Trr  r   T)ry   rz   r[   r   r{   r|   rF   r}   ra  r   rc  r   rN   r:   )!rk   rl   rm   rn   rH   rD  r  r   r   r  r  r  r[   r   r]   rh   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)Zline_numbersZfoobarZ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...ZexamplezPretty printed)typer  z	Syntax...zGive it a try!)cycle)record)r   r   z[red]Downloadingr<  r  z[green]Processingz[yellow]ThinkingrE  r   g333333?g{Gz?d   )rp   Nr   TNFNrq   rr   rs   rt   ru   rv   FT)"rw   rx   ry   rz   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   rx   )r   r   r{   r}   ry   rz   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   ry   rz   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   ry   rz   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   ry   rz   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'   Ztyping_extensionsr(   r  r*   r+   r   r,   r-   r.   r/   r!  r0   Z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   r0  r   r   rO  rT  rU  r   r\  r]  r^  r   rk   randomtimeZpanelr  Zruler  Zsyntaxr  r  Zprogress_renderables	itertoolsr  Zexamplesr  r>   r  Ztask1Ztask2Ztask3r  rU   sleeprandintr  r   rL   rL   rL   rM   <module>   s   T
*NgAV*2*H0		1	}    
T


$