
    Kxh              +          d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ d dl	m
Z
 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mZ d dlmZmZmZ d dlmZ d dlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ej0        dk    rd dlm1Z1 nd dl2m1Z1 ddl3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZD ddlEmFZF ddlGmHZHmIZI ddlJmKZKmLZL  e(deM          ZN e.d          ZOe g ePf         ZQ ej.        de+e          ZR G d de          ZS	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd)e/e*eO         e%eO         f         d*eTd+e)eP         d,eUd-e)e7         d.eUd/e)e g ePf                  d0ePd1eFd2eFd3eFd4eFd5ePd6eUd7eUd8e%eO         f d9ZV G d: d;ee          ZW G d< d=e!eR         e$eR                   ZXd>d!dd"dd#d$d%d&d'd"d?d@ed+eMd*eTd,eUd-e)e7         d.eUd/e)e g ePf                  d0ePd1eFd2eFd3eFd4eFd6eUd8e!e         fdAZYejZ        	 	 	 	 ddd>d!dd"dd#d$d%d&d'd"dCd@e/eTdDe[f         dEe/e1dF         e1dG         f         dHeMdIe)eT         dJe)eT         dKe)eT         d+e)eM         d*eTd,eUd-e)e7         d.eUd/e)e g ePf                  d0ePd1eFd2eFd3eFd4eFd6eUd8e!e+         f&dL            Z\ejZ        	 	 	 	 ddd>d!dd"dd#d$d%d&d'd"dCd@e/eTdDe[f         dEe1dM         dHeMdIe)eT         dJe)eT         dKe)eT         d+e)eM         d*eTd,eUd-e)e7         d.eUd/e)e g ePf                  d0ePd1eFd2eFd3eFd4eFd6eUd8e!e         f&dN            Z\	 	 	 	 	 ddd>d!dd"dd#d$d%d&d'd"dCd@e/eTdDe[f         dEe/e1dM         e1dF         e1dG         f         dHeMdIe)eT         dJe)eT         dKe)eT         d+e)eM         d*eTd,eUd-e)e7         d.eUd/e)e g ePf                  d0ePd1eFd2eFd3eFd4eFd6eUd8e/e!e         e!e+         f         f&dOZ\ G dP dQe          Z] G dR dSe]          Z^ G dT dUe]          Z_ G dV dWe]          Z` G dX dYe]          Za G dZ d[e]          Zb G d\ d]e`          Zc G d^ d_e]          Zd G d` dae]          Ze G db dce]          Zf G dd dee]          Zg G df dge]          Zh G dh die]          Zi G dj dke'          Zje G dl dm                      Zk G dn doe>          Zlemdpk    rd dlnZnd dloZoddqlpmqZq ddrlrmsZs ddsltmuZu ddtlGmIZI  eududvd!w          Zt eIdxdydz          ZGeGv                    d{d|d}           d~ eqd          deGdddddet esd          g	Zwd dlxmyZy  eyew          Zz e7d!          Z6 el e_            gel{                                 eb            R e6d"d5 Z|e|}                    dd          Z~e|}                    dd          Ze|}                    dd          Ze|j        sxe|                    e~d           e|                    ed            eoj        d            enj        d d          dk     re|                     eez                     e|j        xddd           dS # 1 swxY w Y   dS dS )    N)ABCabstractmethoddeque)Sized)	dataclassfield)	timedelta)	RawIOBaseUnsupportedOperation)ceil)mmap)PathLikestat)EventRLockThread)TracebackType)AnyBinaryIOCallableContextManagerDequeDictGenericIterableList
NamedTupleNewTypeOptionalSequenceTextIOTupleTypeTypeVarUnion)      )Literal   )filesizeget_console)ConsoleGroupJustifyMethodRenderableType)Highlighter)JupyterMixin)Live)ProgressBar)Spinner)	StyleType)ColumnTable)TextTextTypeTaskIDProgressType_Ic                        e Zd ZdZdddddef fdZdd
ZddZdee	e
                  dee
         dee         dd	fdZ xZS )_TrackThreadz)A thread to periodically update progress.progressProgresstask_idr;   update_periodc                     || _         || _        || _        t                      | _        d| _        t                                                       d S )Nr   )r@   rB   rC   r   done	completedsuper__init__)selfr@   rB   rC   	__class__s       L/var/www/html/what/lib/python3.11/site-packages/pip/_vendor/rich/progress.pyrH   z_TrackThread.__init__B   sG     *GG	    returnNc                    | j         }| j        j        }| j        }d}| j        j        } ||          s)| j        }||k    r ||||z
             |} ||          )| j                            | j         | j        d           d S )Nr   T)rF   refresh)rB   r@   advancerC   rE   waitrF   update)rI   rB   rP   rC   last_completedrQ   rF   s          rK   runz_TrackThread.runK   s    ,-'*y~$}%% 	+I**^!;<<<!*	 $}%% 	+ 	T\T^TRRRRRrL   c                 .    |                                   | S NstartrI   s    rK   	__enter__z_TrackThread.__enter__Y       

rL   exc_typeexc_valexc_tbc                 `    | j                                          |                                  d S rV   )rE   setjoinrI   r\   r]   r^   s       rK   __exit__z_TrackThread.__exit__]   s$     				rL   rM   N)rM   r?   )__name__
__module____qualname____doc__floatrH   rT   rZ   r    r$   BaseExceptionr   rc   __classcell__rJ   s   @rK   r?   r?   ?   s        33 h u      S S S S   4./ -( '	
 
       rL   r?   
Working...TF
   bar.backbar.completebar.finished	bar.pulse皙?sequencedescriptiontotalauto_refreshconsole	transientget_timerefresh_per_secondstylecomplete_stylefinished_stylepulse_stylerC   disable
show_speedrM   c           
   #   R  K   |rt          d          gng }|                    t          ||	|
|          t          |          t	                      f           t          ||||||pd|d}|5  |                    | |||          E d{V  ddd           dS # 1 swxY w Y   dS )a  Track progress by iterating over a sequence.

    Args:
        sequence (Iterable[ProgressType]): A sequence (must support "len") you wish to iterate over.
        description (str, optional): Description of task show next to progress bar. Defaults to "Working".
        total: (float, optional): Total number of steps. Default is len(sequence).
        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   rn   rw   rx   ry   rz   r{   r   )rv   ru   rC   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnrA   track)rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   rC   r   r   columnsr@   s                    rK   r   r   g   s\     P EPW>	?	?@@UW  NN--'	   *555!!		
   	!-3  H 
 
 
>>E{- " 
 
 	
 	
 	
 	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   / BB #B c                      e Zd ZdZ	 d*dedddededd	f
d
Zd+dZde	e
e                  de	e         de	e         dd	fdZdefdZdefdZedefd            ZdefdZdefdZedefd            Zedefd            ZdefdZdefdZdefdZd,dedefdZdeeee f         fdZ!d,dedefdZ"d,d ede#e         fd!Z$d-d"Z%d.d$ed%edefd&Z&defd'Z'd(e(defd)Z)d	S )/_Readerz9A reader that tracks progress while it's being read from.Thandler@   rA   taskclose_handlerM   Nc                 L    || _         || _        || _        || _        d| _        d S NF)r   r@   r   r   _closed)rI   r   r@   r   r   s        rK   rH   z_Reader.__init__   s,      	(rL   c                 8    | j                                          | S rV   )r   rZ   rY   s    rK   rZ   z_Reader.__enter__   s    rL   r\   r]   r^   c                 .    |                                   d S rV   )closerb   s       rK   rc   z_Reader.__exit__   s     	

rL   c                     | S rV    rY   s    rK   __iter__z_Reader.__iter__   s    rL   c                     t          | j                  }| j                            | j        t          |                     |S NrP   )nextr   r@   rP   r   len)rI   lines     rK   __next__z_Reader.__next__   s9    DK  diT;;;rL   c                     | j         S rV   )r   rY   s    rK   closedz_Reader.closed   s
    |rL   c                 4    | j                                         S rV   )r   filenorY   s    rK   r   z_Reader.fileno       {!!###rL   c                 4    | j                                         S rV   )r   isattyrY   s    rK   r   z_Reader.isatty   r   rL   c                     | j         j        S rV   )r   moderY   s    rK   r   z_Reader.mode       {rL   c                     | j         j        S rV   )r   namerY   s    rK   r   z_Reader.name   r   rL   c                 4    | j                                         S rV   )r   readablerY   s    rK   r   z_Reader.readable       {##%%%rL   c                 4    | j                                         S rV   )r   seekablerY   s    rK   r   z_Reader.seekable   r   rL   c                     dS r   r   rY   s    rK   writablez_Reader.writable   s    urL   sizec                     | j                             |          }| j                            | j        t          |                     |S r   )r   readr@   rP   r   r   )rI   r   blocks      rK   r   z_Reader.read   s?      &&diU<<<rL   bc                 |    | j                             |          }| j                            | j        |           |S r   )r   readintor@   rP   r   )rI   r   ns      rK   r   z_Reader.readinto   s9    K  ##di333rL   c                     | j                             |          }| j                            | j        t          |                     |S r   )r   readliner@   rP   r   r   )rI   r   r   s      rK   r   z_Reader.readline   s?    {##D))diT;;;rL   hintc           	          | j                             |          }| j                            | j        t          t          t          |                               |S r   )r   	readlinesr@   rP   r   summapr   )rI   r   liness      rK   r   z_Reader.readlines   sI    %%d++diSe__1E1EFFFrL   c                 T    | j         r| j                                         d| _        d S )NT)r   r   r   r   rY   s    rK   r   z_Reader.close   s,     	 KrL   r   offsetwhencec                 ~    | j                             ||          }| j                            | j        |           |S )NrF   )r   seekr@   rR   r   )rI   r   r   poss       rK   r   z_Reader.seek  s;    kvv..TY#666
rL   c                 4    | j                                         S rV   )r   tellrY   s    rK   r   z_Reader.tell
  s    {!!!rL   sc                      t          d          )Nwrite)r   )rI   r   s     rK   r   z_Reader.write  s    "7+++rL   )T)rM   r   )r   rd   )r   )*re   rf   rg   rh   r   r;   boolrH   rZ   r    r$   rj   r   rc   r   bytesr   propertyr   intr   r   strr   r   r   r   r   r   r&   	bytearray
memoryviewr   r   r   r   r   r   r   r   r   r   r   rL   rK   r   r      s       CC "   	
  
      4./ -( '	
 
   (    %    
     X$ $ $ $ $$ $ $ $ $  c       X   c       X &$ & & & &&$ & & & &$      e    
%	:t ;<    
 S %    
 c 4;    
   
 3  C    
"c " " " ",s ,s , , , , , ,rL   r   c                   z    e Zd ZdZdddeddfdZdefdZd	eee	                  d
ee	         dee
         ddfdZdS )_ReadContextzEA utility class to handle a context for both a reader and a progress.r@   rA   readerrM   Nc                 "    || _         || _        d S rV   )r@   r   )rI   r@   r   s      rK   rH   z_ReadContext.__init__  s      rL   c                 f    | j                                          | j                                        S rV   )r@   rX   r   rZ   rY   s    rK   rZ   z_ReadContext.__enter__  s*    {$$&&&rL   r\   r]   r^   c                 p    | j                                          | j                            |||           d S rV   )r@   stopr   rc   rb   s       rK   rc   z_ReadContext.__exit__  s8     	Xw77777rL   )re   rf   rg   rh   r=   rH   rZ   r    r$   rj   r   rc   r   rL   rK   r   r     s        OO! !R !D ! ! ! !'2 ' ' ' '84./8 -(8 '	8
 
8 8 8 8 8 8rL   r   
Reading...)ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   filec          
      "   |rt          d          gng }|                    t          ||	|
|          t                      t	                      f           t          ||||||pd|d}|                    | ||          }t          ||          S )a  Read bytes from a file while tracking progress.

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

    r   r   rn   r   )rv   ru   )r   r   r   DownloadColumnr   rA   	wrap_filer   )r   rv   ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r@   r   s                   rK   r   r   &  s    J EPW>	?	?@@UW  NN--'	   !!		
   	!-3  H E{KKF&)))rL   r   )rv   ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   PathLike[str]r   rtr	bufferingencodingerrorsnewlinec                    d S rV   r   r   r   r   r   r   r   rv   ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   s                     rK   openr   g  	    , 	DrL   rbc                    d S rV   r   r   s                     rK   r   r     r   rL   c          
      ,   |rt          d          gng }|                    t          ||||          t                      t	                      f           t          |||	|
||pd|d}|                    | |||||||          }t          ||          S )a  Read bytes from a file while tracking progress.

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

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

    r   r   rn   r   )r   r   r   r   r   rv   ru   )r   r   r   r   r   rA   r   r   )r   r   r   r   r   r   rv   ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r@   r   s                        rK   r   r     s    b EPW>	?	?@@UW  NN--'	   !!		
   	!-3  H ]]  	 	F &)))rL   c                       e Zd ZU dZdZee         ed<   ddee         ddfdZ	defdZ
dd	defd
Zedd	defd            ZdS )ProgressColumnz3Base class for a widget to use in progress display.Nmax_refreshtable_columnrM   c                 0    || _         i | _        d | _        d S rV   )_table_column_renderable_cache_update_time)rI   r   s     rK   rH   zProgressColumn.__init__  s     )MO-1rL   c                 ,    | j         pt                      S )z.Get a table column, used to build tasks table.)r   r7   rY   s    rK   get_table_columnzProgressColumn.get_table_column  s    !-VXX-rL   r   Taskc                    |                                 }| j        >|j        s7	 | j        |j                 \  }}|| j        z   |k    r|S n# t
          $ r Y nw xY w|                     |          }||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).
        )rz   r   rF   r   idKeyErrorrender)rI   r   current_time	timestamp
renderables        rK   __call__zProgressColumn.__call__  s     }}''&(,(>tw(G%	: t//,>>%% ?     [[&&
+7*Dtw's   A
 

AAc                     dS )z"Should return a renderable object.Nr   rI   r   s     rK   r  zProgressColumn.render  s      rL   rV   )re   rf   rg   rh   r   r    ri   __annotations__r7   rH   r   r0   r  r   r  r   rL   rK   r   r     s         ==#'K%'''2 2Xf%5 2 2 2 2 2
.& . . . .V     . 16 1n 1 1 1 ^1 1 1rL   r   c                   R     e Zd ZdZ	 ddddedee         f fdZdd	d
efdZ xZ	S )RenderableColumnzA column to insert an arbitrary column.

    Args:
        renderable (RenderableType, optional): Any renderable. Defaults to empty string.
     Nr   r  r   c                Z    || _         t                                          |           d S Nr  )r  rG   rH   )rI   r  r   rJ   s      rK   rH   zRenderableColumn.__init__   s-     %l33333rL   r   r   rM   c                     | j         S rV   )r  r  s     rK   r  zRenderableColumn.render&  s
    rL   )r  )
re   rf   rg   rh   r0   r    r7   rH   r  rk   rl   s   @rK   r
  r
    s          ,.4SW4 4 4(4@H@P4 4 4 4 4 46 n        rL   r
  c                        e Zd ZdZ	 	 	 	 	 ddedee         d	ed
edee	         f
 fdZ
	 	 ddedee         d	eddfdZdddefdZ xZS )SpinnerColumna  A column with a 'spinner' animation.

    Args:
        spinner_name (str, optional): Name of spinner animation. Defaults to "dots".
        style (StyleType, optional): Style of spinner. Defaults to "progress.spinner".
        speed (float, optional): Speed factor of spinner. Defaults to 1.0.
        finished_text (TextType, optional): Text used when task is finished. Defaults to " ".
    dotsprogress.spinner      ? Nspinner_namer|   speedfinished_textr   c                     t          |||          | _        t          |t                    rt	          j        |          n|| _        t                                          |           d S )Nr|   r  r  )	r5   spinner
isinstancer   r9   from_markupr  rG   rH   )rI   r  r|   r  r  r   rJ   s         rK   rH   zSpinnerColumn.__init__4  sm     |5FFF ---D]+++ 	
 	l33333rL   spinner_stylerM   c                 4    t          |||          | _        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)r5   r  )rI   r  r  r  s       rK   set_spinnerzSpinnerColumn.set_spinnerD  s     |=NNNrL   r   r   c                 z    |j         r| j        n+| j                            |                                          }|S rV   )finishedr  r  r  rz   )rI   r   texts      rK   r  zSpinnerColumn.renderS  s=     }6D$$T]]__55 	
 rL   )r  r  r  r  N)r  r  )re   rf   rg   rh   r   r    r6   ri   r:   r7   rH   r   r0   r  rk   rl   s   @rK   r  r  *  s         #%7"%)-4 44 	"4 	4
  4 v&4 4 4 4 4 4& .@	O OO  	*O 	O
 
O O O O6 n        rL   r  c                   t     e Zd ZdZ	 	 	 	 	 ddededed	ed
ee	         dee
         ddf fdZdddefdZ xZS )r   zA column containing text.noneleftTNtext_formatr|   justifymarkuphighlighterr   rM   c                     || _         || _        || _        || _        || _        t                                          |pt          d                     d S )NTno_wrapr  )r'  r(  r|   r)  r*  rG   rH   r7   )rI   r'  r|   r(  r)  r*  r   rJ   s          rK   rH   zTextColumn.__init___  s[     '&-
&l&JfT6J6J6JKKKKKrL   r   r   c                    | j                             |          }| j        r"t          j        || j        | j                  }nt          || j        | j                  }| j        r| j                            |           |S Nr   )r|   r(  )	r'  formatr)  r9   r  r|   r(  r*  	highlight)rI   r   _textr#  s       rK   r  zTextColumn.rendero  s     ''T'22; 	G#ET\RRRDDTZFFFD 	-&&t,,,rL   )r%  r&  TNN)re   rf   rg   rh   r   r6   r/   r   r    r1   r7   rH   r9   r  rk   rl   s   @rK   r   r   \  s        ##
 "!'-1)-L LL L 	L
 L k*L v&L 
L L L L L L 6 d        rL   r   c                   v     e Zd ZdZ	 	 	 	 	 	 ddee         d	ed
edededee         ddf fdZddde	fdZ
 xZS )r   a  Renders a visual progress bar.

    Args:
        bar_width (Optional[int], optional): Width of bar or None for full width. Defaults to 40.
        style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
        complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
        finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
        pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
    (   ro   rp   rq   rr   N	bar_widthr|   r}   r~   r   r   rM   c                     || _         || _        || _        || _        || _        t                                          |           d S r  )r6  r|   r}   r~   r   rG   rH   )rI   r6  r|   r}   r~   r   r   rJ   s          rK   rH   zBarColumn.__init__  sL     #
,,&l33333rL   r   r   c                     t          |j        t          d|j                  ndt          d|j                  | j        dnt          d| j                  |j         |                                | j        | j        | j	        | j
        	  	        S )z&Gets a progress bar widget for a task.Nr   r*   )	rv   rF   widthpulseanimation_timer|   r}   r~   r   )r4   rv   maxrF   r6  startedrz   r|   r}   r~   r   r  s     rK   r  zBarColumn.render  s    (,
(>#a$$$D!T^,,.0$$c!T^6L6Ll"==??*..(

 

 

 
	
rL   )r5  ro   rp   rq   rr   N)re   rf   rg   rh   r    r   r6   r7   rH   r4   r  rk   rl   s   @rK   r   r   z  s          $&%$2$2!,)-4 4C=4 4 "	4
 "4 4 v&4 
4 4 4 4 4 4 
6 
k 
 
 
 
 
 
 
 
rL   r   c                   "    e Zd ZdZdddefdZdS )TimeElapsedColumnzRenders time elapsed.r   r   rM   c                     |j         r|j        n|j        }|t          dd          S t	          t          |                    }t          t          |          d          S )Show time remaining.N-:--:--progress.elapsedr|   )seconds)r"  finished_timeelapsedr9   r
   r   r   )rI   r   rG  deltas       rK   r  zTimeElapsedColumn.render  sa    (,G$$$4<?	);<<<<#g,,///CJJ&89999rL   Nre   rf   rg   rh   r9   r  r   rL   rK   r?  r?    s<        :6 :d : : : : : :rL   r?  c                        e Zd ZdZ	 	 	 	 	 	 	 	 dd	ed
ededededee	         dee
         deddf fdZedee         defd            ZdddefdZ xZS )r   a  Show task progress as a percentage.

    Args:
        text_format (str, optional): Format for percentage display. Defaults to "[progress.percentage]{task.percentage:>3.0f}%".
        text_format_no_percentage (str, optional): Format if percentage is unknown. Defaults to "".
        style (StyleType, optional): Style of output. Defaults to "none".
        justify (JustifyMethod, optional): Text justification. Defaults to "left".
        markup (bool, optional): Enable markup. Defaults to True.
        highlighter (Optional[Highlighter], optional): Highlighter to apply to output. Defaults to None.
        table_column (Optional[Column], optional): Table Column to use. Defaults to None.
        show_speed (bool, optional): Show speed if total is unknown. Defaults to False.
    -[progress.percentage]{task.percentage:>3.0f}%r  r%  r&  TNFr'  text_format_no_percentager|   r(  r)  r*  r   r   rM   c	                 r    || _         || _        t                                          ||||||           d S )N)r'  r|   r(  r)  r*  r   )rL  r   rG   rH   )
rI   r'  rL  r|   r(  r)  r*  r   r   rJ   s
            rK   rH   zTaskProgressColumn.__init__  sR     *C&$##% 	 	
 	
 	
 	
 	
rL   r  c                     |t          dd          S t          j        t          |          g dd          \  }}||z  }t          |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.percentagerD  )r  u   ×10³u   ×10⁶u   ×10⁹u   ×10¹²  z.1fz it/s)r9   r+   pick_unit_and_suffixr   )clsr  unitsuffix
data_speeds        rK   render_speedzTaskProgressColumn.render_speed  sx     ="788884JJ<<<
 
f
 T\
z44v444<QRRRRrL   r   r   c                    |j         (| j        r!|                     |j        p|j                  S |j         | j        n| j        }|                    |          }| j        r"t          j
        || j        | j                  }nt          || j        | j                  }| j        r| j                            |           |S r/  )rv   r   rU  finished_speedr  rL  r'  r1  r)  r9   r  r|   r(  r*  r2  )rI   r   r'  r3  r#  s        rK   r  zTaskProgressColumn.render  s    :$/$$T%8%FDJGGG.2j.@D**dFV 	 """--; 	G#ET\RRRDDTZFFFD 	-&&t,,,rL   )rK  r  r%  r&  TNNF)re   rf   rg   rh   r   r6   r/   r   r    r1   r7   rH   classmethodri   r9   rU  r  rk   rl   s   @rK   r   r     s#         K)+!!'-1)- 
 

 $'
 	

 
 
 k*
 v&
 
 

 
 
 
 
 
. S% ST S S S [S&6 d        rL   r   c                   X     e Zd ZdZdZ	 	 	 ddededee         f fdZd	d
de	fdZ
 x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compactelapsed_when_finishedr   c                 h    || _         || _        t                                          |           d S r  )r[  r\  rG   rH   )rI   r[  r\  r   rJ   s       rK   rH   zTimeRemainingColumn.__init__  s5     %:"l33333rL   r   r   rM   c                 t   | j         r|j        r
|j        }d}n	|j        }d}|j        t          d|          S |t          | j        rdnd|          S t          t          |          d          \  }}t          |d          \  }}| j        r|s
|d	d
|d	}n|dd
|d	d
|d	}t          ||          S )rA  rC  zprogress.remainingNr  rD  z--:--rB  <   02d:d)	r\  r"  rF  time_remainingrv   r9   r[  divmodr   )rI   r   	task_timer|   minutesrE  hours	formatteds           rK   r  zTimeRemainingColumn.render  s   % 	)$- 	)*I&EE+I(E:%((((4<>YeLLLL "#i.."55,,w< 	A 	A"666666II @@@W@@@7@@@IIU++++rL   )FFN)re   rf   rg   rh   r   r   r    r7   rH   r9   r  rk   rl   s   @rK   r   r     s          K &+)-	4 44  $4 v&	4 4 4 4 4 4,6 ,d , , , , , , , ,rL   r   c                   "    e Zd ZdZdddefdZdS )FileSizeColumnzRenders completed filesize.r   r   rM   c                 p    t          j        t          |j                            }t	          |d          S )Show data completed.zprogress.filesizerD  )r+   decimalr   rF   r9   rI   r   	data_sizes      rK   r  zFileSizeColumn.render,  s0    $S%8%899	I%89999rL   NrI  r   rL   rK   rj  rj  )  s<        %%:6 :d : : : : : :rL   rj  c                   "    e Zd ZdZdddefdZdS )TotalFileSizeColumnzRenders total filesize.r   r   rM   c                     |j         &t          j        t          |j                             nd}t	          |d          S )rl  Nr  zprogress.filesize.totalrD  )rv   r+   rm  r   r9   rn  s      rK   r  zTotalFileSizeColumn.render5  s;    9=9OH$S__555UW	I%>????rL   NrI  r   rL   rK   rq  rq  2  sD        !!@6 @d @ @ @ @ @ @rL   rq  c                   J     e Zd ZdZddedee         f fdZddd	efd
Z	 xZ
S )MofNCompleteColumnaH  Renders completed count/total, e.g. '  10/1000'.

    Best for bounded tasks with int quantities.

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

    Args:
        separator (str, optional): Text to separate completed and total values. Defaults to "/".
    /N	separatorr   c                 Z    || _         t                                          |           d S r  )rv  rG   rH   )rI   rv  r   rJ   s      rK   rH   zMofNCompleteColumn.__init__G  s+    "l33333rL   r   r   rM   c                     t          |j                  }|j        t          |j                  nd}t          t	          |                    }t          || d| j         | d          S )zShow completed/total.N?rb  progress.downloadrD  )r   rF   rv   r   r   r9   rv  )rI   r   rF   rv   total_widths        rK   r  zMofNCompleteColumn.renderK  st    ''	#':#9DJs#e**oo+@@@@@@@%
 
 
 	
rL   )ru  N)re   rf   rg   rh   r   r    r7   rH   r9   r  rk   rl   s   @rK   rt  rt  ;  s        	 	4 4# 48F;K 4 4 4 4 4 4
6 
d 
 
 
 
 
 
 
 
rL   rt  c                   P     e Zd ZdZ	 ddedee         ddf fdZdd	defd
Z	 x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   rM   c                 Z    || _         t                                          |           d S r  )r}  rG   rH   )rI   r}  r   rJ   s      rK   rH   zDownloadColumn.__init__]  s.     )l33333rL   r   r   c                    t          |j                  }|j        t          |j                  n|}| j        rt	          j        |g dd          \  }}nt	          j        |g dd          \  }}|dk    rdnd}||z  }|d| d	}|j        "t          |j                  }	|	|z  }
|
d| d	}nd
}| d| d| }t          |d          }|S )z.Calculate common unit for completed and total.N)	r   KiBMiBGiBTiBPiBEiBZiBYiBi   )	r   kBMBGBTBPBEBZBYBrO  r*   r   z,.fry  ru  r  rz  rD  )r   rF   rv   r}  r+   rP  r9   )rI   r   rF    unit_and_suffix_calculation_baserR  rS  	precisioncompleted_ratiocompleted_strrv   total_ratio	total_strdownload_statusdownload_texts                 rK   r  zDownloadColumn.renderc  s+   ''	  $z5C
OOO9 	)  	#80QQQ LD&& $80III LD&
 AA	#d**;i;;;;:!
OOE$,K&7)7777III*AAYAAAA_4GHHHrL   )FN)re   rf   rg   rh   r   r    r7   rH   r9   r  rk   rl   s   @rK   r   r   V  s          LP4 4 48@8H4	4 4 4 4 4 4!6 !d ! ! ! ! ! ! ! !rL   r   c                   "    e Zd ZdZdddefdZdS )TransferSpeedColumnz&Renders human readable transfer speed.r   r   rM   c                     |j         p|j        }|t          dd          S t          j        t          |                    }t          | dd          S )zShow data transfer speed.Nry  zprogress.data.speedrD  z/s)rW  r  r9   r+   rm  r   )rI   r   r  rT  s       rK   r  zTransferSpeedColumn.render  s]    #1tz=#89999%c%jj11
z%%%-BCCCCrL   NrI  r   rL   rK   r  r    sD        00D6 Dd D D D D D DrL   r  c                   *    e Zd ZU dZeed<   	 eed<   dS )ProgressSamplez$Sample of progress for a given time.r  rF   N)re   rf   rg   rh   ri   r  r   rL   rK   r  r    s3         ..$$rL   r  c                      e Zd ZU dZeed<   	 eed<   	 ee         ed<   	 eed<   	 e	ed<   	 dZ
ee         ed<   	 d	Zeed
<   	  ee          Zeeef         ed<   	  eddd          Zee         ed<   	  eddd          Zee         ed<   	 dZee         ed<   	  ed dd          Zee         ed<    ede          Zeed<   	 defdZedefd            Zedee         fd            Zedee         fd            Zedefd            Zedefd            Z edee         fd            Z!edee         fd            Z"d!d Z#dS )"r   zInformation regarding a progress task.

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

    r   ru   rv   rF   	_get_timeNrF  Tvisible)default_factoryfieldsF)defaultinitrepr
start_time	stop_timerW  c                  "    t          d          S )NrO  )maxlenr   r   rL   rK   <lambda>zTask.<lambda>  s    T 2 2 2 rL   )r  r  r  	_progress)r  r  _lockrM   c                 *    |                                  S )z(float: Get the current time, in seconds.)r  rY   s    rK   rz   zTask.get_time  s    ~~rL   c                     | j         duS )z#bool: Check if the task as started.N)r  rY   s    rK   r=  zTask.started  s     d**rL   c                 2    | j         dS | j         | j        z
  S )zPOptional[float]: Get the number of steps remaining, if a non-None total was set.N)rv   rF   rY   s    rK   	remainingzTask.remaining  s      :4zDN**rL   c                 x    | j         dS | j        | j        | j         z
  S |                                 | j         z
  S )z]Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started.N)r  r  rz   rY   s    rK   rG  zTask.elapsed  s=     ?"4>%>DO33}}00rL   c                     | j         duS )zCheck if the task has finished.N)rF  rY   s    rK   r"  zTask.finished  s     !--rL   c                 x    | j         sdS | j        | j         z  dz  }t          dt          d|                    }|S )zOfloat: Get progress of task as a percentage. If a None total was set, returns 0              Y@)rv   rF   minr<  )rI   rF   s     rK   
percentagezTask.percentage  sE     z 	3^dj0E9	s3	2233	rL   c                 ^   | j         dS | j        5  | j        }|s	 ddd           dS |d         j        |d         j        z
  }|dk    r	 ddd           dS t	          |          }t          |           t          d |D                       }||z  }|cddd           S # 1 swxY w Y   dS )z=Optional[float]: Get the estimated speed in steps per second.Nr   r   c              3   $   K   | ]}|j         V  d S rV   r   ).0samples     rK   	<genexpr>zTask.speed.<locals>.<genexpr>  s%      !O!Ov&"2!O!O!O!O!O!OrL   )r  r  r  r  iterr   r   )rI   r@   
total_timeiter_progresstotal_completedr  s         rK   r  z
Task.speed  sI    ?"4Z 	 	~H 	 	 	 	 	 	 	 	 ""/(1+2GGJQ	 	 	 	 	 	 	 	 !NNM!!O!O!O!O!OOOO#j0E	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   B""B"=B""B&)B&c                 h    | j         rdS | j        }|sdS | j        }|dS t          ||z            }|S )zJOptional[float]: Get estimated time to completion, or ``None`` if no data.r  N)r"  r  r  r   )rI   r  r  estimates       rK   rc  zTask.time_remaining  sP     = 	3
 	4N	4	E)**rL   c                 T    | j                                          d| _        d| _        dS )zReset progress.N)r  clearrF  rW  rY   s    rK   _resetzTask._reset  s,    !"rL   rd   )$re   rf   rg   rh   r;   r  r   r    ri   GetTimeCallablerF  r  r   r	   dictr  r   r   r  r  rW  r  r   r  r   r  rz   r   r=  r  rG  r"  r  r  rc  r  r   rL   rK   r   r     s          	JJJG'E?>*+%)M8E?)))(GTJ"U4888FDcN888?"'%5u"M"M"MJMMMN!&t%e!L!L!LIxLLLN&*NHUO***>',u22U( ( (Iu^$    5eU;;;E5;;; %         + + + + X+ +8E? + + + X+ 1% 1 1 1 X1 .$ . . . X. E    X x    X"     X# # # # # #rL   r   c                   `   e Zd ZdZddddddddddd
deeef         d	ee         d
e	de
de
de	de	de	dee         de	de	ddfdZedeedf         fd            Zedefd            Zedee         fd            Zedee         fd            Zede	fd            ZdTdZdTdZdUdZdeee                  dee         d ee         ddfd!Z	 	 	 	 dVd$eee          e!e          f         d%ee
         d&ee         d'ed(e
dee          fd)Z"	 dWdd*d+d,e#d%ee$         d&ee         d'ede#f
d-Z%e&j'        	 	 	 	 dXddd*d/d,eed0e(f         d1e)d2         d3e$d4ee         d5ee         d6ee         d%ee$         d&ee         d'ede#fd7            Z*e&j'        	 	 	 	 dXddd*d/d,eed0e(f         d1ee)d8         e)d9         f         d3e$d4ee         d5ee         d6ee         d%ee$         d&ee         d'ede+fd:            Z*	 	 	 	 	 dYddd*d/d,eed0e(f         d1ee)d2         e)d9         e)d8         f         d3e$d4ee         d5ee         d6ee         d%ee$         d&ee         d'edee#e+f         fd;Z*d&eddfd<Z,d&eddfd=Z-ddddddd>d&ed%ee
         d?ee
         d@ee
         d'ee         dAee	         dBe	dCe.ddfdDZ/dddEdddFd&edGe	d%ee
         d?e$dAee	         d'ee         dCe.ddfdHZ0dZd&ed@e
ddfdJZ1dTdKZ2de3fdLZ4dee3         fdMZ5dNee         de6fdOZ7de3fdPZ8	 	 	 	 d[d'edGe	d%ee
         d?e$dAe	dCe.defdRZ9d&eddfdSZ:dS )\rA   a  Renders an auto-updating progress bar(s).

    Args:
        console (Console, optional): Optional Console instance. Default will an internal Console instance writing to stdout.
        auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()`.
        refresh_per_second (Optional[float], optional): Number of times per second to refresh the progress information or None to use default (10). Defaults to None.
        speed_estimate_period: (float, optional): Period (in seconds) used to calculate the speed estimate. Defaults to 30.
        transient: (bool, optional): Clear the progress on exit. Defaults to False.
        redirect_stdout: (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True.
        redirect_stderr: (bool, optional): Enable redirection of stderr. Defaults to True.
        get_time: (Callable, optional): A callable that gets the current time, or None to use Console.get_time. Defaults to None.
        disable (bool, optional): Disable progress display. Defaults to False
        expand (bool, optional): Expand tasks table to fit width. Defaults to False.
    NTrn   g      >@F)
rx   rw   r{   speed_estimate_periodry   redirect_stdoutredirect_stderrrz   r   expandr   rx   rw   r{   r  ry   r  r  rz   r   r  rM   c       
   	         |dk    s
J d            t                      | _        |p|                                 | _        || _        |	| _        |
| _        i | _        t          d          | _	        t          |pt                      |||||| j                  | _        |p| j        j        | _        | j        j        | _        | j        j        | _        d S )Nr   zrefresh_per_second must be > 0)rx   rw   r{   ry   r  r  get_renderable)r   r  get_default_columnsr   r  r   r  _tasksr;   _task_indexr3   r,   r  liverx   rz   printlog)rI   rx   rw   r{   r  ry   r  r  rz   r   r  r   s               rK   rH   zProgress.__init__*  s     "A%%%'G%%%WW
<$":":"<"<%:"*,#)!99,{}}%1++.
 
 
	 !9DL$9\'
<#rL   .c                 p    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.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   )rQ  s    rK   r  zProgress.get_default_columnsN  s3    2 ABBKK  !!	
 	
rL   c                     | j         j        S rV   )r  rx   rY   s    rK   rx   zProgress.consolem  s    y  rL   c                     | j         5  t          | j                                                  cddd           S # 1 swxY w Y   dS )zGet a list of Task instances.N)r  listr  valuesrY   s    rK   taskszProgress.tasksq  s     Z 	. 	.**,,--	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.   &;??c                     | j         5  t          | j                                                  cddd           S # 1 swxY w Y   dS )zA list of task IDs.N)r  r  r  keysrY   s    rK   task_idszProgress.task_idsw  s     Z 	, 	,((**++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,r  c                     | j         5  | j        s	 ddd           dS t          d | j                                        D                       cddd           S # 1 swxY w Y   dS )z'Check if all tasks have been completed.NTc              3   $   K   | ]}|j         V  d S rV   )r"  )r  r   s     rK   r  z$Progress.finished.<locals>.<genexpr>  s$      FFt}FFFFFFrL   )r  r  allr  rY   s    rK   r"  zProgress.finished}  s     Z 	G 	G; 	G 	G 	G 	G 	G 	G 	G 	G FF1C1C1E1EFFFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   	A/AA!Ac                 N    | j         s| j                            d           dS dS )zStart the progress display.T)rO   N)r   r  rX   rY   s    rK   rX   zProgress.start  s2    | 	*IOODO)))))	* 	*rL   c                     | j                                          | j        j        s| j                                         dS dS )zStop the progress display.N)r  r   rx   is_interactiver  rY   s    rK   r   zProgress.stop  sE    	|* 	!L     	! 	!rL   c                 .    |                                   | S rV   rW   rY   s    rK   rZ   zProgress.__enter__  r[   rL   r\   r]   r^   c                 .    |                                   d S rV   )r   rb   s       rK   rc   zProgress.__exit__  s     			rL   rm   rs   rt   rv   rB   ru   rC   c              #     K   d}|2t          |t                    rt          t          |                    }n|}||                     ||          }n|                     ||           | j        j        rFt          | ||          5 }|D ]}|V  |xj	        dz  c_	        	 ddd           dS # 1 swxY w Y   dS | j
        }	| j        }
|D ]}|V   |	|d            |
             dS )a  Track progress by iterating over a sequence.

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

        Returns:
            Iterable[ProgressType]: An iterable of values taken from the provided sequence.
        Nrv   r*   )r  r   ri   r   add_taskrR   r  rw   r?   rF   rP   rO   )rI   rt   rv   rB   ru   rC   
task_totaltrack_threadvaluerP   rO   s              rK   r   zProgress.track  st     * '+
=(E** 2"3x==11
J?mmKzmBBGGKKzK2229! 	dG];; 0|% 0 0EKKK **a/***00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 lGlG!  ###				 s   	B11B58B5r   )rB   ru   r   c                    d}||}n3|1| j         5  | j        |         j        }ddd           n# 1 swxY w Y   |t          d          ||                     ||          }n|                     ||           t          || |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  rv   
ValueErrorr  rR   r   )rI   r   rv   rB   ru   total_bytess         rK   r   zProgress.wrap_file  s    . (,KK  9 9"k'289 9 9 9 9 9 9 9 9 9 9 9 9 9 9R  
 ?mmK{mCCGGKK{K333tT7????s   044r   )rv   rB   ru   r   r   r   r   r   r   r   c                    d S rV   r   
rI   r   r   r   r   r   r   rv   rB   ru   s
             rK   r   zProgress.open  	     	rL   r   r   c                    d S rV   r   r  s
             rK   r   zProgress.open  r  rL   c                v   d                     t          |d                    }
|
dvr"t          d                    |                    |dk    }|
dk    r#|dk    rt	          j        dt                     d	}n)|
d
k    s|
dk    r|dk    rt          d          |dk    rd	}|t          |          j        }|| 	                    |	|          }n| 
                    ||           t          j        |d|          }t          || |d          }|dk    s|d
k    rt          j        |||||          S |S )a#  Track progress while reading from a binary file.

        Args:
            path (Union[str, PathLike[str]]): The path to the file to read.
            mode (str): The mode to use to open the file. Only supports "r", "rb" or "rt".
            buffering (int): The buffering strategy to use, see :func:`io.open`.
            encoding (str, optional): The encoding to use when reading in text mode, see :func:`io.open`.
            errors (str, optional): The error handling strategy for decoding errors, see :func:`io.open`.
            newline (str, optional): The strategy for handling newlines in text mode, see :func:`io.open`.
            total (int, optional): Total number of bytes to read. If none given, os.stat(path).st_size is used.
            task_id (TaskID): Task to track. Default is new task.
            description (str, optional): Description of task, if new task is created.

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

        Raises:
            ValueError: When an invalid mode is given.
        r  F)reverse)brr   r   zinvalid mode {!r}r*   r  zaline buffering (buffering=1) isn't supported in binary mode, the default buffer size will be usedr   r   r   r   zcan't have unbuffered text I/ONr  r   )r   Tr  )r   r   r   line_buffering)ra   sortedr  r1  warningswarnRuntimeWarningr   st_sizer  rR   ior   r   TextIOWrapper)rI   r   r   r   r   r   r   rv   rB   ru   _moder  r   r   s                 rK   r   zProgress.open  s|   B tU33344)))077==>>> #aD==Y!^^Ms   IId]]esllA~~ !ABBBa	 =JJ&E ?mmKum==GGKKuK--- ty999wTBBB 3;;$$,,#!-    rL   c                     | j         5  | j        |         }|j        |                                 |_        ddd           dS # 1 swxY 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  rz   )rI   rB   r   s      rK   
start_taskzProgress.start_taska  s     Z 	2 	2;w'D&"&--//	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   .AA
Ac                     | j         5  | j        |         }|                                 }|j        ||_        ||_        ddd           dS # 1 swxY 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  rz   r  r  )rI   rB   r   r  s       rK   	stop_taskzProgress.stop_tasko  s     Z 	* 	*;w'D==??L&".)DN	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   7AAA)rv   rF   rP   ru   r  rO   rF   rP   r  rO   r  c                   | j         5  | j        |         }	|	j        }
|&||	j        k    r||	_        |	                                 ||	xj        |z  c_        |||	_        |||	_        |||	_        |	j                            |           |	j        |
z
  }| 	                                }|| j
        z
  }|	j        }|j        }|r.|d         j        |k     r |             |r|d         j        |k     |dk    r#|                    t          ||                     |	j        #|	j        |	j        k    r|	j        |	j        |	_        ddd           n# 1 swxY w 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   rv   r  ru   r  r  rR   rz   r  r  popleftr  appendr  rF  rG  rO   )rI   rB   rv   rF   rP   ru   r  rO   r  r   completed_startupdate_completedr  old_sample_timer  r  s                   rK   rR   zProgress.update~  s   0 Z  	2  	2;w'D"nO Udj%8%8"
"')$!*&#. "&Kv&&&#~?==??L*T-GGOI'G 	! 6 H H			  	! 6 H H!##  >N!O!OPPP
&Ndj00&.%)\"A 	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2  	2D  	LLNNNNN	 	s   D=EEEr   )rX   rv   rF   r  ru   rX   c                P   |                                  }| j        5  | j        |         }	|	                                 |r|nd|	_        |||	_        ||	_        |||	_        |r||	_        |||	_	        d|	_
        ddd           n# 1 swxY w Y   |                                  dS )a  Reset a task so completed is 0 and the clock is reset.

        Args:
            task_id (TaskID): ID of task.
            start (bool, optional): Start the task after reset. Defaults to True.
            total (float, optional): New total steps in task, or None to use current total. Defaults to None.
            completed (int, optional): Number of steps completed. Defaults to 0.
            visible (bool, optional): Enable display of the task. Defaults to True.
            description (str, optional): Change task description if not None. Defaults to None.
            **fields (str): Additional data fields required for rendering.
        N)rz   r  r  r  r  rv   rF   r  r  ru   rF  rO   )
rI   rB   rX   rv   rF   r  ru   r  r  r   s
             rK   resetzProgress.reset  s    , }}Z 	& 	&;w'DKKMMM.3=llDO "
&DN"& %$&#. !%D	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	s   ABBBr*   c                 l   |                                  }| j        5  | j        |         }|j        }|xj        |z  c_        |j        |z
  }|| j        z
  }|j        }|j        }	|r.|d         j        |k     r |	             |r|d         j        |k     t          |          dk    r |	             t          |          dk    |	                    t          ||                     |j        /|j        |j        k    r|j        |j        |_        |j        |_        ddd           dS # 1 swxY w 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   rO  N)rz   r  r  rF   r  r  r  r  r   r  r  rv   rF  rG  r  rW  )
rI   rB   rP   r  r   r  r	  r
  r  r  s
             rK   rP   zProgress.advance  s    }}Z 	1 	1;w'D"nONNg%NN#~?*T-GGOI'G 	! 6 H H			  	! 6 H Hi..4''			 i..4''^L:JKKLLL
&Ndj00&.%)\"&*j#)	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   D D))D-0D-c                 f    | j         s'| j        j        r| j                                         dS dS dS )z*Refresh (render) the progress information.N)r   r  
is_startedrO   rY   s    rK   rO   zProgress.refresh   sF    | 	 	 4 	 I	  	  	  	 rL   c                 <    t          |                                  }|S )z*Get a renderable for the progress display.)r.   get_renderables)rI   r  s     rK   r  zProgress.get_renderable  s    D00223
rL   c              #   F   K   |                      | j                  }|V  dS )z5Get a number of renderables for the progress display.N)make_tasks_tabler  )rI   tables     rK   r  zProgress.get_renderables
  s(      %%dj11rL   r  c                     d | j         D             }t          j        |d| j        d}|D ]$j        r |j        fd| j         D               %|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              3      K   | ]O}t          |t                    rt          d           n%|                                                                V  PdS )Tr,  N)r  r   r7   r   copy)r  _columns     rK   r  z,Progress.make_tasks_table.<locals>.<genexpr>  sr       
 
  gs++7t$$$$--//4466	
 
 
 
 
 
rL   )r   r*   )paddingr  c              3      K   | ]:}t          |t                    r|                               n
 |          V  ;dS )r0  N)r  r   r1  )r  columnr   s     rK   r  z,Progress.make_tasks_table.<locals>.<genexpr>%  sf         #  *&#66.FMMtM444!'	     rL   )r   r8   gridr  r  add_row)rI   r  table_columnsr  r   s       @rK   r  zProgress.make_tasks_table  s    
 
  <
 
 
 
M6$+NNN 	 	D| 
    '+l  	 	 rL   c                 l    | j         5  |                                 cddd           S # 1 swxY w Y   dS )z+Makes the Progress class itself renderable.N)r  r  rY   s    rK   __rich__zProgress.__rich__0  s}    Z 	) 	)&&((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   )--r  c                 n   | j         5  t          | j        |||||| j        | j                   }|| j        | j        <   |r|                     | j                   | j        }t          t          | j                  dz             | _        ddd           n# 1 swxY w 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  rz   r  r  r;   r   rO   )	rI   ru   rX   rv   rF   r  r  r   new_task_indexs	            rK   r  zProgress.add_task5  s   0 Z 	A 	A -j	 	 	D -1DK() 2 0111!-N%c$*:&;&;a&?@@D	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A  	s   BBBBc                 V    | j         5  | j        |= ddd           dS # 1 swxY w Y   dS )z]Delete a task if it exists.

        Args:
            task_id (TaskID): A task ID.

        N)r  r  )rI   rB   s     rK   remove_taskzProgress.remove_task`  sz     Z 	% 	%G$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   	""rd   )rM   rA   )NNrm   rs   rV   r   NNNr   r   NNN)r*   )Tr  r   T);re   rf   rg   rh   r&   r   r   r    r-   r   ri   r  rH   rX  r#   r  r   rx   r   r   r  r;   r  r"  rX   r   rZ   r$   rj   r   rc   r   r<   r!   r   r   r   r   typingoverloadr   r)   r   r"   r  r  r   rR   r  rP   rO   r0   r  r  r8   r  r   r  r$  r   rL   rK   rA   rA     s        $ &*!$&'+ $ $.2"$ "$ "$^+,"$ '""$ 	"$
 ""$  %"$ "$ "$ "$ ?+"$ "$ "$ 
"$ "$ "$ "$H 
E.#*=$> 
 
 
 [
< ! ! ! ! X! .tDz . . . X.
 ,$v, , , , X,
 G$ G G G XG* * * *
! ! ! !   4./ -( '	
 
    "&$('", ,.0FFG, , &!	,
 , , 
,	, , , ,b  $(@
 %)'(@ (@ (@(@ }(@
 &!(@ (@ 
(@ (@ (@ (@T _
 "& $!%  $$('  C%/0 dm 	
 3-  # } &!  
   _ _
 "& $!%  $$('  C%/0 GCL'$-/0 	
 3-  # } &!  
   _$ CF"& $!%K  $$('K K KC%/0K GDM74='#,>?K 	K
 3-K K #K }K &!K K 
x	 K K K KZ2& 2T 2 2 2 2* *D * * * *& "&%)#'%)"&; ; ;; 	;
 E?; %; c]; $; ; ; 
; ; ; ;B !%"&%)% % %% 	%
 % % $% c]% % 
% % % %N1 1v 1 1d 1 1 1 1<       
    
.!9    
htn     B). ) ) ) ) !&) )) ) 	)
 ) ) ) 
) ) ) )V%6 %d % % % % % %rL   rA   __main__)Panel)Rule)Syntax)r8   a~  def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
    """Iterate and generate a tuple with a flag for last value."""
    iter_values = iter(values)
    try:
        previous_value = next(iter_values)
    except StopIteration:
        return
    for value in iter_values:
        yield False, previous_value
        previous_value = value
    yield True, previous_valuepython)line_numbersfoobarbaz123z:Text may be printed while the progress bars are rendering.z(In fact, [i]any[/i] renderable will workzSuch as [magenta]tables[/]...zPretty printed structures...examplezPretty printed)typer#  z	Syntax...zGive it a try!)cycle)record)rx   ry   z[red]DownloadingrO  r  z[green]Processingz[yellow]ThinkingrZ  r   g333333?g{Gz?d   )rm   NTNFNrn   ro   rp   rq   rr   rs   FTr%  r&  )r  sysr'  r  abcr   r   collectionsr   collections.abcr   dataclassesr   r	   datetimer
   r   r   mathr   r   osr   r   	threadingr   r   r   typesr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   version_infor)   pip._vendor.typing_extensionsr  r+   r,   rx   r-   r.   r/   r0   r*  r1   jupyterr2   r  r3   progress_barr4   r  r5   r|   r6   r  r7   r8   r#  r9   r:   r   r;   r<   ri   r  r=   r?   r   r   r   r   r   r   r(  r   r   r   r
  r  r   r   r?  r   r   rj  rq  rt  r   r  r  r   rA   re   randomtimepanelr*  ruler+  syntaxr,  r  progress_renderables	itertoolsr7  examplesr  r@   r  task1task2task3r"  rR   sleeprandintr  r   r   rL   rK   <module>rU     s   				 



   # # # # # # # #       ! ! ! ! ! ! ( ( ( ( ( ( ( (       . . . . . . . .                     * * * * * * * * * *                                             * v555555 # # # # # # # # B B B B B B B B B B B B $ $ $ $ $ $ ! ! ! ! ! !       % % % % % %                                            	3		w~&&2u9% V^D&(++% % % % %6 % % %T $!!%.2 "! . .(C
 C
H\*H\,BBCC
C
 E?C
 	C

 gC
 C
 xE	*+C
 C
 C
 C
 C
 C
 C
 C
 C
  l!C
 C
 C
 C
La, a, a, a, a,i a, a, a,H8 8 8 8 8>"%wr{ 8 8 82 $!%.2 "! . .(>* >* >*
>*>* 	>*
 >* g>* >* xE	*+>* >* >* >* >* >* >* H>* >* >* >*B  " !	  #!%.2 "! . .('	 	 	
_e+
,	
ws|+
,	 	 sm		
 SM	 c]	 C=	 	 	 g	 	 xE	*+	 	 	  !	" #	$ %	& '	( F)	 	 	 	0  " !	  #!%.2 "! . .('	 	 	
_e+
,	
$-	 	 sm		
 SM	 c]	 C=	 	 	 g	 	 xE	*+	 	 	  !	" #	$ %	& '	( H)	 	 	 	4 ?B" !S*  #!%.2 "! . .('S* S* S*
_e+
,S*
wt}gcl:
;S* S* sm	S*
 SMS* c]S* C=S* S* S* gS* S* xE	*+S* S* S*  !S*" #S*$ %S*& 'S*( >(#^F%;;<)S* S* S* S*l'1 '1 '1 '1 '1S '1 '1 '1T    ~   "/ / / / /N / / /d       <'
 '
 '
 '
 '
 '
 '
 '
T	: 	: 	: 	: 	: 	: 	: 	:F F F F F F F FR-, -, -, -, -,. -, -, -,`: : : : :^ : : :@ @ @ @ @. @ @ @
 
 
 
 
 
 
 
6. . . . .^ . . .b	D 	D 	D 	D 	D. 	D 	D 	D% % % % %Z % % % z# z# z# z# z# z# z# z#zN	% N	% N	% N	% N	%| N	% N	% N	%b zMMMKKKV
	" 	  F  E%&&E	MM#sC    	E899'&$455
  u)**HgT"""G	
		%	%	'	'
 	
 
 
 
 
 - 
!!"4D!AA!!"5T!BB!!"4D!AA# 	-OOE3O///OOE3O///DJtv~a%%))TT(^^,,, # 	-- - - - - - - - - - - - - - - - - -_ s   4CYY
Y
