8fC+ ddlZddlZddlZddlZddlmZmZddlmZddl m Z m Z ddl m Z ddlmZmZddlmZddlmZdd lmZdd lmZmZdd lmZmZmZdd lmZdd lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ej0dkrddlm1Z1nddl2m1Z1ddl3m4Z4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:ddl;mZ>ddl?m@Z@ddlAmBZBddlCmDZDddlEmFZFddlGmHZHmIZIddlJmKZKmLZLe(deMZNe.dZOe gePfZQej.de+eZRGddeZS dd)e/e*eOe%eOfd*eTd+e)ePd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd5ePd6eUd7eUd8e%eOf d9ZVGd:d;eeZWGd<d=e!eRe$eRZXd>d!dd"dd#d$d%d&d'd"d? d@ed+eMd*eTd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd6eUd8e!efdAZYejZ ddd>d!dd"dd#d$d%d&d'd"dC d@e/eTdDe[fdEe/e1dFe1dGfdHeMdIe)eTdJe)eTdKe)eTd+e)eMd*eTd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd6eUd8e!e+f&dLZ\ejZ ddd>d!dd"dd#d$d%d&d'd"dC d@e/eTdDe[fdEe1dMdHeMdIe)eTdJe)eTdKe)eTd+e)eMd*eTd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd6eUd8e!ef&dNZ\ ddd>d!dd"dd#d$d%d&d'd"dC d@e/eTdDe[fdEe/e1dMe1dFe1dGfdHeMdIe)eTdJe)eTdKe)eTd+e)eMd*eTd,eUd-e)e7d.eUd/e)e gePfd0ePd1eFd2eFd3eFd4eFd6eUd8e/e!ee!e+ff&dOZ\GdPdQeZ]GdRdSe]Z^GdTdUe]Z_GdVdWe]Z`GdXdYe]ZaGdZd[e]ZbGd\d]e`ZcGd^d_e]ZdGd`dae]ZeGdbdce]ZfGdddee]ZgGdfdge]ZhGdhdie]ZiGdjdke'Zje GdldmZkGdndoe>ZlemdpkrddlnZnddloZoddqlpmqZqddrlrmsZsddsltmuZuddtlGmIZIeududvd!wZteIdxdydzZGeGvd{d|d}d~eqddeGdddddetesdg ZwddlxmyZyeyewZze7d!Z6ele_gel{ebRe6d"d5Z|e|}ddZ~e|}ddZe|}ddZe|jsxe|e~de|edeojdenjdddkre|eeze|jxddddS#1swxYwYdSdS)N)ABCabstractmethoddeque) dataclassfield) timedelta) RawIOBaseUnsupportedOperation)ceil)mmap) length_hint)PathLikestat)EventRLockThread) TracebackType)AnyBinaryIOCallableContextManagerDequeDictGenericIterableList NamedTupleNewTypeOptionalSequenceTextIOTupleTypeTypeVarUnion))Literal)filesize get_console)ConsoleGroup JustifyMethodRenderableType) Highlighter) JupyterMixin)Live) ProgressBar)Spinner) StyleType)ColumnTable)TextTextTypeTaskID ProgressType_IceZdZdZdddddeffd Zdd Zdd Zd ee e d ee dee dd fdZ xZ S) _TrackThreadz)A thread to periodically update progress.progressProgresstask_idr; update_periodc||_||_||_t|_d|_t dS)Nr)r@rBrCrdone completedsuper__init__)selfr@rBrC __class__s y/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/rich/progress.pyrHz_TrackThread.__init__BsG   *GG  returnNc |j}|jj}|j}d}|jj}||s)|j}||kr||||z |}||)|j|j|jddS)NrT)rFrefresh)rBr@advancerCrEwaitrFupdate)rIrBrPrClast_completedrQrFs rKrunz_TrackThread.runKs,-'* y~$}%% +I**^!;<< ? ?@@UW  NN --'     * 5 5 5 d ; ; ;     !-3H   >> E{-"                           s1 BB"%B"c eZdZdZ d*dedddededd f d Zd+d Zd e e e d e e de e dd fdZ defdZdefdZedefdZdefdZdefdZedefdZedefdZdefdZdefdZdefdZd,dedefdZdeeee ffdZ!d,dedefdZ"d,d ede#efd!Z$d-d"Z%d.d$ed%edefd&Z&defd'Z'd(e(defd)Z)d S)/_Readerz9A reader that tracks progress while it's being read from.Thandler@rAtask close_handlerMNcL||_||_||_||_d|_dSNF)rr@rr_closed)rIrr@rrs rKrHz_Reader.__init__s,    ( rLc8|j|SrV)rrZrYs rKrZz_Reader.__enter__s  rLr\r]r^c.|dSrV)closerbs rKrcz_Reader.__exit__s rLc|SrVrYs rK__iter__z_Reader.__iter__s rLct|j}|j|jt ||SNrP)nextrr@rPrlen)rIlines rK__next__z_Reader.__next__s9DK   diT;;; rLc|jSrV)rrYs rKclosedz_Reader.closeds |rLc4|jSrV)rfilenorYs rKrz_Reader.fileno{!!###rLc4|jSrV)risattyrYs rKrz_Reader.isattyrrLc|jjSrV)rmoderYs rKrz _Reader.mode {rLc|jjSrV)rnamerYs rKrz _Reader.namerrLc4|jSrV)rreadablerYs rKrz_Reader.readable{##%%%rLc4|jSrV)rseekablerYs rKrz_Reader.seekablerrLcdSrrrYs rKwritablez_Reader.writablesurLsizec|j|}|j|jt ||Sr)rreadr@rPrr)rIrblocks rKrz _Reader.reads?   && diU<<< rLbc||j|}|j|j||Sr)rreadintor@rPr)rIrns rKrz_Reader.readintos9 K  # # di333rLc|j|}|j|jt ||Sr)rreadliner@rPrr)rIrrs rKrz_Reader.readlines?{##D)) diT;;; rLhintc |j|}|j|jt t t||Sr)r readlinesr@rPrsummapr)rIrliness rKrz_Reader.readlinessI %%d++ diSe__1E1EFFF rLcT|jr|jd|_dS)NT)rrrrrYs rKrz _Reader.closes,   K      rLroffsetwhencec~|j||}|j|j||S)NrF)rseekr@rRr)rIrrposs rKrz _Reader.seeks;kvv.. TY#666 rLc4|jSrV)rtellrYs rKrz _Reader.tell s{!!!rLsc td)Nwrite)r )rIrs rKrz _Reader.write s"7+++rL)T)rMr)rrd)r)*rerfrgrhrr;boolrHrZr r$rjrrcrbytesrpropertyrintrrstrrrrrrrr& bytearray memoryviewr rrrrrrrrrrrLrKrrsCC"            4 ./-('   (% X$$$$$$$$$$ c   X  c   X &$&&&&&$&&&&$e % :t ;< S% c4;  3C "c"""",s,s,,,,,,rLrczeZdZdZdddeddfdZdefdZd eee d ee d ee ddfd Z dS) _ReadContextzEA utility class to handle a context for both a reader and a progress.r@rAreaderrMNc"||_||_dSrV)r@r)rIr@rs rKrHz_ReadContext.__init__s    rLcf|j|jSrV)r@rXrrZrYs rKrZz_ReadContext.__enter__s* {$$&&&rLr\r]r^cp|j|j|||dSrV)r@stoprrcrbs rKrcz_ReadContext.__exit__s8  Xw77777rL) rerfrgrhr=rHrZr r$rjrrcrrLrKrrsOO!!R!D!!!!'2''''84 ./8-(8' 8  888888rLr Reading...) rurwrxryrzr{r|r}r~rrfilec "|rtdgng} | t|| | | tt ft | |||||pd| d}||||}t||S)aRead 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. rrrnr)rvru)rrrDownloadColumnrrA wrap_filer)rrvrurwrxryrzr{r|r}r~rrrr@rs rKrr&sJEPW> ? ?@@UW  NN --'         ! !     !-3H  E{  K KF & ) ))rLr) rvrurwrxryrzr{r|r}r~rr PathLike[str]rrtr bufferingencodingerrorsnewlinec dSrVrrrrrrrrvrurwrxryrzr{r|r}r~rrs rKopenrg , DrLrbc dSrVrrs rKrrrrLc ,|rtdgng}|t| |||tt ft ||| | | | pd|d}|||||||||}t||S)aRead 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. rrrnr)rrrrrrvru)rrrrrrArr)rrrrrrrvrurwrxryrzr{r|r}r~rrrr@rs rKrrsbEPW> ? ?@@UW  NN --'         ! !     !-3H]]   F & ) ))rLceZdZUdZdZeeed<d deeddfdZ defdZ dd de fd Z e dd de fd ZdS) ProgressColumnz3Base class for a widget to use in progress display.N max_refresh table_columnrMc0||_i|_d|_dSrV) _table_column_renderable_cache _update_time)rIrs rKrHzProgressColumn.__init__s )MO-1rLc,|jp tS)z.Get a table column, used to build tasks table.)rr7rYs rKget_table_columnzProgressColumn.get_table_columns!-VXX-rLrTaskc|}|j>|js7 |j|j\}}||jz|kr|Sn#t $rYnwxYw||}||f|j|j<|S)aCalled 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). )rzrrFridKeyErrorrender)rIr current_time timestamp renderables rK__call__zProgressColumn.__call__s}}   ' ' &(,(>tw(G% :t//,>>%%?     [[&& +7*Dtw'sA AAcdS)z"Should return a renderable object.NrrIrs rKrzProgressColumn.rendersrLrV)rerfrgrhrr ri__annotations__r7rHrr0rrrrrLrKrrs==#'K%'''22Xf%522222 .&....V.161n111^111rLrcReZdZdZ d dddedeeffdZdd d efd ZxZ S) RenderableColumnzA column to insert an arbitrary column. Args: renderable (RenderableType, optional): Any renderable. Defaults to empty string. NrrrcZ||_t|dSNr )rrGrH)rIrrrJs rKrHzRenderableColumn.__init__ s-% l33333rLrrrMc|jSrV)rrs rKrzRenderableColumn.render&s rL)r ) rerfrgrhr0r r7rHrrkrls@rKr r s,.4SW444(4@H@P444444 6nrLr c eZdZdZ ddedeed ed ed ee f fd Z dded eed eddfdZ ddde fdZ xZS) SpinnerColumnaA 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 " ". dotsprogress.spinner? N spinner_namer|speed finished_textrct||||_t|trt j|n||_t|dS)Nr|rr ) r5spinner isinstancerr9 from_markuprrGrH)rIrr|rrrrJs rKrHzSpinnerColumn.__init__4sm|5FFF --- D ] + + +  l33333rL spinner_stylerMc4t||||_dS)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. rN)r5r)rIrrrs rK set_spinnerzSpinnerColumn.set_spinnerDs|=NNN rLrrcz|jr|jn+|j|}|SrV)finishedrrrrz)rIrtexts rKrzSpinnerColumn.renderSs=} 6D  $$T]]__55  rL)rrrrN)rr)rerfrgrhrr r6rir:r7rHr!r0rrkrls@rKrr*s#%7"%)- 444 "4 4  4 v& 444444&.@ O O O * O O  O O O O6nrLrcteZdZdZ ddededed ed ee d ee d dffd Z ddd e fdZ xZS)rzA column containing text.noneleftTN text_formatr|justifymarkup highlighterrrMc||_||_||_||_||_t |ptddS)NTno_wrapr )r(r)r|r*r+rGrHr7)rIr(r|r)r*r+rrJs rKrHzTextColumn.__init___s['&-   & l&JfT6J6J6JKKKKKrLrrc|j|}|jr"tj||j|j}nt||j|j}|jr|j||SNr)r|r)) r(formatr*r9rr|r)r+ highlight)rIr_textr$s rKrzTextColumn.renderos ''T'22 ; G#ET\RRRDDTZFFFD   -   & &t , , , rL)r&r'TNN)rerfrgrhrr6r/rr r1r7rHr9rrkrls@rKrr\s## "!'-1)-LLLL L  L k* Lv&L LLLLLL 6drLrcveZdZdZ ddeed ed ed ed ed eeddffd Zddde fdZ xZ S)raRenders 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". (rorprqrrN bar_widthr|r}r~rrrMc||_||_||_||_||_t |dSr)r7r|r}r~rrGrH)rIr7r|r}r~rrrJs rKrHzBarColumn.__init__sL# ,,& l33333rLrrc  t|jtd|jndtd|j|jdntd|j|j ||j|j|j |j  S)z&Gets a progress bar widget for a task.Nrr*) rvrFwidthpulseanimation_timer|r}r~r) r4rvmaxrFr7startedrzr|r}r~rrs rKrzBarColumn.renders(, (>#a$$$D!T^,,.0$$c!T^6L6Ll"==??*..(    rL)r6rorprqrrN) rerfrgrhr rr6r7rHr4rrkrls@rKrrzs$&%$2$2!,)-44C=44" 4 " 4  4v&4 444444  6  k         rLrc"eZdZdZdddefdZdS)TimeElapsedColumnzRenders time elapsed.rrrMc|jr|jn|j}|tddSt t dt |}tt|dS)zShow time elapsed.N-:--:--progress.elapsedr|r)seconds)r# finished_timeelapsedr9r r=rr)rIrrGdeltas rKrzTimeElapsedColumn.rendersk(, G$$$4< ? );<<< <#aW"6"6777CJJ&89999rLNrerfrgrhr9rrrLrKr@r@s<:6:d::::::rLr@ceZdZdZ dd ed ed ed ed edee dee deddffd Z e dee defdZdddefdZxZS)raShow task progress as a percentage. Args: text_format (str, optional): Format for percentage display. Defaults to "[progress.percentage]{task.percentage:>3.0f}%". text_format_no_percentage (str, optional): Format if percentage is unknown. Defaults to "". style (StyleType, optional): Style of output. Defaults to "none". justify (JustifyMethod, optional): Text justification. Defaults to "left". markup (bool, optional): Enable markup. Defaults to True. highlighter (Optional[Highlighter], optional): Highlighter to apply to output. Defaults to None. table_column (Optional[Column], optional): Table Column to use. Defaults to None. show_speed (bool, optional): Show speed if total is unknown. Defaults to False. -[progress.percentage]{task.percentage:>3.0f}%r r&r'TNFr(text_format_no_percentager|r)r*r+rrrMc r||_||_t||||||dS)N)r(r|r)r*r+r)rLrrGrH) rIr(rLr|r)r*r+rrrJs rKrHzTaskProgressColumn.__init__sR*C&$ ##%      rLrc|tddStjt|gdd\}}||z }t|d|ddS) zRender the speed in iterations per second. Args: task (Task): A Task object. Returns: Text: Text object containing the task speed. Nr zprogress.percentagerD)r u×10³u×10⁶u×10⁹u×10¹²z.1fz it/s)r9r+pick_unit_and_suffixr)clsrunitsuffix data_speeds rK render_speedzTaskProgressColumn.render_speedsx ="7888 84 JJ < < <   f T\ z44v444YeLLL L"#i.."55,,w < A A"666666II @@@W@@@7@@@IIU++++rL)FFN) rerfrgrhrrr r7rHr9rrkrls@rKrrsK&+)- 444 $4v& 444444,6,d,,,,,,,,rLrc"eZdZdZdddefdZdS)FileSizeColumnzRenders completed filesize.rrrMcptjt|j}t |dS)Show data completed.zprogress.filesizerD)r+decimalrrFr9rIr data_sizes rKrzFileSizeColumn.render+s0$S%8%899 I%89999rLNrIrrLrKriri(s<%%:6:d::::::rLric"eZdZdZdddefdZdS)TotalFileSizeColumnzRenders total filesize.rrrMc|j&tjt|jnd}t |dS)rkNr zprogress.filesize.totalrD)rvr+rlrr9rms rKrzTotalFileSizeColumn.render4s;9=9OH$S__555UW I%>????rLNrIrrLrKrprp1sD!!@6@d@@@@@@rLrpcJeZdZdZd dedeeffd Zddd efd Z xZ S) MofNCompleteColumnaHRenders completed count/total, e.g. ' 10/1000'. Best for bounded tasks with int quantities. Space pads the completed count so that progress length does not change as task progresses past powers of 10. Args: separator (str, optional): Text to separate completed and total values. Defaults to "/". /N separatorrcZ||_t|dSr)rurGrH)rIrurrJs rKrHzMofNCompleteColumn.__init__Fs+" l33333rLrrrMct|j}|jt|jnd}tt |}t ||d|j|dS)zShow completed/total.N?raprogress.downloadrD)rrFrvrrr9ru)rIrrFrv total_widths rKrzMofNCompleteColumn.renderJst'' #':#9DJs#e**oo + @ @ @ @ @ @ @%    rL)rtN) rerfrgrhrr r7rHr9rrkrls@rKrsrs:s  44#48F;K444444 6 d        rLrscPeZdZdZ d dedeeddffd Zdd defd Z xZ S) rzRenders file size downloaded and total, e.g. '0.5/2.3 GB'. Args: binary_units (bool, optional): Use binary units, KiB, MiB etc. Defaults to False. FN binary_unitsrrMcZ||_t|dSr)r|rGrH)rIr|rrJs rKrHzDownloadColumn.__init__\s.) l33333rLrrct|j}|jt|jn|}|jrt j|gdd\}}nt j|gdd\}}|dkrdnd}||z }|d|d }|j"t|j} | |z } | d|d } nd } |d | d |} t | d } | S)z.Calculate common unit for completed and total.N) rKiBMiBGiBTiBPiBEiBZiBYiBi) rkBMBGBTBPBEBZBYBrOr*rz,.frxrtrryrD)rrFrvr|r+rPr9)rIrrF unit_and_suffix_calculation_baserRrS precisioncompleted_ratio completed_strrv total_ratio total_strdownload_status download_texts rKrzDownloadColumn.renderbs+''  $z5C OOO9 )   #80QQQLD&& $80IIILD& AA #d**;i;;;; : ! OOE$,K&7)7777III*AAYAAAA_4GHHH rL)FN) rerfrgrhrr r7rHr9rrkrls@rKrrUsLP44 48@8H4 444444 !6!d!!!!!!!!rLrc"eZdZdZdddefdZdS)TransferSpeedColumnz&Renders human readable transfer speed.rrrMc|jp|j}|tddStjt |}t|ddS)zShow data transfer speed.Nrxzprogress.data.speedrDz/s)rWrr9r+rlr)rIrrrTs rKrzTransferSpeedColumn.renders]#1tz =#8999 9%c%jj11 z%%%-BCCCCrLNrIrrLrKrrsD00D6DdDDDDDDrLrc*eZdZUdZeed< eed<dS)ProgressSamplez$Sample of progress for a given time.rrFN)rerfrgrhrir rrLrKrrs3..$$rLrceZdZUdZeed< eed< eeed< eed< e ed< dZ eeed< d Z e ed < e e Zeeefed < e dd d Zeeed< e dd d Zeeed< dZeeed< e dd d Zeeed<e d eZeed< defdZede fdZedeefdZedeefdZede fdZedefdZ edeefdZ!edeefdZ"d!d Z#dS)"rzInformation regarding a progress task. This object should be considered read-only outside of the :class:`~Progress` class. rrurvrF _get_timeNrFTvisible)default_factoryfieldsF)defaultinitrepr start_time stop_timerWc"tdS)NrO)maxlenrrrLrKz Task.sT 2 2 2rL)rrr _progress)rr_lockrMc*|S)z(float: Get the current time, in seconds.)rrYs rKrzz Task.get_times~~rLc|jduS)z#bool: Check if the task as started.N)rrYs rKr>z Task.startedsd**rLc2|jdS|j|jz S)zPOptional[float]: Get the number of steps remaining, if a non-None total was set.N)rvrFrYs rK remainingzTask.remainings  : 4zDN**rLcx|jdS|j|j|jz S||jz S)z]Optional[float]: Time elapsed since task was started, or ``None`` if the task hasn't started.N)rrrzrYs rKrGz Task.elapseds= ? "4 > %>DO3 3}}00rLc|jduS)zCheck if the task has finished.N)rFrYs rKr#z Task.finisheds!--rLcx|jsdS|j|jz dz}tdtd|}|S)zOfloat: Get progress of task as a percentage. If a None total was set, returns 0Y@)rvrFminr=)rIrFs rK percentagezTask.percentagesEz 3^dj0E9 s3 2233 rLc^|jdS|j5|j}|s ddddS|dj|djz }|dkr ddddSt |}t |t d|D}||z }|cdddS#1swxYwYdS)z=Optional[float]: Get the estimated speed in steps per second.Nrrc3$K|] }|jV dSrVr).0samples rK zTask.speed..s%!O!Ov&"2!O!O!O!O!O!OrL)rrrriterrr)rIr@ total_time iter_progresstotal_completedrs rKrz Task.speedsI ? "4 Z  ~H         ""/(1+2GGJQ        !NNM    !!O!O!O!O!OOOO#j0E                  s B""B"=B""B&)B&ch|jrdS|j}|sdS|j}|dSt||z }|S)zJOptional[float]: Get estimated time to completion, or ``None`` if no data.rN)r#rrr )rIrrestimates rKrbzTask.time_remainingsP = 3  4N  4 E)**rLcT|jd|_d|_dS)zReset progress.N)rclearrFrWrYs rK_resetz Task._resets, !"rLrd)$rerfrgrhr;r rr riGetTimeCallablerFrrrdictrrrrrrWrrrrrrzrr>rrGr#rrrbrrrLrKrrs JJJG' E?>*+%)M8E?)))(GTJ"U4888FDcN888?"'%5u"M"M"MJMMMN!&t%e!L!L!LIxLLLN&*NHUO***>',u22U(((Iu^$5eU;;;E5;;; %    ++++X++8E?+++X+ 1%111X1.$...X.EXxX"    X ######rLrc`eZdZdZddddddddddd deeefd eed e d e d e d e de de dee de de ddfdZ e deedffdZedefdZedeefdZedeefdZede fdZdTdZdTdZdUdZdeeedeed eeddfd!Z dVd$eee e!e fd%ee d&eed'ed(e dee f d)Z" dWdd*d+d,e#d%ee$d&eed'ede#f d-Z%e&j' dXddd*d/d,eed0e(fd1e)d2d3e$d4eed5eed6eed%ee$d&eed'ede#fd7Z*e&j' dXddd*d/d,eed0e(fd1ee)d8e)d9fd3e$d4eed5eed6eed%ee$d&eed'ede+fd:Z* dYddd*d/d,eed0e(fd1ee)d2e)d9e)d8fd3e$d4eed5eed6eed%ee$d&eed'edee#e+ffd;Z*d&eddfd<Z,d&eddfd=Z-ddddddd>d&ed%ee d?ee d@ee d'eedAee dBe dCe.ddfdDZ/dddEdddFd&edGe d%ee d?e$dAee d'eedCe.ddfdHZ0dZd&ed@e ddfdJZ1dTdKZ2de3fdLZ4dee3fdMZ5dNeede6fdOZ7de3fdPZ8 d[d'edGe d%ee d?e$dAe dCe.defdRZ9d&eddfdSZ:dS)\rAaRenders 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. NTrng>@F) rxrwr{speed_estimate_periodryredirect_stdoutredirect_stderrrzrexpandrrxrwr{rryrrrzrrrMc |dks Jdt|_| p||_||_| |_| |_i|_td|_ t|p t||||||j |_ |p |jj|_|jj|_|jj|_dS)Nrzrefresh_per_second must be > 0)rxrwr{ryrrget_renderable)rrget_default_columnsrrrr_tasksr; _task_indexr3r,rliverxrzprintlog) rIrxrwr{rryrrrzrrrs rKrHzProgress.__init__)s"A%%%'G%%%WW <$":":"<"< %:"  *, #)!99,{}}%1++.    !9DL$9 \' <#rL.cptdtttfS)aGet 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)rrrr)rQs rKrzProgress.get_default_columnsMs32 A B B KK   ! !   rLc|jjSrV)rrxrYs rKrxzProgress.consolels y  rLc|j5t|jcdddS#1swxYwYdS)zGet a list of Task instances.N)rlistrvaluesrYs rKtaskszProgress.taskspsZ . . **,,-- . . . . . . . . . . . . . . . . . . &;??c|j5t|jcdddS#1swxYwYdS)zA list of task IDs.N)rrrkeysrYs rKtask_idszProgress.task_idsvsZ , , ((**++ , , , , , , , , , , , , , , , , , ,rc|j5|js ddddStd|jDcdddS#1swxYwYdS)z'Check if all tasks have been completed.NTc3$K|] }|jV dSrV)r#)rrs rKrz$Progress.finished..s$FFt}FFFFFFrL)rrallrrYs rKr#zProgress.finished|sZ G G;  G G G G G G G GFF1C1C1E1EFFFFF G G G G G G G G G G G G G G G G G Gs A/AA!AcN|js|jddSdS)zStart the progress display.T)rON)rrrXrYs rKrXzProgress.starts2| * IOODO ) ) ) ) ) * *rLc|j|jjs|jdSdS)zStop the progress display.N)rrrxis_interactiverrYs rKrz Progress.stopsE |* ! L    ! !rLc.||SrVrWrYs rKrZzProgress.__enter__r[rLr\r]r^c.|dSrV)rrbs rKrczProgress.__exit__s rLrmrsrtrvrBrurCc#K|tt|pd}||||}n||||jjrFt |||5}|D]}|V|xjdz c_ ddddS#1swxYwYdS|j}|j } |D]}|V||d| dS)aTrack 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. Nrvr*) riradd_taskrRrrwr?rFrPrO) rIrtrvrBrurC track_threadvaluerPrOs rKrzProgress.tracks^( =+h//008DE ?mmKum==GG KKuK - - - 9 ! dG];; 0|%00EKKK **a/***0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 lGlG!   ###   s1BB Br)rBrurc d}||}n3|1|j5|j|j}dddn #1swxYwY|td||||}n|||t |||dS)ajTrack 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'rFr)rrrv ValueErrorrrRr)rIrrvrBru total_bytess rKrzProgress.wrap_files.(,  KK   9 9"k'28  9 9 9 9 9 9 9 9 9 9 9 9 9 9 9  R  ?mmK{mCCGG KK{K 3 3 3tT7????s 044r)rvrBrurrrrrrrcdSrVr rIrrrrrrrvrBrus rKrz Progress.open  rLrrcdSrVrrs rKrz Progress.openrrLcVdt|d} | dvr"td||dk} | dkr#|dkrt jdt d }n!| d vr|d krtd |dkrd }|t|j}|| | |}n| ||tj |d|} t| ||d} |dvrtj| |||| S| S)a#Track progress while reading from a binary file. Args: path (Union[str, PathLike[str]]): The path to the file to read. mode (str): The mode to use to open the file. Only supports "r", "rb" or "rt". buffering (int): The buffering strategy to use, see :func:`io.open`. encoding (str, optional): The encoding to use when reading in text mode, see :func:`io.open`. errors (str, optional): The error handling strategy for decoding errors, see :func:`io.open`. newline (str, optional): The strategy for handling newlines in text mode, see :func:`io.open`. total (int, optional): Total number of bytes to read. If none given, os.stat(path).st_size is used. task_id (TaskID): Task to track. Default is new task. description (str, optional): Description of task, if new task is created. Returns: BinaryIO: A readable file-like object in binary mode. Raises: ValueError: When an invalid mode is given. r F)reverse)brrrzinvalid mode {!r}r*rzaline buffering (buffering=1) isn't supported in binary mode, the default buffer size will be usedr)rrrzcan't have unbuffered text I/ONrr)rTr)rr)rrrline_buffering)rasortedrr2warningswarnRuntimeWarningrst_sizerrRiorr TextIOWrapper)rIrrrrrrrvrBru_moderrrs rKrz Progress.openspBtU33344 ) ) )077==>> >#a D==Y!^^ Ms   II k ! !A~~ !ABBBa  =JJ&E ?mmKum==GG KKuK - - -ty999wTBBB ;  #!-   rLc|j5|j|}|j||_ddddS#1swxYwYdS)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)rrrrz)rIrBrs rK start_taskzProgress.start_task[sZ 2 2;w'D&"&--// 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2s.AA Ac|j5|j|}|}|j||_||_ddddS#1swxYwYdS)zStop a task. This will freeze the elapsed time on the task. Args: task_id (TaskID): ID of task. N)rrrzrr)rIrBrrs rK stop_taskzProgress.stop_taskisZ * *;w'D==??L&".)DN  * * * * * * * * * * * * * * * * * *s7A  AA)rvrFrPrurrOrFrPrrOrc |j5|j|} | j} |&|| jkr|| _| || xj|z c_||| _||| _||| _| j|| j| z } | } | |j z } | j }|j }|r.|dj | kr||r|dj | k| dkr#|t| | | j#| j| jkr| j | j| _dddn #1swxYwY|r|dSdS)aUpdate 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)rrrFrvrrurrrRrzrrpopleftrappendrrFrGrO)rIrBrvrFrPrurrOrrcompleted_startupdate_completedrold_sample_timerrs rKrRzProgress.updatexs0Z 2 2;w'D"nO Udj%8%8"  "')$!*&#. "& K  v & & &#~? ==??L*T-GGOI'G  ! 6 H H   ! 6 H H!##   >N!O!OPPP &Ndj00&.%)\"A 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2D   LLNNNNN  sD=EEEr)rXrvrFrrurXc P|}|j5|j|} | |r|nd| _||| _|| _||| _|r|| _||| _ d| _ dddn #1swxYwY| dS)aReset 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) rzrrrrrvrFrrrurFrO) rIrBrXrvrFrrurrrs rKresetzProgress.resets,}} Z & &;w'D KKMMM.3=llDO " &DN"&  %$ &#. !%D  & & & & & & & & & & & & & & & sABB B r*cl|}|j5|j|}|j}|xj|z c_|j|z }||jz }|j}|j} |r.|dj|kr| |r|dj|kt|dkr| t|dk| t|||j /|j|j kr|j |j |_ |j|_ddddS#1swxYwYdS)zAdvance task by a number of steps. Args: task_id (TaskID): ID of task. advance (float): Number of steps to advance. Default is 1. rrON)rzrrrFrrrrrrrrvrFrGrrW) rIrBrPrrrrrrrs rKrPzProgress.advances}} Z 1 1;w'D"nO NNg %NN#~? *T-GGOI'G  ! 6 H H   ! 6 H Hi..4'' i..4''   ^L:JKK L L L &Ndj00&.%)\"&*j#) 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1sDD))D-0D-cf|js'|jjr|jdSdSdS)z*Refresh (render) the progress information.N)rr is_startedrOrYs rKrOzProgress.refreshsF|  4 I           rLc<t|}|S)z*Get a renderable for the progress display.)r.get_renderables)rIrs rKrzProgress.get_renderablesD00223 rLc#FK||j}|VdS)z5Get a number of renderables for the progress display.N)make_tasks_tabler)rItables rKrzProgress.get_renderabless(%%dj11 rLrcd|jD}tj|d|jd}|D]$jr|jfd|jD%|S)zGet a table to render the Progress display. Args: tasks (Iterable[Task]): An iterable of Task instances, one per row of the table. Returns: Table: A table instance. c3K|]O}t|trtdn%|VPdS)Tr-N)rrr7rcopy)r_columns rKrz,Progress.make_tasks_table..sr  gs++7t$$$$--//4466       rL)rr*)paddingrc3K|]:}t|tr|n |V;dS)r1N)rrr2)rcolumnrs rKrz,Progress.make_tasks_table..sf # *&#66.FMMtM444!' rL)rr8gridrradd_row)rIr table_columnsrrs @rKrzProgress.make_tasks_table s   <     M6$+NNN  D|   '+l    rLcl|j5|cdddS#1swxYwYdS)z+Makes the Progress class itself renderable.N)rrrYs rK__rich__zProgress.__rich__*s} Z ) )&&(( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s )--rc n|j5t|j||||||j|j}||j|j<|r||j|j}t t|jdz|_dddn #1swxYwY||S)aAdd 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`. )rrrrr*N) rrrrzrrr;rrO) rIrurXrvrFrrrnew_task_indexs rKrzProgress.add_task/s0Z A A -j   D-1DK( ) 2 0111!-N%c$*:&;&;a&?@@D  A A A A A A A A A A A A A A A sBBBBcV|j5|j|=ddddS#1swxYwYdS)z]Delete a task if it exists. Args: task_id (TaskID): A task ID. N)rr)rIrBs rK remove_taskzProgress.remove_taskZszZ % % G$ % % % % % % % % % % % % % % % % % %s ""rd)rMrA)NNrmrsrVrNNNrrNNN)r*)TrrT);rerfrgrhr&rrr r-rrirrHrXr#rrrxrrrr;rr#rXrrZr$rjrrcrr<r!rrrrtypingoverloadrr)rr"rrrrRr rPrOr0rrr8rrrr"rrLrKrArAs  $&*!$&'+ $ $.2"$"$"$^+,"$'""$ "$ " "$ % "$"$"$"$?+"$"$"$ "$"$"$"$H E.#*=$>   [ <!!!!X!.tDz...X. ,$v,,,,X, G$GGGXG**** !!!! 4 ./-('   "&$('" ''.0FFG''&! '  '  ' , ''''X $(@ %)' (@(@(@(@}(@ &! (@  (@ (@(@(@(@T _ "& $!%   $$('    C%/0  dm    3-    #  }  &!         _   _ "& $!%   $$('    C%/0  GCL'$-/0    3-    #  }  &!         _  $CF"& $!%K $$('KKKC%/0KGDM74='#,>?K K 3- K  K#K}K&!KK x KKKKZ 2& 2T 2 2 2 2 * *D * * * *&"&%)#'%)"&;;;; ; E? ; % ;c];$;;; ;;;;B!%"&%)%%%% %  %  %$%c]%% %%%%N11v11d1111<     .!9 htnB).))))!& )))) )  )  )) ))))V%6%d%%%%%%rLrA__main__)Panel)Rule)Syntax)r8a~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_valuepython) line_numbersfoobarbaz123z:Text may be printed while the progress bars are rendering.z(In fact, [i]any[/i] renderable will workzSuch as [magenta]tables[/]...zPretty printed structures...examplezPretty printed)typer$z Syntax...zGive it a try!)cycle)record)rxryz[red]DownloadingrOrz[green]Processingz[yellow]ThinkingrZrg333333?g{Gz?d)rmNTNFNrnrorprqrrrsFTr#r$)rsysr%rabcrr collectionsr dataclassesrrdatetimer r r mathr r operatorrosrr threadingrrrtypesrrrrrrrrrrrrr r!r"r#r$r%r& version_infor)pip._vendor.typing_extensionsr r+r,rxr-r.r/r0r+r1jupyterr2rr3 progress_barr4rr5r|r6rr7r8r$r9r:rr;r<rirr=r?rrrrrrr&rrrr rrrr@rrrirprsrrrrrArerandomtimepanelr(ruler)syntaxr*rprogress_renderables itertoolsr5examplesrr@rtask1task2task3r#rRsleeprandintrrrrLrKrSs ########((((((((........ ***********v555555########BBBBBBBBBBBB$$$$$$!!!!!!%%%%%% 3  w~&& 2u9%V^D&(++%%%%%6%%%T$!!%.2 "! . .(C C H\*H\,BBCC C  E?C  C g  C  C xE *+C C  C C C C C C C l!C C C C La,a,a,a,a,ia,a,a,H88888>"%wr{8882$!%.2 "! . .(>*>*>* >* >* >*  >* g  >*>*xE *+>*>* >*>*>*>*>*H>*>*>*>*B" !   #!%.2 "! . .('   _e+ ,  ws|+ ,  sm  SM  c]   C=   g   xE *+    ! "# $% &' (F)    0" !   #!%.2 "! . .('   _e+ , $-  sm  SM  c]   C=   g   xE *+    ! "# $% &' (H)    4?B" ! S* #!%.2 "! . .('S*S*S* _e+ ,S*  wt}gcl: ;S*S*sm S* SM S* c] S* C=S*S*S*g S*S*xE *+S*S* S* !S*"#S*$%S*&'S*( >( #^F%; ;<)S*S*S*S*l'1'1'1'1'1S'1'1'1T~"/////N///d<' ' ' ' ' ' ' ' T : : : : : : : :EEEEEEEEP-,-,-,-,-,.-,-,-,`:::::^:::@@@@@.@@@        6.....^...b D D D D D. D D D%%%%%Z%%% z#z#z#z#z#z#z# z#zI %I %I %I %I %|I %I %I %X zMMMKKK V " F E% & &E MM#sC    E 899' &$455    u)**HgT"""G     % % ' '        - !!"4D!AA!!"5T!BB!!"4D!AA# - OOE3O / / / OOE3O / / / DJt   v~a%%)) TT(^^,,, # -------------------]s4CYY  Y