"Te7 TUddlZddlmZmZmZddlmZddlmZm Z m Z m Z m Z m Z mZmZddlmZddlmZmZmZmZddlmZdd lmZdd lmZdd lmZmZdd l m!Z!dd l"m#Z#GddeZ$GddeeZ%e&dk(rddl'Z'ddl(Z(ddl)m*Z*ddlm+Z+m Z m,Z,ddl-m.Z.ddlmZddl/m%Z%ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7eZe5dddZ4e7d d!d"Z6e6jqd#d$d%d&e1d'd(e6d)d*d+d,d-e4e3d.g Z9e*e9Z:gd/Z;e%e05Ze>fe?fe@d1<eAd2D]VZBe;eBeCe;zZDe;D]?ZEeEeDk(r e(jd3e'jdd4dkrejeIe:d5e'jNd6zdzz e=eDeEf<eCe=eCe;dz kDr(e=jeKe=jde7d78Z6e6jd9e6jd:e6jd;e=jD],\\ZOZPZQe6jqeOePe#eQd<eQd=krd>nd?@.e 0FT)rF) _renderablerr@_screen _alt_screen_redirect_stdout_redirect_stderr_restore_stdout_restore_stderrrr2 ipy_widgetrB_startedrC_refresh_threadr rF_get_renderablerrG _live_render) r'rHr@rArBr rCrDrErFrGs r)r&z Live.__init__3s"A%G'GG%%")"5w;=    / /2626W )-(# !'Y9="4!2-&    !5F r*c|jS)z'Check if live display has been started.)rRr.s r) is_startedzLive.is_started[s}}r*c^|j|jn |j}|xsdS)N)rTrJr'rHs r)rGzLive.get_renderable`s9##/  "!!  Rr*r4c~|j5|jr dddy|jj|d|_|jr |jj d|_|jjd|j|jj||r |j|jr5t||j|_|j j#dddy#t$r|jwxYw#1swYyxYw)z|Start live rendering display. Args: refresh (bool, optional): Also refresh. Defaults to False. NTF)r2rRr@set_liverKset_alt_screenrL show_cursor_enable_redirect_iopush_render_hookr4 Exceptionr/rBrr rSstart)r'r4s r)rbz Live.starths ZZ -}} - - LL ! !$ ' DM||#'<<#>#>t#D LL $ $U +  $ $ & LL ) )$ /LLN  '5dD.> ,,T->->-M-M-OP2t~~--/! 0 0 0 --/LL002++ 0H0H ))+LL,,T2'' 33E:~~d.>.> ,,T->->-M-M-OP2t~~--/8F2 0 0 0 0sCL5A-L5L(2G<D&L(+L5cB|j|jdu|S)Nr4)rbrJr.s r) __enter__zLive.__enter__s  4++47 8 r*exc_typeexc_valexc_tbc$|jyr,)r/)r'rqrrrss r)__exit__z Live.__exit__s r*c:|jjs|jjr|jrjt t j tsLt j |_tdt|jt j t _|jrlt t jtsMt j|_ tdt|jt jt _ yyyy)z&Enable redirecting of stdout / stderr.r N) r@rirfrM isinstancesysstdoutrrOrrNstderrrPr.s r)r_zLive._enable_redirect_ios << # #t||'>'>$$Z I-N'*zz$!(IdllCJJ,OP $$Z I-N'*zz$!(IdllCJJ,OP .O$ (?r*c|jr&td|jt_d|_|jr'td|jt_d|_yy)z'Disable redirecting of stdout / stderr.r N)rOrrxryrPrzr.s r)rgzLive._disable_redirect_iosQ   h(<(<=CJ#'D   h(<(<=CJ#'D  r*cT|j}|jr t|S|S)zwGet the renderable that is being displayed Returns: RenderableType: Displayed renderable. )rGrLrrZs r)rHzLive.renderables*((* %)%5%5vj!E:Er*roct|tr|jj|}|j5||_|r|j dddy#1swYyxYw)zUpdate the renderable that is being displayed Args: renderable (RenderableType): New renderable to use. refresh (bool, optional): Refresh the display. Defaults to False. N)rwstrr@ render_strr2rJr4)r'rHr4s r)updatez Live.updatesR j# &00>Cr,)Fr6)r!r)r7r8r9r:r rrboolr;rr r&propertyrWrGrbr/rpr BaseExceptionrrur_rgrHrr4r rrr*r)rr#s "04& &*!$% $ $4>AE& ^,& '" &  &  & "& & & & 2& !"n*&  & PD  -T-d-<0>4 ./-('   Q(FNFFEJ  T d 2: 12  r*r__main__)cycle)Dictr Tuple)Align)r)r)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)r@exchange_rate_dictdg? i@zExchange Rates)titlezSource CurrencyzDestination Currencyz Exchange Ratez.4fg?redgreen)style)Trx threadingrrrtypesrtypingrrr r r r r rrYrr@rrrrrkr file_proxyrjupyterr live_renderrrrArrrrrr7randomtime itertoolsrrralignrrpanelrrulersyntaxrtableradd_rowprogress_renderablesexamples exchanges live_tablerr~r;__annotations__rangeindexlenselect_exchangeexchangesleeprandintlognextpoplistkeys add_columnitemssourcedest exchange_ratercenterrr*r)rs **HHHKK!!;(V(&i<iX z(( "iG  " F % &E MM#sC  E 89' &$45  )*HI* g !7*;=DsCx%!78=3Z 7E'I(>?O% 7. 3!6>>!R(1,KKX/BE"V]]_s*a/C"OX#>?)*S^a-??&**40B0G0G0I+J1+MN$45  !23  !78  15G5M5M5O1NVTMMM,S1+83+>%G!!,%,,u"567 7 7!7!7ON!7!7s E4JJ'