
    &gC              +       
   S SK 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.J/r/  \R`                  S:  a  S SKJ1r1  OS SK2J1r1  SSK3J4r4J5r5  SSK6J7r7J8r8J9r9J:r:  SSK;J<r<  SSK=J>r>  SSK?J@r@  SSKAJBrB  SSKCJDrD  SSKEJFrF  SSKGJHrHJIrI  SSKJJKrKJLrL  \(" S\M5      rN\." S5      rO\ / \P4   rQ\R\                  " S\+\5      rR " S S\5      rS              SS'\/\*\O   \%\O   4   S(\TS)\)\P   S*\US+\)\7   S,\US-\)\ / \P4      S.\PS/\FS0\FS1\FS2\FS3\PS4\US5\US6\%\O   4 S7 jjrV " S8 S9\\5      rW " S: S;\!\R   \$\R   5      rXS<S SS!SS"S#S$S%S&S!S=.S>\S)\MS(\TS*\US+\)\7   S,\US-\)\ / \P4      S.\PS/\FS0\FS1\FS2\FS4\US6\!\   4S? jjrY\R                      SSS<S SS!SS"S#S$S%S&S!S@.S>\/\TSA\[4   SB\/\1SC   \1SD   4   SE\MSF\)\T   SG\)\T   SH\)\T   S)\)\M   S(\TS*\US+\)\7   S,\US-\)\ / \P4      S.\PS/\FS0\FS1\FS2\FS4\US6\!\+   4&SI jjj5       r\\R                      SSS<S SS!SS"S#S$S%S&S!S@.S>\/\TSA\[4   SB\1SJ   SE\MSF\)\T   SG\)\T   SH\)\T   S)\)\M   S(\TS*\US+\)\7   S,\US-\)\ / \P4      S.\PS/\FS0\FS1\FS2\FS4\US6\!\   4&SK jjj5       r\     SSS<S SS!SS"S#S$S%S&S!S@.S>\/\TSA\[4   SB\/\1SJ   \1SC   \1SD   4   SE\MSF\)\T   SG\)\T   SH\)\T   S)\)\M   S(\TS*\US+\)\7   S,\US-\)\ / \P4      S.\PS/\FS0\FS1\FS2\FS4\US6\/\!\   \!\+   4   4&SL jjjr\ " SM SN\5      r] " SO SP\]5      r^ " SQ SR\]5      r_ " SS ST\]5      r` " SU SV\]5      ra " SW SX\]5      rb " SY SZ\`5      rc " S[ S\\]5      rd " S] S^\]5      re " S_ S`\]5      rf " Sa Sb\]5      rg " Sc Sd\]5      rh " Se Sf\]5      ri " Sg Sh\'5      rj\
 " Si Sj5      5       rk " Sk Sl\>5      rl\mSm:X  Ga_  S SKnrnS SKoroSSnKpJqrq  SSoKrJsrs  SSpKtJuru  SSqKGJIrI  \u" SrSsS St9rt\I" SuSvSw5      rG\GR                  SxSySz5        S{\q" S|5      S}\GS~SSS.S\t\s" S5      /	rwS SKxJyry  \y" \w5      rz\7" S S9r6\l" \_" 5       /\lR                  5       Q\b" 5       P7\6S!S.6 r|\|R                  SSS9r~\|R                  SSS9r\|R                  SSS9r\|GR                  (       dy  \|GR                  \~SS9  \|GR                  \SS9  \oGR                  " S5        \nGR                  " S S5      S:  a  \|GR                  \" \z5      5        \|GR                  (       d  My  SSS5        gg! , (       d  f       g= f)    N)ABCabstractmethoddeque)	dataclassfield)	timedelta)	RawIOBaseUnsupportedOperation)ceil)mmap)length_hint)PathLikestat)EventRLockThread)TracebackType)AnyBinaryIOCallableContextManagerDequeDictGenericIterableList
NamedTupleNewTypeOptionalSequenceTextIOTupleTypeTypeVarUnion)      )Literal   )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SSSS\4U 4S jjrSS jrSS jrS\	\
\      S\	\   S\	\   S	S
4S jrSrU =r$ )_TrackThread?   z)A thread to periodically update progress.progressProgresstask_idr;   update_periodc                 r   > Xl         X l        X0l        [        5       U l        SU l        [        TU ]  5         g )Nr   )rA   rC   rD   r   done	completedsuper__init__)selfrA   rC   rD   	__class__s       R/home/matz/Project1/venv/lib/python3.13/site-packages/pip/_vendor/rich/progress.pyrI   _TrackThread.__init__B   s.     *G	    returnNc                 b   U R                   nU R                  R                  nU R                  nSnU R                  R
                  nU" U5      (       d-  U R                  nXF:w  a  U" XU-
  5        UnU" U5      (       d  M-  U R                  R                  U R                   U R                  SS9  g )Nr   T)rG   refresh)rC   rA   advancerD   rF   waitrG   update)rJ   rC   rR   rD   last_completedrS   rG   s          rL   run_TrackThread.runK   s    ,,--''**yy~~}%%I*^!;<!*	 }%% 	T\\T^^TRrN   c                 &    U R                  5         U $ NstartrJ   s    rL   	__enter___TrackThread.__enter__Y       

rN   exc_typeexc_valexc_tbc                 X    U R                   R                  5         U R                  5         g rY   )rF   setjoinrJ   r`   ra   rb   s       rL   __exit___TrackThread.__exit__]   s     					rN   )rG   rF   rA   rC   rD   rO   N)rO   r?   )__name__
__module____qualname____firstlineno____doc__floatrI   rV   r]   r    r$   BaseExceptionr   rg   __static_attributes____classcell__rK   s   @rL   r?   r?   ?   so    3 h u S4./ -( '	
 
 rN   r?   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_stylerD   disable
show_speedrO   c           
   #   ,  #    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                  XXS9 S	h  vN   S	S	S	5        g	 N! , (       d  f       g	= f7f)
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   T)elapsed_when_finishedrt   r|   r}   r~   r   r   r   )r{   rz   rD   N)
TextColumnextend	BarColumnTaskProgressColumnTimeRemainingColumnrB   track)ry   rz   r{   r|   r}   r~   r   r   r   r   r   r   rD   r   r   columnsrA   s                    rL   r   r   g   s     P EP>	?@UW  NN--'	 *5d;		
 	!-3H 
>>{ " 
 	
 	
 
	
 
s0   ABB3B4B8	BB
BBc                      \ rS rSrSr S)S\SSS\S\SS	4
S
 jjrS*S jr	S\
\\      S\
\   S\
\   SS	4S jrS\4S jrS\4S jr\S\4S j5       rS\4S jrS\4S jr\S\4S j5       r\S\4S j5       rS\4S jrS\4S jrS\4S jrS+S\S\4S jjrS\\\ \!4   4S jr"S+S\S\4S jjr#S+S\S\$\   4S  jjr%S,S! jr&S-S"\S#\S\4S$ jjr'S\4S% jr(S&\)S\4S' jr*S(r+g	)._Reader   z9A reader that tracks progress while it's being read from.handlerA   rB   taskclose_handlerO   Nc                 B    Xl         X l        X0l        X@l        SU l        g NF)r   rA   r   r   _closed)rJ   r   rA   r   r   s        rL   rI   _Reader.__init__   s       	(rN   c                 :    U R                   R                  5         U $ rY   )r   r]   r\   s    rL   r]   _Reader.__enter__   s    rN   r`   ra   rb   c                 $    U R                  5         g rY   )closerf   s       rL   rg   _Reader.__exit__   s     	

rN   c                     U $ rY    r\   s    rL   __iter___Reader.__iter__   s    rN   c                     [        U R                  5      nU R                  R                  U R                  [        U5      S9  U$ NrR   )nextr   rA   rR   r   len)rJ   lines     rL   __next___Reader.__next__   s4    DKK diiT;rN   c                     U R                   $ rY   )r   r\   s    rL   closed_Reader.closed   s    ||rN   c                 6    U R                   R                  5       $ rY   )r   filenor\   s    rL   r   _Reader.fileno       {{!!##rN   c                 6    U R                   R                  5       $ rY   )r   isattyr\   s    rL   r   _Reader.isatty   r   rN   c                 .    U R                   R                  $ rY   )r   moder\   s    rL   r   _Reader.mode       {{rN   c                 .    U R                   R                  $ rY   )r   namer\   s    rL   r   _Reader.name   r   rN   c                 6    U R                   R                  5       $ rY   )r   readabler\   s    rL   r   _Reader.readable       {{##%%rN   c                 6    U R                   R                  5       $ rY   )r   seekabler\   s    rL   r   _Reader.seekable   r   rN   c                     gr   r   r\   s    rL   writable_Reader.writable   s    rN   sizec                     U R                   R                  U5      nU R                  R                  U R                  [        U5      S9  U$ r   )r   readrA   rR   r   r   )rJ   r   blocks      rL   r   _Reader.read   s:      &diiU<rN   bc                     U R                   R                  U5      nU R                  R                  U R                  US9  U$ r   )r   readintorA   rR   r   )rJ   r   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   readlinerA   rR   r   r   )rJ   r   r   s      rL   r   _Reader.readline   s:    {{##D)diiT;rN   hintc           	          U R                   R                  U5      nU R                  R                  U R                  [        [        [        U5      5      S9  U$ r   )r   	readlinesrA   rR   r   summapr   )rJ   r   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   offsetwhencec                     U R                   R                  X5      nU R                  R                  U R                  US9  U$ )NrG   )r   seekrA   rT   r   )rJ   r   r   poss       rL   r   _Reader.seek  s6    kkv.TYY#6
rN   c                 6    U R                   R                  5       $ rY   )r   tellr\   s    rL   r   _Reader.tell
  s    {{!!rN   sc                     [        S5      e)Nwrite)r   )rJ   r   s     rL   r   _Reader.write  s    "7++rN   )r   r   r   rA   r   )T)rO   r   )ri   )r   ),rj   rk   rl   rm   rn   r   r;   boolrI   r]   r    r$   rp   r   rg   r   bytesr   propertyr   intr   r   strr   r   r   r   r   r   r&   	bytearray
memoryviewr   r   r   r   r   r   r   r   r   r   rq   r   rN   rL   r   r      s   C "  	
  
4./ -( '	
 
( % 
   $ $$ $  c      c    &$ &&$ &$  e 
%	:t ;< 
S % 
c 4; 

3  C 
"c ",s ,s ,rN   r   c                   n    \ rS rSrSrSSS\SS4S jrS\4S	 jrS
\\	\
      S\\
   S\\   SS4S jrSrg)_ReadContexti  zEA utility class to handle a context for both a reader and a progress.rA   rB   readerrO   Nc                     Xl         X l        g rY   rA   r   )rJ   rA   r   s      rL   rI   _ReadContext.__init__  s      rN   c                 j    U R                   R                  5         U R                  R                  5       $ rY   )rA   r[   r   r]   r\   s    rL   r]   _ReadContext.__enter__  s%    {{$$&&rN   r`   ra   rb   c                 p    U R                   R                  5         U R                  R                  XU5        g rY   )rA   stopr   rg   rf   s       rL   rg   _ReadContext.__exit__  s(     	X7rN   r   )rj   rk   rl   rm   rn   r=   rI   r]   r    r$   rp   r   rg   rq   r   rN   rL   r   r     sj    O! !R !D !'2 '84./8 -(8 '	8
 
8rN   r   
Reading...)rz   r|   r}   r~   r   r   r   r   r   r   r   filec          
          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   rt   r   )r{   rz   )r   r   r   DownloadColumnr   rB   	wrap_filer   )r  r{   rz   r|   r}   r~   r   r   r   r   r   r   r   r   rA   r   s                   rL   r  r  &  s    J EP>	?@UW  NN--'	 !		
 	!-3H {KF))rN   )r{   rz   r|   r}   r~   r   r   r   r   r   r   r   PathLike[str]r   rtr	bufferingencodingerrorsnewlinec                    g rY   r   r  r   r  r	  r
  r  r{   rz   r|   r}   r~   r   r   r   r   r   r   r   s                     rL   openr  g      , 	rN   rbc                    g rY   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   rt   r   )r   r  r	  r
  r  r{   rz   )r   r   r   r  r   rB   r  r   )r  r   r  r	  r
  r  r{   rz   r|   r}   r~   r   r   r   r   r   r   r   r   rA   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4S jjr
S\	4S jrS	S
S\4S jr\S	S
S\4S j5       rSrg)ProgressColumni  z3Base class for a widget to use in progress display.Nmax_refreshtable_columnrO   c                 ,    Xl         0 U l        S U l        g rY   )_table_column_renderable_cache_update_time)rJ   r  s     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   r   Taskc                 :   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  rY   )rj   rk   rl   rm   rn   r  r    ro   __annotations__r7   rI   r  r0   r'  r   r#  rq   r   rN   rL   r  r    sl    =#'K%'2Xf%5 2 2
.& .V  . 16 1n 1 1rN   r  c                   ^   ^  \ rS rSrSr SSS.S\S\\   4U 4S jjjjrSS	S
\4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  r&  r  c                ,   > Xl         [        TU ]	  US9  g Nr/  )r&  rH   rI   )rJ   r&  r  rK   s      rL   rI   RenderableColumn.__init__   s     %l3rN   r   r  rO   c                     U R                   $ rY   r&  r*  s     rL   r#  RenderableColumn.render&  s    rN   r4  ) )rj   rk   rl   rm   rn   r0   r    r7   rI   r#  rq   rr   rs   s   @rL   r.  r.    sL     ,.4SW4(4@H@P4 46 n  rN   r.  c                      ^  \ rS rSrSr     SS\S\\   S\S\	S\\
   4
U 4S	 jjjr  SS\S
\\   S\SS4S jjrSSS\4S jrSrU =r$ )SpinnerColumni*  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 " ".
Nspinner_namer   speedfinished_textr  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   r:  r/  )	r5   spinner
isinstancer   r9   from_markupr;  rH   rI   )rJ   r9  r   r:  r;  r  rK   s         rL   rI   SpinnerColumn.__init__4  sO     |F --- ]+ 	
 	l3rN   spinner_stylerO   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.
r=  N)r5   r>  )rJ   r9  rB  r:  s       rL   set_spinnerSpinnerColumn.set_spinnerD  s     |NrN   r   r  c                     UR                   (       a  U R                  nU$ U R                  R                  UR	                  5       5      nU$ rY   )finishedr;  r>  r#  r   )rJ   r   texts      rL   r#  SpinnerColumn.renderS  sH     }}  	
  $$T]]_5 	
 rN   )r;  r>  )dotsprogress.spinner      ? N)rK  rL  )rj   rk   rl   rm   rn   r   r    r6   ro   r:   r7   rI   rD  r0   r#  rq   rr   rs   s   @rL   r8  r8  *  s     #%7"%)-44 	"4 	4
  4 v&4 4& .@	OO  	*O 	O
 
O6 n  rN   r8  c                   x   ^  \ rS rSrSr     SS\S\S\S\S\	\
   S	\	\   S
S4U 4S jjjrSSS
\4S jrSrU =r$ )r   i\  zA column containing text.Ntext_formatr   justifymarkuphighlighterr  rO   c                 |   > Xl         X0l        X l        X@l        XPl        [
        TU ]  U=(       d	    [        SS9S9  g )NTno_wrapr/  )rO  rP  r   rQ  rR  rH   rI   r7   )rJ   rO  r   rP  rQ  rR  r  rK   s          rL   rI   TextColumn.__init___  s:     '&-
&l&JfT6JKrN   r   r  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   rP  )	rO  formatrQ  r9   r@  r   rP  rR  	highlight)rJ   r   _textrH  s       rL   r#  TextColumn.rendero  sr      ''T'2;;##ET\\RDZZFD&&t,rN   )rR  rP  rQ  r   rO  )noneleftTNN)rj   rk   rl   rm   rn   r   r6   r/   r   r    r1   r7   rI   r9   r#  rq   rr   rs   s   @rL   r   r   \  s    #
 "!'-1)-LL L 	L
 L k*L v&L 
L L 6 d  rN   r   c                   z   ^  \ rS rSrSr      SS\\   S\S\S\S\S	\\   S
S4U 4S jjjr	SSS
\
4S jrSrU =r$ )r   iz  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".
N	bar_widthr   r   r   r   r  rO   c                 \   > Xl         X l        X0l        X@l        XPl        [
        TU ]  US9  g r1  )ra  r   r   r   r   rH   rI   )rJ   ra  r   r   r   r   r  rK   s          rL   rI   BarColumn.__init__  s1     #
,,&l3rN   r   r  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   ra  startedr   r   r   r   r   r*  s     rL   r#  BarColumn.render  s    (,

(>#a$D!T^^,..0$c!T^^6Lll"==?**....((

 
	
rN   )ra  r   r   r   r   )(   ru   rv   rw   rx   N)rj   rk   rl   rm   rn   r    r   r6   r7   rI   r4   r#  rq   rr   rs   s   @rL   r   r   z  s     $&%$2$2!,)-4C=4 4 "	4
 "4 4 v&4 
4 4 
6 
k 
 
rN   r   c                   *    \ rS rSrSrSSS\4S jrSrg)	TimeElapsedColumni  zRenders time elapsed.r   r  rO   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)rG  finished_timeelapsedr9   r	   rh  r   r   )rJ   r   rt  deltas       rL   r#  TimeElapsedColumn.render  sS    (,$$$4<<?	);<<#aW"67CJ&899rN   r   Nrj   rk   rl   rm   rn   r9   r#  rq   r   rN   rL   rm  rm    s    :6 :d :rN   rm  c                      ^  \ rS rSrSr        SS\S\S\S\S\S	\	\
   S
\	\   S\SS4U 4S jjjr\S\	\   S\4S j5       rSSS\4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.
NrO  text_format_no_percentager   rP  rQ  rR  r  r   rO   c	           	      B   > X l         Xl        [        T	U ]  UUUUUUS9  g )N)rO  r   rP  rQ  rR  r  )ry  r   rH   rI   )
rJ   rO  ry  r   rP  rQ  rR  r  r   rK   s
            rL   rI   TaskProgressColumn.__init__  s5     *C&$##% 	 	
rN   r:  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.
r6  zprogress.percentagerq  )r6  u   ×10³u   ×10⁶u   ×10⁹u   ×10¹²  z.1fz it/s)r9   r+   pick_unit_and_suffixr   )clsr:  unitsuffix
data_speeds        rL   render_speedTaskProgressColumn.render_speed  s[     ="78844J<

 \
z#&vhe4<QRRrN   r   r  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$ rX  )r{   r   r  finished_speedr:  ry  rO  rZ  rQ  r9   r@  r   rP  rR  r[  )rJ   r   rO  r\  rH  s        rL   r#  TaskProgressColumn.render  s    ::$//$$T%8%8%FDJJGG.2jj.@D**dFVFV 	 """-;;##ET\\RDZZFD&&t,rN   )r   ry  )z-[progress.percentage]{task.percentage:>3.0f}%r6  r^  r_  TNNF)rj   rk   rl   rm   rn   r   r6   r/   r   r    r1   r7   rI   classmethodro   r9   r  r#  rq   rr   rs   s   @rL   r   r     s     K)+!!'-1)- 

 $'
 	

 
 
 k*
 v&
 
 

 
, S% ST S S&6 d  rN   r   c                   b   ^  \ rS rSrSrSr   SS\S\S\\   4U 4S jjjr	SS	S
\
4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.
      ?compactr   r  c                 8   > Xl         X l        [        TU ]  US9  g r1  )r  r   rH   rI   )rJ   r  r   r  rK   s       rL   rI   TimeRemainingColumn.__init__  s      %:"l3rN   r   r  rO   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.rp  zprogress.remainingr6  rq  z--:--ro  <   02d:d)	r   rG  rs  time_remainingr{   r9   r  divmodr   )rJ   r   	task_timer   minutesrr  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)rj   rk   rl   rm   rn   r  r   r    r7   rI   r9   r#  rq   rr   rs   s   @rL   r   r     s]     K &+)-	44  $4 v&	4 4,6 ,d , ,rN   r   c                   *    \ rS rSrSrSSS\4S jrSrg)	FileSizeColumni(  zRenders completed filesize.r   r  rO   c                 h    [         R                  " [        UR                  5      5      n[	        USS9$ )Show data completed.zprogress.filesizerq  )r+   decimalr   rG   r9   rJ   r   	data_sizes      rL   r#  FileSizeColumn.render+  s)    $$S%89	I%899rN   r   Nrw  r   rN   rL   r  r  (  s    %:6 :d :rN   r  c                   *    \ rS rSrSrSSS\4S jrSrg)	TotalFileSizeColumni1  zRenders total filesize.r   r  rO   c                     UR                   b)  [        R                  " [        UR                   5      5      OSn[	        USS9$ )r  r6  zprogress.filesize.totalrq  )r{   r+   r  r   r9   r  s      rL   r#  TotalFileSizeColumn.render4  s4    9=9OH$$S_5UW	I%>??rN   r   Nrw  r   rN   rL   r  r  1  s    !@6 @d @rN   r  c                   T   ^  \ rS rSrSrSS\S\\   4U 4S jjjrSSS\	4S	 jr
S
rU =r$ )MofNCompleteColumni:  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 "/".
	separatorr  c                 ,   > Xl         [        TU ]	  US9  g r1  )r  rH   rI   )rJ   r  r  rK   s      rL   rI   MofNCompleteColumn.__init__F  s    "l3rN   r   r  rO   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.downloadrq  )r   rG   r{   r   r   r9   r  )rJ   r   rG   r{   total_widths        rL   r#  MofNCompleteColumn.renderJ  sa    '	#'::#9DJJs#e*oa((8@%
 	
rN   )r  )/N)rj   rk   rl   rm   rn   r   r    r7   rI   r9   r#  rq   rr   rs   s   @rL   r  r  :  s=    	4# 48F;K 4 4
6 
d 
 
rN   r  c                   Z   ^  \ rS rSrSr SS\S\\   SS4U 4S jjjrSS	S\	4S
 jr
SrU =r$ )r  iU  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.
Nbinary_unitsr  rO   c                 ,   > Xl         [        TU ]	  US9  g r1  )r  rH   rI   )rJ   r  r  rK   s      rL   rI   DownloadColumn.__init__\  s     )l3rN   r   r  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  rM  r  rq  )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.renderb  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)rj   rk   rl   rm   rn   r   r    r7   rI   r9   r#  rq   rr   rs   s   @rL   r  r  U  sN     LP4 48@8H4	4 4!6 !d ! !rN   r  c                   *    \ rS rSrSrSSS\4S jrSrg)	TransferSpeedColumni  z&Renders human readable transfer speed.r   r  rO   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.speedrq  z/s)r  r:  r9   r+   r  r   )rJ   r   r:  r  s       rL   r#  TransferSpeedColumn.render  sR    ##1tzz=#899%%c%j1
zl"%-BCCrN   r   Nrw  r   rN   rL   r  r    s    0D6 Dd DrN   r  c                   0    \ rS rSr% Sr\\S'    \\S'   Srg)ProgressSamplei  z$Sample of progress for a given time.r%  rG   r   N)rj   rk   rl   rm   rn   ro   r,  rq   r   rN   rL   r  r    s    .$rN   r  c                      \ rS rSr% Sr\\S'    \\S'    \\	   \S'    \	\S'    \
\S'    Sr\\	   \S	'    S
r\\S'    \" \S9r\\\4   \S'    \" SSSS9r\\	   \S'    \" SSSS9r\\	   \S'    Sr\\	   \S'    \" S SSS9r\\   \S'   \" S\S9r\\S'    S\	4S jr\S\4S j5       r\S\\	   4S j5       r\S\\	   4S j5       r\S\4S j5       r \S\	4S j5       r!\S\\	   4S j5       r"\S\\	   4S  j5       r#S#S! jr$S"r%g)$r  i  z}Information regarding a progress task.

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

r!  rz   r{   rG   	_get_timeNrs  Tvisible)default_factory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  	_progress)r  r  _lockrO   c                 "    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   ri  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   rt  Task.elapsed  sC     ??">>%>>DOO33}}00rN   c                     U R                   SL$ )zCheck if the task has finished.N)rs  r\   s    rL   rG  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   minrh  )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rY   r   ).0samples     rL   	<genexpr>Task.speed.<locals>.<genexpr>   s     !Ov"2"2   )r  r  r  r%  iterr   r   )rJ   rA   
total_timeiter_progresstotal_completedr:  s         rL   r:  
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)rG  r:  r  r   )rJ   r:  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  clearrs  r  r\   s    rL   _resetTask._reset  s"    !"rN   )r  rs  ri   )&rj   rk   rl   rm   rn   r;   r,  r   r    ro   GetTimeCallablers  r  r   r   dictr  r   r   r  r  r  r  r   r  r   r  r   r   ri  r  rt  rG  r  r:  r  r  rq   r   rN   rL   r  r    s    	JG'E?>*+%)M8E?)(GTJ"48FDcN8?"'5u"MJMN!&t%e!LIxLN&*NHUO*>',2U(Iu^$  eU;E5; %   + + + +8E? + + 1% 1 1 .$ . . E   x  "   #rN   r  c                   R   \ rS rSrSrSSSSSSSSSSS.
S	\\\4   S
\\	   S\
S\S\S\
S\
S\
S\\   S\
S\
SS4S jjr\S\\S4   4S j5       r\S\	4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\
4S j5       rSQS jrSQS jrSRS jrS\\\      S \\   S!\\   SS4S" jr    SSS#\\ \!   \"\!   4   S$\\   S%\\   S&\S'\S\ \!   4S( jjr# STSS)S*.S+\$S$\\%   S%\\   S&\S\$4
S, jjjr&\'RP                      SUSSS)S-.S+\\S.\)4   S/\*S0   S1\%S2\\   S3\\   S4\\   S$\\%   S%\\   S&\S\$4S5 jjj5       r+\'RP                      SUSSS)S-.S+\\S.\)4   S/\\*S6   \*S7   4   S1\%S2\\   S3\\   S4\\   S$\\%   S%\\   S&\S\,4S8 jjj5       r+     SVSSS)S-.S+\\S.\)4   S/\\*S0   \*S7   \*S6   4   S1\%S2\\   S3\\   S4\\   S$\\%   S%\\   S&\S\\$\,4   4S9 jjjr+S%\SS4S: jr-S%\SS4S; jr.SSSSSSS<.S%\S$\\   S=\\   S>\\   S&\\   S?\\
   S@\
SA\/SS4SB jjr0SSSCSSSD.S%\SE\
S$\\   S=\%S?\\
   S&\\   SA\/SS4SF jjr1SWS%\S>\SS4SG jjr2SQSH jr3S\44SI jr5S\ \4   4SJ jr6SK\ \   S\74SL jr8S\44SM jr9    SXS&\SE\
S$\\   S=\%S?\
SA\/S\4SN jjr:S%\SS4SO jr;SPr<g)YrB   i  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.
NTrt   g      >@F)
r}   r|   r   speed_estimate_periodr~   redirect_stdoutredirect_stderrr   r   expandr   r}   r|   r   r  r~   r  r  r   r   r  rO   c       
   
         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  liver}   r   printlog)rJ   r}   r|   r   r  r~   r  r  r   r   r  r   s               rL   rI   Progress.__init__)  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_columnsM  s(    2 ABK !	
 	
rN   c                 .    U R                   R                  $ rY   )r  r}   r\   s    rL   r}   Progress.consolel  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.tasksp  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_idsv  s*     ZZ((*+ ZZr#  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rY   )rG  )r  r   s     rL   r  $Progress.finished.<locals>.<genexpr>  s     F1E}}1Er  )r  r  allr   r\   s    rL   rG  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)rQ   N)r   r  r[   r\   s    rL   r[   Progress.start  s     ||IIOODO) rN   c                     U R                   R                  5         U R                  R                  (       d  U R                  R	                  5         gg)zStop the progress display.N)r  r   r}   is_interactiver  r\   s    rL   r   Progress.stop  s2    		||**LL  +rN   c                 &    U R                  5         U $ rY   rZ   r\   s    rL   r]   Progress.__enter__  r_   rN   r`   ra   rb   c                 $    U R                  5         g rY   )r   rf   s       rL   rg   Progress.__exit__  s     			rN   ry   r{   rC   rz   rD   c              #     #    Uc  [        [        U5      5      =(       d    SnUc  U R                  XBS9nOU R                  X2S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.

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r{   r*   )
ro   r   add_taskrT   r  r|   r?   rG   rR   rQ   )
rJ   ry   r{   rC   rz   rD   track_threadvaluerR   rQ   s
             rL   r   Progress.track  s     ( =+h/08DE?mmKm=GKKK-99!!d];|%EK **a/* & <;
 llGllG!#	 " <;s   A*C,#C?C
CCr   )rC   rz   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'r7  Fr   )r  r  r{   
ValueErrorr8  rT   r   )rJ   r  r{   rC   rz   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{   rC   rz   r  r   r  r  r	  r
  r  c                    g rY   r   
rJ   r  r   r  r	  r
  r  r{   rC   rz   s
             rL   r  Progress.open       	rN   r  r  c                    g rY   r   rB  s
             rL   r  rC    rD  rN   c                   SR                  [        USS95      n
U
S;  a  [        SR                  U5      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.
r6  F)reverse)brr  r  zinvalid mode {!r}r*   rH  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/Or7  r  )r  Tr=  )r  r  )r	  r
  r  line_buffering)re   sortedr>  rZ  warningswarnRuntimeWarningr   st_sizer8  rT   ior  r   TextIOWrapper)rJ   r  r   r  r	  r
  r  r{   rC   rz   _moderI  r   r   s                 rL   r  rC    s"   B tU34))077=>> #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   rC   r   s      rL   
start_taskProgress.start_task[  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   rC   r   r$  s       rL   	stop_taskProgress.stop_taski  sB     ZZ;;w'D==?L&".)N ZZs   9A
A)r{   rG   rR   rz   r  rQ   rG   rR   r  rQ   r  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  rz   r  r  rT   r   r  r  popleftr%  appendr  rs  rt  rQ   )rJ   rC   r{   rG   rR   rz   r  rQ   r  r   completed_startupdate_completedr$  old_sample_timer  rY  s                   rL   rT   Progress.updatex  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[   r{   rG   r  rz   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  rz   rs  rQ   )
rJ   rC   r[   r{   rG   r  rz   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  rY  r%  r   rZ  r  r{   rs  rt  r:  r  )
rJ   rC   rR   r$  r   r[  r\  r]  r  rY  s
             rL   rR   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   r  
is_startedrQ   r\   s    rL   rQ   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   rh  Progress.get_renderables  s     %%djj1s   !#r!  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)TrT  N)r?  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)rY  N)r?  r   rZ  )r  columnr   s     rL   r  rr    sB       '3F  *&#66 #MMtM4!'. '3s   9<)r   r8   gridr  r  add_row)rJ   r!  table_columnsrl  r   s       @rL   rk  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  rS  r;   r   rQ   )	rJ   rz   r[   r{   rG   r  r  r   new_task_indexs	            rL   r8  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   rC   s     rL   remove_taskProgress.remove_taskZ  s!     ZZG$ ZZs   $
2)r  r  r  r   r   r  r   r  r  r  r  ri   )rO   rB   )NN
Working...皙?rY   r   NNNr  r   NNN)r*   )Tr  r   T)=rj   rk   rl   rm   rn   r&   r   r  r    r-   r   ro   r
  rI   r  r#   r  r   r}   r   r  r!  r;   r&  rG  r[   r   r]   r$   rp   r   rg   r   r<   r!   r   r   r   r  typingoverloadr   r)   r  r"   rS  rV  r   rT   r`  rR   rQ   r0   r  rh  r8   rk  r{  r8  r  rq   r   rN   rL   rB   rB     s   $ &*!$&'+ $ $.2"$^+,"$ '""$ 	"$
 ""$  %"$ "$ "$ "$ ?+"$ "$ "$ 
"$H 
E.#*=$> 
 
< ! ! ! .tDz . .
 ,$v, , ,
 G$ G G*
!4./ -( '	
 
 "&$('"'.0FFG' ' &!	'
 ' ' 
,	'X  $(@
 %)'(@(@ }(@
 &!(@ (@ 
(@T __
 "& $!%  $$('C%/0 dm 	
 3-  # } &!  
  __
 "& $!%  $$('C%/0 GCL'$-/0 	
 3-  # } &!  
 $ CF"& $!%K  $$('KC%/0K GDM74='#,>?K 	K
 3-K K #K }K &!K K 
x	 KZ2& 2T 2* *D *& "&%)#'%)"&;; 	;
 E?; %; c]; $; ; ; 
;B !%"&%)%% 	%
 % % $% c]% % 
%N1v 1 1d 1< 
 
.!9 
htn  B). ) !&)) ) 	)
 ) ) ) 
)V%6 %d %rN   rB   __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)typerH  z	Syntax...zGive it a try!)cycle)record)r}   r~   z[red]Downloadingr}  r7  z[green]Processingz[yellow]Thinkingr  r   g333333?g{Gz?d   )r  NTNFNrt   ru   rv   rw   rx   r  FTr  r  )rO  sysr  rK  abcr   r   collectionsr   dataclassesr   r   datetimer	   r
   r   mathr   r   operatorr   osr   r   	threadingr   r   r   typesr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   version_infor)   pip._vendor.typing_extensionsr6  r+   r,   r}   r-   r.   r/   r0   rR  r1   jupyterr2   r  r3   progress_barr4   r>  r5   r   r6   rl  r7   r8   rH  r9   r:   r   r;   r<   ro   r
  r=   r?   r   r   r   r   r   r  r  r   r  r  r.  r8  r   r   rm  r   r   r  r  r  r  r  r  r  rB   rj   randomtimepanelr  ruler  syntaxr  rw  progress_renderables	itertoolsr  examplesr  rA   r8  task1task2task3rG  rT   sleeprandintr  r   r   rN   rL   <module>r     sT	   	 
   #  (  .      * *     * v5 # B B $ !  %      	3	~&2u9% ^^D&(+%6 %T $!!%.2 "! . .(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
La,i a,H8>"%wr{ 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*
_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*l'1S '1T~ "/N /d <'
 '
T	: 	:E EP-,. -,`:^ :@. @
 
6.^ .b	D. 	D%Z % z# z# z#zI	%| I	%X 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   B:U
U