
    4Քh                    @	   S SK Jr  S SKrS SKrS SKrS SKJrJr  S SKJ	r	  S SK
JrJr  S SKJr  S SKJrJr  S SKJr  S S	KJr  S S
KJr  S SKJrJr  S SKJrJrJr  S SKJr  S SKJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1  \(       a  S SK2J3r3  SSK4J5r5J6r6  SSK7J8r8J9r9J:r:J;r;  SSK<J=r=  SSK>J?r?  SSK@JArA  SSKBJCrC  SSKDJErE  SSKFJGrG  SSKHJIrIJJrJ  SSKKJLrLJMrM  \+" S\N5      rO\0" S5      rP\"/ \Q4   rR\R`                  " S\-\!5      rS " S S\5      rT               Sw                                 SxS' jjrU " S( S)\\!5      rV " S* S+\#\S   \&\S   5      rWS,S SS!SS"S#S$S%S&S!S-.                           SyS. jjrX\R                      SzSS,S SS!SS"S#S$S%S&S!S/.                                     S{S0 jjj5       rZ\R                      SzSS,S SS!SS"S#S$S%S&S!S/.                                     S|S1 jjj5       rZ     S}SS,S SS!SS"S#S$S%S&S!S/.                                     S~S2 jjjrZ " S3 S4\5      r[ " S5 S6\[5      r\ " S7 S8\[5      r] " S9 S:\[5      r^ " S; S<\[5      r_ " S= S>\[5      r` " S? S@\^5      ra " SA SB\[5      rb " SC SD\[5      rc " SE SF\[5      rd " SG SH\[5      re " SI SJ\[5      rf " SK SL\[5      rg " SM SN\*5      rh\ " SO SP5      5       ri " SQ SR\?5      rj\kSS:X  Ga]  S SKlrlS SKmrmSSTKnJoro  SSUKpJqrq  SSVKrJsrs  SSWKHJJrJ  \s" SXSYS SZ9rr\J" S[S\S]5      rH\HR                  S^S_S`5        Sa\o" Sb5      Sc\HSdSeSfSg.Sh\r\q" Si5      /	ruS SjKvJwrw  \w" \u5      rx\8" S Sk9r7\j" \]" 5       /\jR                  5       Q\`" 5       P7\7S!Sl.6 rz\zR                  SmSnSo9r|\zR                  SpSnSo9r}\zR                  SqSSo9r~\zR                  (       dx  \zGR                  \|SrSs9  \zGR                  \}StSs9  \mGR                  " Su5        \lGR                  " S Sv5      S:  a  \zGR                  \" \x5      5        \zR                  (       d  Mx  SSS5        gg! , (       d  f       g= f)    )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                  ^   ^  \ rS rSrSrSU 4S jjrS	S jrS
S jr        SS jrSr	U =r
$ )_TrackThread@   z)A thread to periodically update progress.c                p   > Xl         X l        X0l        [        5       U l        SU l        [        TU ]  SS9  g )Nr   T)daemon)progresstask_idupdate_periodr   done	completedsuper__init__)selfrC   rD   rE   	__class__s       Q/var/www/auris/envauris/lib/python3.13/site-packages/pip/_vendor/rich/progress.pyrI   _TrackThread.__init__C   s3     *G	%    c                   U R                   nU R                  R                  nU R                  nSnU R                  R
                  nU" U5      (       dw  U R                  R                  R                  (       aR  U R                  nXF:w  a  U" XU-
  5        UnU" U5      (       d'  U R                  R                  R                  (       a  MR  U R                  R                  U R                   U R                  SS9  g )Nr   T)rG   refresh)
rD   rC   advancerE   rF   waitlive
is_startedrG   update)rJ   rD   rQ   rE   last_completedrR   rG   s          rL   run_TrackThread.runL   s    ,,--''**yy~~}%%$--*<*<*G*GI*^!;<!*	 }%%$--*<*<*G*G*G 	T\\T^^TRrN   c                &    U R                  5         U $ NstartrJ   s    rL   	__enter___TrackThread.__enter__Z       

rN   c                X    U R                   R                  5         U R                  5         g rZ   )rF   setjoinrJ   exc_typeexc_valexc_tbs       rL   __exit___TrackThread.__exit__^   s     					rN   )rG   rF   rC   rD   rE   )rC   
'Progress'rD   z'TaskID'rE   floatreturnNone)rm   z'_TrackThread're   zOptional[Type[BaseException]]rf   zOptional[BaseException]rg   zOptional[TracebackType]rm   rn   )__name__
__module____qualname____firstlineno____doc__rI   rW   r^   rh   __static_attributes____classcell__rK   s   @rL   r?   r?   @   sF    3&S/ ) (	
 
 rN   r?   TF
   bar.backbar.completebar.finished	bar.pulsec           
   #  2  #    U(       a  [        S5      /O/ nUR                  [        U	U
UUS9[        US9[	        SS945        [        UUUUUU=(       d    SUS.6nU   UR                  U UUUUS9 S	h  vN   S	S	S	5        g	 N! , (       d  f       g	= f7f)
aU  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}stylecomplete_stylefinished_stylepulse_style)
show_speedT)elapsed_when_finishedrx   auto_refreshconsole	transientget_timerefresh_per_seconddisable)totalrG   descriptionrE   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnProgresstrack)sequencer   r   rG   r   r   r   r   r   r   r   r   r   rE   r   r   columnsrC   s                     rL   r   r   h   s     X EP>	?@UW  NN--'	 *5d;		
 	!-3H 
>>#' " 
 	
 	
 
	
 
s0   ABB6B7B;	BB
BBc                  J   \ rS rSrSr S         SS jjrSS jr        SS jrSS jrS S jr	\
S!S j5       rS"S	 jrS!S
 jr\
S#S j5       r\
S#S j5       rS!S jrS!S jrS!S jrS$S%S jjrS&S jrS$S%S jjrS$S'S jjrS(S jrS)S*S jjrS"S jrS+S jrS,S jrSrg)-_Reader   z9A reader that tracks progress while it's being read from.c                B    Xl         X l        X0l        X@l        SU l        g NF)handlerC   taskclose_handle_closed)rJ   r   rC   r   r   s        rL   rI   _Reader.__init__   s       	(rN   c                :    U R                   R                  5         U $ rZ   )r   r^   r]   s    rL   r^   _Reader.__enter__   s    rN   c                $    U R                  5         g rZ   )closerd   s       rL   rh   _Reader.__exit__   s     	

rN   c                    U $ rZ    r]   s    rL   __iter___Reader.__iter__   s    rN   c                    [        U R                  5      nU R                  R                  U R                  [        U5      S9  U$ NrQ   )nextr   rC   rQ   r   len)rJ   lines     rL   __next___Reader.__next__   s4    DKK diiT;rN   c                    U R                   $ rZ   )r   r]   s    rL   closed_Reader.closed   s    ||rN   c                6    U R                   R                  5       $ rZ   )r   filenor]   s    rL   r   _Reader.fileno       {{!!##rN   c                6    U R                   R                  5       $ rZ   )r   isattyr]   s    rL   r   _Reader.isatty   r   rN   c                .    U R                   R                  $ rZ   )r   moder]   s    rL   r   _Reader.mode       {{rN   c                .    U R                   R                  $ rZ   )r   namer]   s    rL   r   _Reader.name   r   rN   c                6    U R                   R                  5       $ rZ   )r   readabler]   s    rL   r   _Reader.readable       {{##%%rN   c                6    U R                   R                  5       $ rZ   )r   seekabler]   s    rL   r   _Reader.seekable   r   rN   c                    gr   r   r]   s    rL   writable_Reader.writable   s    rN   c                    U R                   R                  U5      nU R                  R                  U R                  [        U5      S9  U$ r   )r   readrC   rQ   r   r   )rJ   sizeblocks      rL   r   _Reader.read   s:      &diiU<rN   c                    U R                   R                  U5      nU R                  R                  U R                  US9  U$ r   )r   readintorC   rQ   r   )rJ   bns      rL   r   _Reader.readinto   s6    KK  #dii3rN   c                    U R                   R                  U5      nU R                  R                  U R                  [        U5      S9  U$ r   )r   readlinerC   rQ   r   r   )rJ   r   r   s      rL   r   _Reader.readline   s:    {{##D)diiT;rN   c           	         U R                   R                  U5      nU R                  R                  U R                  [        [        [        U5      5      S9  U$ r   )r   	readlinesrC   rQ   r   summapr   )rJ   hintliness      rL   r   _Reader.readlines  sA    %%d+diiSe_1EFrN   c                h    U R                   (       a  U R                  R                  5         SU l        g )NT)r   r   r   r   r]   s    rL   r   _Reader.close	  s"    KKrN   c                    U R                   R                  X5      nU R                  R                  U R                  US9  U$ )NrG   )r   seekrC   rU   r   )rJ   offsetwhenceposs       rL   r   _Reader.seek  s6    kkv.TYY#6
rN   c                6    U R                   R                  5       $ rZ   )r   tellr]   s    rL   r   _Reader.tell  s    {{!!rN   c                    [        S5      e)Nwriter   )rJ   ss     rL   r   _Reader.write  s    "7++rN   c                    [        S5      e)N
writelinesr   )rJ   r   s     rL   r   _Reader.writelines  s    "<00rN   )r   r   r   rC   r   N)T)
r   r   rC   rj   r   r;   r   boolrm   rn   )rm   z	'_Reader'ro   )rm   r   )rm   bytesrm   r   )rm   int)rm   str))r   r   rm   r   )r   z"Union[bytearray, memoryview, mmap])r   r   rm   zList[bytes]rl   )r   )r   r   r   r   rm   r   )r   r   rm   r   )r   zIterable[Any]rm   rn   )rp   rq   rr   rs   rt   rI   r^   rh   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ru   r   rN   rL   r   r      s    C "  	
  
/ ) (	
 

  $$        &&





",1rN   r   c                  F    \ rS rSrSrSS jrS	S jr        S
S jrSrg)_ReadContexti  zEA utility class to handle a context for both a reader and a progress.c                    Xl         X l        g rZ   rC   reader)rJ   rC   r  s      rL   rI   _ReadContext.__init__   s      rN   c                j    U R                   R                  5         U R                  R                  5       $ rZ   )rC   r\   r  r^   r]   s    rL   r^   _ReadContext.__enter__$  s%    {{$$&&rN   c                p    U R                   R                  5         U R                  R                  XU5        g rZ   )rC   stopr  rh   rd   s       rL   rh   _ReadContext.__exit__(  s(     	X7rN   r   N)rC   rj   r  r=   rm   rn   )rm   r=   ro   )	rp   rq   rr   rs   rt   rI   r^   rh   ru   r   rN   rL   r   r     s:    O!'8/8 )8 (	8
 
8rN   r   
Reading...)r   r   r   r   r   r   r   r   r   r   r   c          
         U(       a  [        S5      /O/ nUR                  [        UU	U
US9[        5       [	        5       45        [        UUUUUU=(       d    SUS.6nUR                  XUS9n[        X5      $ )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   rx   r   )r   r   )r   r   r   DownloadColumnr   r   	wrap_filer   )filer   r   r   r   r   r   r   r   r   r   r   r   r   rC   r  s                   rL   r  r  2  s    J EP>	?@UW  NN--'	 !		
 	!-3H {KF))rN   )r   r   r   r   r   r   r   r   r   r   r   r   c                   g rZ   r   r  r   	bufferingencodingerrorsnewliner   r   r   r   r   r   r   r   r   r   r   r   s                     rL   openr  s      , 	rN   c                   g rZ   r   r  s                     rL   r  r    r  rN   c                   U(       a  [        S5      /O/ nUR                  [        UUUUS9[        5       [	        5       45        [        UUU	U
UU=(       d    SUS.6nUR                  U UUUUUUUS9n[        UU5      $ )aV  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   rx   r   )r   r  r  r  r  r   r   )r   r   r   r
  r   r   r  r   )r  r   r  r  r  r  r   r   r   r   r   r   r   r   r   r   r   r   r   rC   r  s                        rL   r  r    s    b EP>	?@UW  NN--'	 !		
 	!-3H ]]  	F &))rN   c                  ^    \ rS rSr% SrSrS\S'   SSS jjrSS jrSS jr	\
SS	 j5       rS
rg)ProgressColumni  z3Base class for a widget to use in progress display.NOptional[float]max_refreshc                ,    Xl         0 U l        S U l        g rZ   )_table_column_renderable_cache_update_time)rJ   table_columns     rL   rI   ProgressColumn.__init__   s    )MO-1rN   c                <    U R                   =(       d
    [        5       $ )z.Get a table column, used to build tasks table.)r  r7   r]   s    rL   get_table_columnProgressColumn.get_table_column  s    !!-VX-rN   c                :   UR                  5       nU R                  bB  UR                  (       d1   U R                  UR                     u  p4X0R                  -   U:  a  U$  U R                  U5      nX$4U R                  UR                  '   U$ ! [
         a     N9f = f)zCalled by the Progress object to return a renderable for the given task.

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

Returns:
    RenderableType: Anything renderable (including str).
)r   r  rG   r  idKeyErrorrender)rJ   r   current_time	timestamp
renderables        rL   __call__ProgressColumn.__call__	  s     }}'&(,(>(>tww(G%	 ///,>%% ? [[&
+7*Dtww'  s   B 
BBc                    g)z"Should return a renderable object.Nr   rJ   r   s     rL   r'  ProgressColumn.render   s    rN   )r  r  r  rZ   )r  Optional[Column]rm   rn   )rm   r7   r   'Task'rm   r0   )rp   rq   rr   rs   rt   r  __annotations__rI   r"  r+  r   r'  ru   r   rN   rL   r  r    s2    =#'K'2
.. 1 1rN   r  c                  N   ^  \ rS rSrSr SSS.   S	U 4S jjjjrS
S jrSrU =r$ )RenderableColumni%  zA column to insert an arbitrary column.

Args:
    renderable (RenderableType, optional): Any renderable. Defaults to empty string.
Nr  c               ,   > Xl         [        TU ]	  US9  g Nr6  )r*  rH   rI   )rJ   r*  r  rK   s      rL   rI   RenderableColumn.__init__,  s     %l3rN   c                    U R                   $ rZ   r*  r.  s     rL   r'  RenderableColumn.render2  s    rN   r;  ) )r*  r0   r  r0  r1  	rp   rq   rr   rs   rt   rI   r'  ru   rv   rw   s   @rL   r5  r5  %  s9     ,.4SW4(4@P4 4 rN   r5  c                  z   ^  \ rS rSrSr     S         SU 4S jjjr  S	       S
S jjrSS jrSrU =r	$ )SpinnerColumni6  aq  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 " ".
c                   > [        XUS9U l        [        U[        5      (       a  [        R
                  " U5      OUU l        [        TU ]!  US9  g )Nr   speedr6  )	r5   spinner
isinstancer   r9   from_markupfinished_textrH   rI   )rJ   spinner_namer   rC  rG  r  rK   s         rL   rI   SpinnerColumn.__init__@  sO     |F --- ]+ 	
 	l3rN   c                "    [        XUS9U l        g)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.
rB  N)r5   rD  )rJ   rH  spinner_stylerC  s       rL   set_spinnerSpinnerColumn.set_spinnerP  s     |NrN   c                    UR                   (       a  U R                  nU$ U R                  R                  UR	                  5       5      nU$ rZ   )finishedrG  rD  r'  r   )rJ   r   texts      rL   r'  SpinnerColumn.render_  sH     }}  	
  $$T]]_5 	
 rN   )rG  rD  )dotsprogress.spinner      ? N)
rH  r   r   Optional[StyleType]rC  rk   rG  r:   r  r0  )rS  rT  )rH  r   rK  rV  rC  rk   rm   rn   r1  )
rp   rq   rr   rs   rt   rI   rL  r'  ru   rv   rw   s   @rL   r@  r@  6  s     #%7"%)-44 #4 	4
  4 '4 4& .@	OO +O 	O
 
O rN   r@  c                  b   ^  \ rS rSrSr     S             SU 4S jjjrSS jrSrU =r$ )	r   ih  zA column containing text.c                |   > Xl         X0l        X l        X@l        XPl        [
        TU ]  U=(       d	    [        SS9S9  g )NTno_wrapr6  )text_formatjustifyr   markuphighlighterrH   rI   r7   )rJ   r[  r   r\  r]  r^  r  rK   s          rL   rI   TextColumn.__init__k  s:     '&-
&l&JfT6JKrN   c                B   U R                   R                  US9nU R                  (       a*  [        R                  " X R
                  U R                  S9nO[        X R
                  U R                  S9nU R                  (       a  U R                  R                  U5        U$ Nr   )r   r\  )	r[  formatr]  r9   rF  r   r\  r^  	highlight)rJ   r   _textrP  s       rL   r'  TextColumn.render{  sr      ''T'2;;##ET\\RDZZFD&&t,rN   )r^  r\  r]  r   r[  )noneleftTNN)r[  r   r   r6   r\  r/   r]  r   r^  Optional[Highlighter]r  r0  rm   rn   r   r2  rm   r9   r>  rw   s   @rL   r   r   h  sx    #
 "!'-1)-LL L 	L
 L +L 'L 
L L  rN   r   c                  d   ^  \ rS rSrSr      S             SU 4S jjjrSS jrSrU =r$ )	r   i  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".
c                \   > Xl         X l        X0l        X@l        XPl        [
        TU ]  US9  g r8  )	bar_widthr   r   r   r   rH   rI   )rJ   rm  r   r   r   r   r  rK   s          rL   rI   BarColumn.__init__  s1     #
,,&l3rN   c                b   [        UR                  b  [        SUR                  5      OS[        SUR                  5      U R                  c  SO[        SU R                  5      UR
                  (       + UR                  5       U R                  U R                  U R                  U R                  S9	$ )z&Gets a progress bar widget for a task.Nr   r*   )	r   rG   widthpulseanimation_timer   r   r   r   )r4   r   maxrG   rm  startedr   r   r   r   r   r.  s     rL   r'  BarColumn.render  s    (,

(>#a$D!T^^,..0$c!T^^6Lll"==?**....((

 
	
rN   )rm  r   r   r   r   )(   ry   rz   r{   r|   N)rm  Optional[int]r   r6   r   r6   r   r6   r   r6   r  r0  rm   rn   )r   r2  rm   r4   r>  rw   s   @rL   r   r     st     $&%$2$2!,)-4 4 4 "	4
 "4 4 '4 
4 4 
 
rN   r   c                  "    \ rS rSrSrSS jrSrg)TimeElapsedColumni  zRenders time elapsed.c                    UR                   (       a  UR                  OUR                  nUc
  [        SSS9$ [	        [        S[        U5      5      S9n[        [        U5      SS9$ )zShow time elapsed.-:--:--progress.elapsedr   r   )seconds)rO  finished_timeelapsedr9   r
   rs  r   r   )rJ   r   r  deltas       rL   r'  TimeElapsedColumn.render  sS    (,$$$4<<?	);<<#aW"67CJ&899rN   r   Nrj  rp   rq   rr   rs   rt   r'  ru   r   rN   rL   ry  ry    s
    :rN   ry  c                     ^  \ rS rSrSr        S                 SU 4S jjjr\S	S j5       rS
S jrSr	U =r
$ )r   i  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.
c	           	     B   > X l         Xl        [        T	U ]  UUUUUUS9  g )N)r[  r   r\  r]  r^  r  )text_format_no_percentager   rH   rI   )
rJ   r[  r  r   r\  r]  r^  r  r   rK   s
            rL   rI   TaskProgressColumn.__init__  s5     *C&$##% 	 	
rN   c                    Uc
  [        SSS9$ [        R                  " [        U5      / SQS5      u  p#X-  n[        US U S3SS9$ )zRender the speed in iterations per second.

Args:
    task (Task): A Task object.

Returns:
    Text: Text object containing the task speed.
r=  zprogress.percentager}  )r=  u   ×10³u   ×10⁶u   ×10⁹u   ×10¹²  z.1fz it/s)r9   r+   pick_unit_and_suffixr   )clsrC  unitsuffix
data_speeds        rL   render_speedTaskProgressColumn.render_speed  s[     ="78844J<

 \
z#&vhe4<QRRrN   c                   UR                   c?  U R                  (       a.  U R                  UR                  =(       d    UR                  5      $ UR                   c  U R
                  OU R                  nUR                  US9nU R                  (       a*  [        R                  " X0R                  U R                  S9nO[        X0R                  U R                  S9nU R                  (       a  U R                  R                  U5        U$ ra  )r   r   r  finished_speedrC  r  r[  rc  r]  r9   rF  r   r\  r^  rd  )rJ   r   r[  re  rP  s        rL   r'  TaskProgressColumn.render  s    ::$//$$T%8%8%FDJJGG.2jj.@D**dFVFV 	 """-;;##ET\\RDZZFD&&t,rN   )r   r  )z-[progress.percentage]{task.percentage:>3.0f}%r=  rg  rh  TNNF)r[  r   r  r   r   r6   r\  r/   r]  r   r^  ri  r  r0  r   r   rm   rn   )rC  r  rm   r9   rj  )rp   rq   rr   rs   rt   rI   classmethodr  r'  ru   rv   rw   s   @rL   r   r     s     K)+!!'-1)- 

 $'
 	

 
 
 +
 '
 
 

 
, S S& rN   r   c                  R   ^  \ rS rSrSrSr   S     SU 4S jjjrS	S jrSrU =r	$ )
r   i  zRenders 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.
      ?c                8   > Xl         X l        [        TU ]  US9  g r8  )compactr   rH   rI   )rJ   r  r   r  rK   s       rL   rI   TimeRemainingColumn.__init__  s      %:"l3rN   c                   U R                   (       a   UR                  (       a  UR                  nSnOUR                  nSnUR                  c
  [        SUS9$ Uc   [        U R                  (       a  SUS9$ SUS9$ [        [        U5      S5      u  pE[        US5      u  pdU R                  (       a  U(       d
  US S	US 3nOUS
 S	US S	US 3n[        XsS9$ )zShow time remaining.r|  zprogress.remainingr=  r}  z--:--r{  <   02d:d)	r   rO  r  time_remainingr   r9   r  divmodr   )rJ   r   	task_timer   minutesr~  hours	formatteds           rL   r'  TimeRemainingColumn.render  s    %%$--**I&E++I(E::%((4<<eLLYeLL "#i."5,<<"3-q6I )1WSM73-@II++rN   )r  r   )FFN)r  r   r   r   r  r0  rj  )
rp   rq   rr   rs   rt   r  rI   r'  ru   rv   rw   s   @rL   r   r     sJ     K &+)-	44  $4 '	4 4, ,rN   r   c                  "    \ rS rSrSrSS jrSrg)FileSizeColumni4  zRenders completed filesize.c                h    [         R                  " [        UR                  5      5      n[	        USS9$ )Show data completed.zprogress.filesizer}  )r+   decimalr   rG   r9   rJ   r   	data_sizes      rL   r'  FileSizeColumn.render7  s)    $$S%89	I%899rN   r   Nrj  r  r   rN   rL   r  r  4  s
    %:rN   r  c                  "    \ rS rSrSrSS jrSrg)TotalFileSizeColumni=  zRenders total filesize.c                    UR                   b)  [        R                  " [        UR                   5      5      OSn[	        USS9$ )r  r=  zprogress.filesize.totalr}  )r   r+   r  r   r9   r  s      rL   r'  TotalFileSizeColumn.render@  s4    9=9OH$$S_5UW	I%>??rN   r   Nrj  r  r   rN   rL   r  r  =  s    !@rN   r  c                  >   ^  \ rS rSrSrSSU 4S jjjrSS jrSrU =r$ )	MofNCompleteColumniF  a0  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 "/".
c                ,   > Xl         [        TU ]	  US9  g r8  )	separatorrH   rI   )rJ   r  r  rK   s      rL   rI   MofNCompleteColumn.__init__R  s    "l3rN   c                    [        UR                  5      nUR                  b  [        UR                  5      OSn[        [	        U5      5      n[        X$ S3 U R                   U 3SS9$ )zShow completed/total.?r  progress.downloadr}  )r   rG   r   r   r   r9   r  )rJ   r   rG   r   total_widths        rL   r'  MofNCompleteColumn.renderV  sa    '	#'::#9DJJs#e*oa((8@%
 	
rN   )r  )/N)r  r   r  r0  rj  r>  rw   s   @rL   r  r  F  s    	4 4
 
rN   r  c                  J   ^  \ rS rSrSr S     SU 4S jjjrSS jrSrU =r$ )	r
  ia  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.
c                ,   > Xl         [        TU ]	  US9  g r8  )binary_unitsrH   rI   )rJ   r  r  rK   s      rL   rI   DownloadColumn.__init__h  s     )l3rN   c                   [        UR                  5      nUR                  b  [        UR                  5      OUnU R                  (       a  [        R
                  " U/ SQS5      u  pEO[        R
                  " U/ SQS5      u  pEUS:X  a  SOSnX$-  nUSU S3 nUR                  b"  [        UR                  5      n	X-  n
U
SU S3 nOS	nU S
U SU 3n[        USS9nU$ )z.Calculate common unit for completed and total.)	r   KiBMiBGiBTiBPiBEiBZiBYiBi   )	r   kBMBGBTBPBEBZBYBr  r*   r   z,.fr  r  rU  r  r}  )r   rG   r   r  r+   r  r9   )rJ   r   rG    unit_and_suffix_calculation_baser  r  	precisioncompleted_ratiocompleted_strr   total_ratio	total_strdownload_statusdownload_texts                 rL   r'  DownloadColumn.rendern  s    '	  $zz5C

O9 	) #880QLD& $880ILD
 A	#**2i[/:::!

OE,K&r)Ao6II*O1YKqA_4GHrN   )r  )FN)r  r   r  r0  rm   rn   rj  r>  rw   s   @rL   r
  r
  a  s;     LP4 48H4	4 4! !rN   r
  c                  "    \ rS rSrSrSS jrSrg)TransferSpeedColumni  z&Renders human readable transfer speed.c                    UR                   =(       d    UR                  nUc
  [        SSS9$ [        R                  " [        U5      5      n[        U S3SS9$ )zShow data transfer speed.r  zprogress.data.speedr}  z/s)r  rC  r9   r+   r  r   )rJ   r   rC  r  s       rL   r'  TransferSpeedColumn.render  sR    ##1tzz=#899%%c%j1
zl"%-BCCrN   r   Nrj  r  r   rN   rL   r  r    s    0DrN   r  c                  0    \ rS rSr% SrS\S'    S\S'   Srg)ProgressSamplei  z$Sample of progress for a given time.rk   r)  rG   r   N)rp   rq   rr   rs   rt   r3  ru   r   rN   rL   r  r    s    .$rN   r  c                     \ rS rSr% SrS\S'    S\S'    S\S'    S	\S
'    S\S'    SrS\S'    SrS\S'    \" \	S9r
S\S'    \" SSSS9rS\S'    \" SSSS9rS\S'    SrS\S'    \" S SSS9rS\S'   \" S\S9rS\S '    S+S! jr\S,S" j5       r\S-S# j5       r\S-S$ j5       r\S,S% j5       r\S+S& j5       r\S-S' j5       r\S-S( j5       rS.S) jrS*rg)/Taski  z}Information regarding a progress task.

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

r;   r%  r   r   r  r   rk   rG   GetTimeCallable	_get_timeNr  Tr   visible)default_factoryzDict[str, Any]fieldsF)defaultinitrepr
start_time	stop_timer  c                     [        SS9$ )Nr  )maxlenr   r   rN   rL   <lambda>Task.<lambda>  s	    T 2rN   )r  r  r  zDeque[ProgressSample]	_progress)r  r  r   _lockc                "    U R                  5       $ )z(float: Get the current time, in seconds.)r  r]   s    rL   r   Task.get_time  s    ~~rN   c                    U R                   SL$ )z#bool: Check if the task as started.N)r  r]   s    rL   rt  Task.started  s     d**rN   c                P    U R                   c  gU R                   U R                  -
  $ )zPOptional[float]: Get the number of steps remaining, if a non-None total was set.Nr   rG   r]   s    rL   	remainingTask.remaining  s$     ::zzDNN**rN   c                    U R                   c  gU R                  b  U R                  U R                   -
  $ U R                  5       U R                   -
  $ )z]Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started.N)r  r  r   r]   s    rL   r  Task.elapsed  sC     ??">>%>>DOO33}}00rN   c                    U R                   SL$ )zCheck if the task has finished.N)r  r]   s    rL   rO  Task.finished  s     !!--rN   c                    U R                   (       d  gU R                  U R                   -  S-  n[        S[        SU5      5      nU$ )zOfloat: Get progress of task as a percentage. If a None total was set, returns 0              Y@)r   rG   minrs  )rJ   rG   s     rL   
percentageTask.percentage  s>     zz^^djj0E9	s3	23	rN   c                `   U R                   c  gU R                     U R                  nU(       d
   SSS5        gUS   R                  US   R                  -
  nUS:X  a
   SSS5        g[	        U5      n[        U5        [        S U 5       5      nXB-  nUsSSS5        $ ! , (       d  f       g= f)z=Optional[float]: Get the estimated speed in steps per second.Nr   r   c              3  8   #    U  H  oR                   v   M     g 7frZ   r   ).0samples     rL   	<genexpr>Task.speed.<locals>.<genexpr>  s     !Ov"2"2   )r  r  r  r)  iterr   r   )rJ   rC   
total_timeiter_progresstotal_completedrC  s         rL   rC  
Task.speed  s     ??"ZZ~~H Z ""//(1+2G2GGJQ Z !NM!!O!OOO#0E ZZs   B&B(-B
B-c                    U R                   (       a  gU R                  nU(       d  gU R                  nUc  g[        X!-  5      nU$ )zJOptional[float]: Get estimated time to completion, or ``None`` if no data.r  N)rO  rC  r  r   )rJ   rC  r  estimates       rL   r  Task.time_remaining  sA     ==

NN		)*rN   c                T    U R                   R                  5         SU l        SU l        g)zReset progress.N)r  clearr  r  r]   s    rL   _resetTask._reset  s"    !"rN   )r  r  )rm   rk   r   )rm   r  rl   )rp   rq   rr   rs   rt   r3  r  r  r	   dictr  r  r  r  r  r   r  r   r   rt  r  r  rO  r  rC  r  r  ru   r   rN   rL   r  r    s_    	JG'>*+%)M?)(GTJ"48FN8?"'5u"MJMN!&t%e!LILN&*NO*>',2U(I$  eU;E5;  + + + + 1 1 . .    "  #rN   r  c                  ~   \ rS rSrSrSSSSSSSSSSS.
                       S+S	 jjr\S,S
 j5       r\S-S j5       r	\S.S j5       r
\S/S j5       r\S0S j5       rS1S jrS1S jrS2S jr        S3S jr     S4             S5S jjr S6SSS.         S7S jjjr\R(                      S8SSSS.                   S9S jjj5       r\R(                      S8SSSS.                   S:S jjj5       r     S;SSSS.                   S<S jjjrS=S jrS=S jrSSSSSSS.                 S>S jjrSSSSSS .               S?S! jjrS@SAS" jjrS1S# jrSBS$ jrSCS% jrSDS& jrSBS' jr    SE             SFS( jjr S=S) jr!S*r"g)Gr   i%  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.
NTrx   g      >@F)
r   r   r   speed_estimate_periodr   redirect_stdoutredirect_stderrr   r   expandc       
   
        US:  d   S5       e[        5       U l        U=(       d    U R                  5       U l        X@l        Xl        Xl        0 U l        [        S5      U l	        [        U=(       d
    [        5       UUUUUU R                  S9U l        U=(       d    U R                  R                  U l        U R                  R                   U l        U R                  R"                  U l        g )Nr   zrefresh_per_second must be > 0)r   r   r   r   r  r  get_renderable)r   r  get_default_columnsr   r  r   r  _tasksr;   _task_indexr3   r,   r   rS   r   r   printlog)rJ   r   r   r   r  r   r  r  r   r   r  r   s               rL   rI   Progress.__init__5  s     "A%G'GG%W
<$":":"<%:"*,#)!9,{}%1++..
	 !9DLL$9$9\\''
<<##rN   c                P    [        S5      [        5       [        5       [        5       4$ )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  s    rL   r!  Progress.get_default_columnsY  s(    2 ABK !	
 	
rN   c                .    U R                   R                  $ rZ   )rS   r   r]   s    rL   r   Progress.consolex  s    yy   rN   c                    U R                      [        U R                  R                  5       5      sSSS5        $ ! , (       d  f       g= f)zGet a list of Task instances.N)r  listr"  valuesr]   s    rL   tasksProgress.tasks|  s*     ZZ**,- ZZ	   #:
Ac                    U R                      [        U R                  R                  5       5      sSSS5        $ ! , (       d  f       g= f)zA list of task IDs.N)r  r,  r"  keysr]   s    rL   task_idsProgress.task_ids  s*     ZZ((*+ ZZr0  c                    U R                      U R                  (       d
   SSS5        g[        S U R                  R                  5        5       5      sSSS5        $ ! , (       d  f       g= f)z'Check if all tasks have been completed.NTc              3  8   #    U  H  oR                   v   M     g 7frZ   )rO  )r  r   s     rL   r
  $Progress.finished.<locals>.<genexpr>  s     F1E}}1Er  )r  r"  allr-  r]   s    rL   rO  Progress.finished  sC     ZZ;; Z F1C1C1EFF ZZs   A)A
A*c                Z    U R                   (       d  U R                  R                  SS9  gg)zStart the progress display.T)rP   N)r   rS   r\   r]   s    rL   r\   Progress.start  s     ||IIOODO) rN   c                    U R                   R                  5         U R                  R                  (       d7  U R                  R                  (       d  U R                  R                  5         ggg)zStop the progress display.N)rS   r  r   is_interactive
is_jupyterr$  r]   s    rL   r  Progress.stop  sB    		||**4<<3J3JLL  4K*rN   c                &    U R                  5         U $ rZ   r[   r]   s    rL   r^   Progress.__enter__  r`   rN   c                $    U R                  5         g rZ   )r  rd   s       rL   rh   Progress.__exit__  s     			rN   r   c              #    #    Uc  [        [        U5      5      =(       d    SnUc  U R                  XRUS9nOU R                  XBUS9  U R                  R
                  (       a8  [        XU5       nU H  nUv   U=R                  S-  sl        M     SSS5        gU R                  n	U R                  n
U H  nUv   U	" US5        U
" 5         M     g! , (       d  f       g= f7f)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 want to iterate over and track progress.
    total: (float, optional): Total number of steps. Default is len(sequence).
    completed (int, optional): Number of steps completed so far. Defaults to 0.
    task_id: (TaskID): Task to track. Default is new task.
    description: (str, optional): Description of task, if new task is created.
    update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1.

Returns:
    Iterable[ProgressType]: An iterable of values taken from the provided sequence.
Nr  r*   )
rk   r   add_taskrU   rS   r   r?   rG   rQ   rP   )rJ   r   r   rG   rD   r   rE   track_threadvaluerQ   rP   s              rL   r   Progress.track  s     0 =+h/08DE?mmK	mRGKK	KB99!!d];|%EK **a/* & <;
 llGllG!#	 " <;s   A,C!.#C?C!
CC!r  )rD   r   c                  SnUb  UnO1Ub.  U R                      U R                  U   R                  nSSS5        Uc  [        S5      eUc  U R	                  XES9nOU R                  X5S9  [        XUSS9$ ! , (       d  f       NI= f)a  Track progress file reading from a binary file.

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

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

Raises:
    ValueError: When no total value can be extracted from the arguments or the task.
Nz?unable to get the total number of bytes, please specify 'total'r   Fr   )r  r"  r   
ValueErrorrE  rU   r   )rJ   r  r   rD   r   total_bytess         rL   r  Progress.wrap_file  s    . (,K "kk'288 Q 
 ?mmKmCGKKK3t7?? s   A55
B)r   rD   r   c                   g rZ   r   
rJ   r  r   r  r  r  r  r   rD   r   s
             rL   r  Progress.open       	rN   c                   g rZ   r   rP  s
             rL   r  rQ    rR  rN   c                  SR                  [        USS95      n
U
S;  a  [        SU< 35      eUS:H  nU
S:X  a$  US:X  a  [        R                  " S[
        5        S	nOU
S
;   a  US:X  a  [        S5      eUS:X  a  S	nUc  [        U5      R                  nUc  U R                  XS9nOU R                  XS9  [        R                  " USUS9n[        XUSS9nUS;   a  [        R                  " UUUUUS9$ U$ )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rtrzinvalid mode r*   rV  zaline buffering (buffering=1) isn't supported in binary mode, the default buffer size will be usedr   )rW  rX  r   zcan't have unbuffered text I/OrJ  rb)r  TrK  )rX  rW  )r  r  r  line_buffering)rc   sortedrL  warningswarnRuntimeWarningr   st_sizerE  rU   ior  r   TextIOWrapper)rJ   r  r   r  r  r  r  r   rD   r   _moderZ  r   r  s                 rL   r  rQ    s   B tU34))}TH566 #aD=Y!^MMs Ik!A~ !ABBa	 =J&&E ?mmKm=GKKK- ty9wTB ;##!-  rN   c                    U R                      U R                  U   nUR                  c  U R                  5       Ul        SSS5        g! , (       d  f       g= f)zStart a task.

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

Args:
    task_id (TaskID): ID of task.
N)r  r"  r  r   )rJ   rD   r   s      rL   
start_taskProgress.start_taskk  s:     ZZ;;w'D&"&--/ ZZs   2A
Ac                    U R                      U R                  U   nU R                  5       nUR                  c  X2l        X2l        SSS5        g! , (       d  f       g= f)zfStop a task.

This will freeze the elapsed time on the task.

Args:
    task_id (TaskID): ID of task.
N)r  r"  r   r  r  )rJ   rD   r   r(  s       rL   	stop_taskProgress.stop_tasky  sB     ZZ;;w'D==?L&".)N ZZs   9A
A)r   rG   rQ   r   r  rP   c               p   U R                      U R                  U   n	U	R                  n
Ub%  X)R                  :w  a  X)l        U	R	                  5         Ub  U	=R                  U-  sl        Ub  X9l        Ub  XYl        Ub  Xil        U	R                  R                  U5        U	R                  U
-
  nU R                  5       nXR                  -
  nU	R                  nUR                  nU(       a6  US   R                  U:  a#  U" 5         U(       a  US   R                  U:  a  M#  US:  a  UR                  [        X5      5        U	R                  b8  U	R                  U	R                  :  a  U	R                   c  U	R"                  U	l        SSS5        U(       a  U R%                  5         gg! , (       d  f       N'= f)aH  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"  rG   r   r  r   r  r  rU   r   r  r  popleftr)  appendr  r  r  rP   )rJ   rD   r   rG   rQ   r   r  rP   r  r   completed_startupdate_completedr(  old_sample_timer  rj  s                   rL   rU   Progress.update  sb   0 ZZ;;w'D"nnO Ujj%8"
"')$!*&#. "&KKv&#~~?==?L*-G-GGOI''G	! 6 6 H	 	! 6 6 H!#  !OP

&NNdjj0&&.%)\\"A D LLN E Zs   DF'!A%F''
F5)r\   r   rG   r  r   c               X   U R                  5       nU R                     U R                  U   n	U	R                  5         U(       a  UOSU	l        Ub  X9l        XIl        Ub  XYl        U(       a  Xyl        Ub  Xil	        SU	l
        SSS5        U R                  5         g! , (       d  f       N= f)a@  Reset a task so completed is 0 and the clock is reset.

Args:
    task_id (TaskID): ID of task.
    start (bool, optional): Start the task after reset. Defaults to True.
    total (float, optional): New total steps in task, or None to use current total. Defaults to None.
    completed (int, optional): Number of steps completed. Defaults to 0.
    visible (bool, optional): Enable display of the task. Defaults to True.
    description (str, optional): Change task description if not None. Defaults to None.
    **fields (str): Additional data fields required for rendering.
N)r   r  r"  r  r  r   rG   r  r  r   r  rP   )
rJ   rD   r\   r   rG   r  r   r  r(  r   s
             rL   resetProgress.reset  s    , }}ZZ;;w'DKKM.3lDO "
&N"&$&#. !%D  	 Zs   A%B
B)c                   U R                  5       nU R                     U R                  U   nUR                  nU=R                  U-  sl        UR                  U-
  nX0R                  -
  nUR
                  nUR                  n	U(       a6  US   R                  U:  a#  U	" 5         U(       a  US   R                  U:  a  M#  [        U5      S:  a  U	" 5         [        U5      S:  a  M  UR                  [        X65      5        UR                  bI  UR                  UR                  :  a/  UR                  c"  UR                  Ul        UR                  Ul        SSS5        g! , (       d  f       g= f)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   r  r"  rG   r  r  rj  r)  r   rk  r  r   r  r  rC  r  )
rJ   rD   rQ   r(  r   rl  rm  rn  r  rj  s
             rL   rQ   Progress.advance  s    }}ZZ;;w'D"nnONNg%N#~~?*-G-GGOI''G	! 6 6 H	 	! 6 6 Hi.4'	 i.4'^LKL

&NNdjj0&&.%)\\"&*jj#) ZZs   B!E  %E 'A0E  
E.c                    U R                   (       d7  U R                  R                  (       a  U R                  R                  5         ggg)z*Refresh (render) the progress information.N)r   rS   rT   rP   r]   s    rL   rP   Progress.refresh
  s,    ||		 4 4II !5|rN   c                2    [        U R                  5       6 nU$ )z*Get a renderable for the progress display.)r.   get_renderables)rJ   r*  s     rL   r   Progress.get_renderable  s    D0023
rN   c              #  J   #    U R                  U R                  5      nUv   g7f)z5Get a number of renderables for the progress display.N)make_tasks_tabler.  )rJ   tables     rL   rx  Progress.get_renderables  s     %%djj1s   !#c                   ^ S U R                    5       n[        R                  " USU R                  S.6nU H9  mTR                  (       d  M  UR
                  " U4S jU R                    5       6   M;     U$ )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     #    U  HA  n[        U[        5      (       a	  [        S S9OUR                  5       R	                  5       v   MC     g7f)TrY  N)rE  r   r7   r"  copy)r  _columns     rL   r
  ,Progress.make_tasks_table.<locals>.<genexpr>"  sI      
 ( gs++ t$--/4467 (s   A	A)r   r*   )paddingr  c              3  |   >#    U  H1  n[        U[        5      (       a  UR                  TS 9OU" T5      v   M3     g7f)rb  N)rE  r   rc  )r  columnr   s     rL   r
  r  /  sB       '3F  *&#66 #MMtM4!'. '3s   9<)r   r8   gridr  r  add_row)rJ   r.  table_columnsr|  r   s       @rL   r{  Progress.make_tasks_table  si    
  <<
 

M6$++ND||| '+ll	  rN   c                p    U R                      U R                  5       sSSS5        $ ! , (       d  f       g= f)z+Makes the Progress class itself renderable.N)r  r   r]   s    rL   __rich__Progress.__rich__:  s    ZZ&&( ZZs   '
5c                   U R                      [        U R                  UUUUUU R                  U R                   S9nXpR                  U R                  '   U(       a  U R                  U R                  5        U R                  n[        [        U R                  5      S-   5      U l        SSS5        U R                  5         W$ ! , (       d  f       N = f)a  Add a new 'task' to the Progress display.

Args:
    description (str): A description of the task.
    start (bool, optional): Start the task immediately (to calculate elapsed time). If set to False,
        you will need to call `start` manually. Defaults to True.
    total (float, optional): Number of total steps in the progress if known.
        Set to None to render a pulsing animation. Defaults to 100.
    completed (int, optional): Number of steps completed so far. Defaults to 0.
    visible (bool, optional): Enable display of the task. Defaults to True.
    **fields (str): Additional data fields required for rendering.

Returns:
    TaskID: An ID you can use when calling `update`.
)r  r  r  r  r*   N)	r  r  r#  r   r"  rd  r;   r   rP   )	rJ   r   r\   r   rG   r  r  r   new_task_indexs	            rL   rE  Progress.add_task?  s    0 ZZ  --jj	D -1KK(() 0 01!--N%c$*:*:&;a&?@D   	# Zs   BC
Cc                j    U R                      U R                  U	 SSS5        g! , (       d  f       g= f)zEDelete a task if it exists.

Args:
    task_id (TaskID): A task ID.

N)r  r"  )rJ   rD   s     rL   remove_taskProgress.remove_taskj  s!     ZZG$ ZZs   $
2)r  r#  r"  r   r   r  r   rS   r%  r$  r  )r   zUnion[str, ProgressColumn]r   Optional[Console]r   r   r   rk   r  rk   r   r   r  r   r  r   r   zOptional[GetTimeCallable]r   r   r  r   rm   rn   )rm   zTuple[ProgressColumn, ...])rm   r-   )rm   z
List[Task])rm   zList[TaskID]r   rl   )rm   r)   ro   )Nr   N
Working...皙?)r   Iterable[ProgressType]r   r  rG   r   rD   Optional[TaskID]r   r   rE   rk   rm   r  rZ   )
r  r   r   rw  rD   r  r   r   rm   r   r   NNN)r  "Union[str, 'PathLike[str]', bytes]r   Literal['rb']r  r   r  Optional[str]r  r  r  r  r   rw  rD   r  r   r   rm   r   )r  r  r   z"Union[Literal['r'], Literal['rt']]r  r   r  r  r  r  r  r  r   rw  rD   r  r   r   rm   r$   rX  r   NNN)r  r  r   1Union[Literal['rb'], Literal['rt'], Literal['r']]r  r   r  r  r  r  r  r  r   rw  rD   r  r   r   rm   zUnion[BinaryIO, TextIO])rD   r;   rm   rn   )rD   r;   r   r  rG   r  rQ   r  r   r  r  Optional[bool]rP   r   r  r   rm   rn   )rD   r;   r\   r   r   r  rG   r   r  r  r   r  r  r   rm   rn   )r*   )rD   r;   rQ   rk   rm   rn   )rm   r0   )rm   zIterable[RenderableType])r.  zIterable[Task]rm   r8   )Tr  r   T)r   r   r\   r   r   r  rG   r   r  r   r  r   rm   r;   )#rp   rq   rr   rs   rt   rI   r  r!  r   r   r.  r3  rO  r\   r  r^   rh   r   r  typingoverloadr  rd  rg  rU   rq  rQ   rP   r   rx  r{  r  rE  r  ru   r   rN   rL   r   r   %  s   $ &*!$&'+ $ $.2"$,"$ #"$ 	"$
 ""$  %"$ "$ "$ "$ ,"$ "$ "$ 
"$H 
 
< ! ! . .
 , ,
 G G*
!/ ) (	
 
 "&$('"+(+ + 	+
 "+ + + 
 +`  $(@
 %)'(@(@ (@
 "(@ (@ 
(@T __
 "& $!%  $$('0  	
      "  
  __
 "& $!%  $$('0 1 	
      "  
 $ CF"& $!%K  $$('K0K @K 	K
  K K K K "K K 
!KZ2*& "&%)#'%)"&;; 	;
 #; !; #;  ; ; ; 
;B !%"&%)%% 	%
 % %  % #% % 
%N1< 


B) !&)) ) 	)
 ) ) ) 
)V%rN   r   __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)typerP  z	Syntax...zGive it a try!)cycle)record)r   r   z[red]Downloadingr  rJ  z[green]Processingz[yellow]Thinkingr  r   g333333?g{Gz?d   )r  Nr   TNFNrx   ry   rz   r{   r|   r  FT)"r   r  r   r   r   r  rG   r   r   r   r   r  r   r   r   Optional[Callable[[], float]]r   rk   r   r6   r   r6   r   r6   r   r6   rE   rk   r   r   r   r   rm   r  )r  r   r   r   r   r   r   r   r   r  r   r   r   r  r   rk   r   r6   r   r6   r   r6   r   r6   r   r   rm   ContextManager[BinaryIO]r  )&r  r  r   z"Union[Literal['rt'], Literal['r']]r  r   r  r  r  r  r  r  r   rw  r   r   r   r   r   r  r   r   r   r  r   rk   r   r6   r   r6   r   r6   r   r6   r   r   rm   zContextManager[TextIO])&r  r  r   r  r  r   r  r  r  r  r  r  r   rw  r   r   r   r   r   r  r   r   r   r  r   rk   r   r6   r   r6   r   r6   r   r6   r   r   rm   r  r  )&r  r  r   r  r  r   r  r  r  r  r  r  r   rw  r   r   r   r   r   r  r   r   r   r  r   rk   r   r6   r   r6   r   r6   r   r6   r   r   rm   z7Union[ContextManager[BinaryIO], ContextManager[TextIO]])
__future__r   r`  r  r\  abcr   r   collectionsr   dataclassesr   r	   datetimer
   r   r   mathr   r   operatorr   osr   r   	threadingr   r   r   typesr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   typing_extensionsr)   r=  r+   r,   r   r-   r.   r/   r0   r^  r1   jupyterr2   rS   r3   progress_barr4   rD  r5   r   r6   r|  r7   r8   rP  r9   r:   r   r;   r<   rk   r  r=   r?   r   r   r   r  r  r  r  r5  r@  r   r   ry  r   r   r  r  r  r
  r  r  r  r   rp   randomtimepanelr  ruler  syntaxr  r  progress_renderables	itertoolsr  examplesr!  rC   rE  task1task2task3rO  rU   sleeprandintr%  r   r   rN   rL   <module>r     s5   " 	   #  (  .      * *      , & # B B $ !  %      	3	~&2u9% ^^D&(+%6 %T $!!%.2 "! . .(!K
$K
K
 K
 	K

 K
 K
 K
 ,K
 K
 K
 K
 K
 K
 K
 K
  !K
" #K
\d1i d1N8>"%wr{ 82 $!%.2 "! . .(>*
>*>* 	>*
 >* >* >* ,>* >* >* >* >* >* >* >*B  " !	  #!%.2 "! . .('	
,	
,	 	 		
 	 	 	 	 	 	 	 ,	 	 	  !	" #	$ %	& '	( )	 	0  " !	  #!%.2 "! . .('	
,	
	 	 		
 	 	 	 	 	 	 	 ,	 	 	  !	" #	$ %	& '	( )	 	4 ?B" !S*  #!%.2 "! . .('S*
,S*
;S* S* 	S*
 S* S* S* S* S* S* S* ,S* S* S*  !S*" #S*$ %S*& 'S*( =)S*l'1S '1T~ "/N /d <'
 '
T	: 	:E EP-,. -,`:^ :@. @
 
6.^ .b	D. 	D%Z % z# z# z#zM	%| M	%` z
	" 	F  %&E	MM#sC  	E89'&$45
  )*HT"G	
		%	%	'
 	
 
 
!!"4D!A!!"5T!B!!"4D!A##OOE3O/OOE3O/JJt~~a%)T(^, ###
 
] \
 
s   B8R
R