xhL;  UddlmZddlZddlmZmZmZddlmZddl m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZmZmZmZmZdd lmZdd lmZdd lm Z dd l!m"Z"m#Z#dd l$m%Z%ddl&m'Z'e rddl(m)Z)GddeZ*Gdde eZ+e,dkrvddl-Z-ddl.Z.ddl/m0Z0ddl m1Z1mZm2Z2ddl3m4Z4ddlmZddl5m+Z+ddl6m7Z7ddl8m9Z9ddl:m;Z;ddld%d&d'd(e7d)d*eeCRD]4\\ZSZTZUe<>eSeTe'eUd?eUd@krdAndBC5eBVe4jWe<t ddddS#1swxYwYdSdS)D) annotationsN)EventRLockThread) TracebackType) IO TYPE_CHECKINGAnyCallableListOptionalTextIOTypecast) get_console)ConsoleConsoleRenderableGroupRenderableType RenderHook)Control) FileProxy) JupyterMixin) LiveRenderVerticalOverflowMethod)Screen)Text)Selfc4eZdZdZd fd Zd d Zd d ZxZS) _RefreshThreadz3A thread that calls refresh() at regular intervals.live'Live'refresh_per_secondfloatreturnNonec||_||_t|_t ddS)NT)daemon)r"r$rdonesuper__init__)selfr"r$ __class__s Y/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/rich/live.pyr,z_RefreshThread.__init__s> "4GG  %%%%%c8|jdSN)r*setr-s r/stopz_RefreshThread.stops r0c>|jd|jz sz|jj5|js|jdddn #1swxYwY|jd|jz xdSdS)Nr)r*waitr$r"_lockis_setrefreshr4s r/runz_RefreshThread.run"s)..T%LiveaRenders an auto-updating live display of any given renderable. Args: renderable (RenderableType, optional): The renderable to live display. Defaults to displaying nothing. console (Console, optional): Optional Console instance. Defaults to an internal Console instance writing to stdout. screen (bool, optional): Enable alternate screen mode. Defaults to False. auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()` or `update()` with refresh flag. Defaults to True refresh_per_second (float, optional): Number of times per second to refresh the live display. Defaults to 4. transient (bool, optional): Clear the renderable on exit (has no effect when screen=True). 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. vertical_overflow (VerticalOverflowMethod, optional): How to handle renderable when it is too tall for the console. Defaults to "ellipsis". get_renderable (Callable[[], RenderableType], optional): Optional callable to get renderable. Defaults to None. NFTellipsis) consolescreen auto_refreshr$ transientredirect_stdoutredirect_stderrvertical_overflowget_renderable renderableOptional[RenderableType]rFOptional[Console]rGboolrHr$r%rIrJrKrLrrM&Optional[Callable[[], RenderableType]]r&r'c |dks Jd||_||n t|_||_d|_||_||_d|_d|_t|_ d|_ ||_ d|_ |rdn||_d|_||_| |_| |_t'|| |_d|_dS)Nrzrefresh_per_second must be > 0FT)rL) _renderablerrF_screen _alt_screen_redirect_stdout_redirect_stderr_restore_stdout_restore_stderrrr8 ipy_widgetrH_startedrI_refresh_threadr$rL_get_renderablerrM _live_render_nested) r-rNrFrGrHr$rIrJrKrLrMs r/r,z Live.__init__9s"A%%%'G%%%%")"5ww;==    / /2626WW )-(# !'6Y9="4!2-&    ! !5F    r0c|jS)z'Check if live display has been started.)r\r4s r/ is_startedzLive.is_startedbs }r0rcN|j|n|j}|pdS)N)r^rT)r-rNs r/rMzLive.get_renderablegs9#/  " " "!  Rr0r:c|j5|jr ddddSd|_|j|sd|_ ddddS|jr|jd|_|jd| |j ||r9 | n##t$r| wxYw|jr3t||j|_|jddddS#1swxYwYdS)z|Start live rendering display. Args: refresh (bool, optional): Also refresh. Defaults to False. NTF)r8r\rFset_liver`rUset_alt_screenrV show_cursor_enable_redirect_iopush_render_hookr: Exceptionr5rHr!r$r]start)r-r:s r/rlz Live.startos Z - -}  - - - - - - - -!DM<((.. #  - - - - - - - -| E#'<#>#>t#D#D L $ $U + + +  $ $ & & & L ) )$ / / / LLNNNN  IIKKK   -'5dDQ ,,T->-M-M-O-OPPP2t~2--///--///L00222+, 0H, ))+++L,,T222'; 33E:::~Qd.>Q ,,T->-M-M-O-OPPP2t~2--////32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s[ K?AK?9KK' K?'K+ +K?.K+ /K??LLrc@||jdu|S)Nr:)rlrTr4s r/ __enter__zLive.__enter__s# 4+47 888 r0exc_typeOptional[Type[BaseException]]exc_valOptional[BaseException]exc_tbOptional[TracebackType]c.|dSr2)r5)r-r|r~rs r/__exit__z Live.__exit__s r0c|jjs |jjr|jrgt t jtsHt j|_tdt|jt jt _|j rkt t j tsNt j |_ tdt|jt j t _ dSdSdSdS)z&Enable redirecting of stdout / stderr.rN) rFrtrqrW isinstancesysstdoutrrYrrXstderrrZr4s r/rizLive._enable_redirect_ios < # Qt|'> Q$ QZ I-N-N Q'*z$!(IdlCJ,O,OPP $ QZ I-N-N Q'*z$!(IdlCJ,O,OPP  Q Q Q Q Q Qr0c|jr&td|jt_d|_|jr(td|jt_d|_dSdS)z'Disable redirecting of stdout / stderr.rN)rYrrrrZrr4s r/rrzLive._disable_redirect_ios`   (h(<==CJ#'D   (h(<==CJ#'D  ( (r0c|jj}|r||durtd|D}n|}|jrt |n|S)zwGet the renderable that is being displayed Returns: RenderableType: Displayed renderable. rc6g|]}|S)rM).0r"s r/ z#Live.renderable..s$ N N N4!4!4!6!6 N N Nr0)rF _live_stackrrMrVr)r- live_stackrNs r/rNzLive.renderablesk\-  /$*Q-// N N: N N NOJJ,,..J%)%5Evj!!!:Er0rzct|tr|j|}|j5||_|r|ddddS#1swxYwYdS)zUpdate the renderable that is being displayed Args: renderable (RenderableType): New renderable to use. refresh (bool, optional): Refresh the display. Defaults to False. N)rstrrF render_strr8rTr:)r-rNr:s r/updatez Live.updates j# & & =00<|jjr$|jjd ddddS|jjr ddl m }ddl m }|j ||_ ||j |j 5|j d|j|jjdddn #1swxYwYn#t $rddl}|dYnwxYw|jjrR|jjsF|j5|jt+dddn #1swxYwYnS|jsL|jsE|j5|jt+dddn #1swxYwYddddS#1swxYwYdS)z&Update the display of the Live Render.rN)display)OutputT)r7z(install "ipywidgets" for Jupyter support)r8r_set_renderablerNr`rFrr:rqIPython.displayr ipywidgetsrr[ clear_outputrp ImportErrorwarningswarnrtis_dumb_terminalrr\rI)r-rrrs r/r:z Live.refreshsP Z 2 2   , ,T_ = = =| <+:L,Q/77999  2 2 2 2 2 2 2 2|& 2I777777111111 .*0&((000II44$4??? **4+<+GHHHIIIIIIIIIIIIIII#NNN#OOOMM"LMMMMMN) 2$,2O 2\22L&&wyy111222222222222222M 2*.. 2\22L&&wyy111222222222222222; 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2sAG2- G2: D -G23AC?3 G2?D G2D G2 #D1.G20D11"G2'F: G2F G2 F G2''G G2G G2!G "G22G69G6 renderablesList[ConsoleRenderable]c0|j|j_|jjr_|j5|jrt jn|j}|g||j}dddn #1swxYwYn|j s|j s g||j}|S)z;Process renderables to restore cursor and display progress.N) rLr_rFis_interactiver8rVrhomeposition_cursorr\rI)r-rresets r/process_renderableszLive.process_renderabless/3.D+ < & < G G'=GLNNN*::<< %F{FD4EF  G G G G G G G G G G G G G G G  <&*n <r?r@r,propertyrbrMrlr5r{rrirrrNrr:rrr0r/rCrC)s  "04'&*!$% $ $4>AE''''''RX     - - - - -D 0 0 0 0DQQQQ(((( F F FX FEJ       2 2 2 2Dr0rC__main__)cycle)Dictr Tuple)Align)r)rC)Panel)Rule)Syntax)Tablea~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_valuepythonT) line_numbersfoobarbaz123zYou can make the terminal shorter and taller to see the live table hideText 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)typetextz Syntax...zGive it a try!)SGDMYREURUSDAUDJPYCNHHKDCADINRDKKGBPRUBNZDMXNIDRTWDTHBVND)rFzDict[Tuple[str, str], float]exchange_rate_dictdg? i@zExchange Rates)titlezSource CurrencyzDestination Currencyz Exchange Ratez.4fg?redgreen)style)X __future__rr threadingrrrtypesrtypingrr r r r r rrrrdrrFrrrrrrvr file_proxyrjupyterr live_renderrrrGrrrtyping_extensionsrr!rCr=randomtime itertoolsrrralignrr"panelrrulersyntaxrtableradd_rowprogress_renderablesexamples exchanges live_tabler__annotations__rangeindexlenselect_exchangeexchangesleeprandintlognextpoplistkeys add_columnitemssourcedest exchange_ratercenterrr0r/rs""""""" **********WWWWWWWWWWWWWWWWWWWWWWRRRRRRRRRRRRRR!!!!!!!!!!!!;;;;;;;;'&&&&&&(((((V(((&|||||<|||~ zMMMKKK((((((((((      """"""giiG V " F E% & &E MM#sC    E 899' &$455   u)**HI* g   !7*;=====U3ZZ 7 7E'I(>?O% 7 7.. 3!6>!R((1,,KKX///BE"V]__s*a/C"OX#>?3)**SS^^a-???&**440B0G0G0I0I+J+J1+MNNN$4555  !2333  !7888  1115G5M5M5O5O1NVTMMM,22+83+>+>%%G!!,%,u"5"566667 7 7!7!7!7!7!7!7!7!7!7!7!7!7!7!7!7!7!7!7OsF"LLL