Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
live.cpython-313.pyc133 linesDownload Raw Back to __pycache__
1�

2�j�;�
�v�%SSKJr SSKrSSKJrJrJr SSKJr SSK	J3r4JrJrJ
r
JrJrJrJrJr SSKJr SSKJrJrJrJrJr SS	KJr SS5KJr SSKJ r  SSK!J"r"J#r# SS
K$J%r% SSK&J'r' \(aSSK(J)r) "SS\5r*"SS\ \5r+\,S:XGaSSK-r-SSK.r.SSK/J0r0 SSK	J1r1JrJ2r2 SSK3J4r4 SSKJr SSK5J+r+ SSK6J7r7 SSK8J9r9 SSK:J;r; SSK<J=r= \"5r\;"SSS S!9r:\="S"S#S$5r<\<R}S%S&S'5 S(\7"S)5S*\<S+S,S-S..S/\:\9"S05/	r?\0"\?5r@/S1QrA\+"\S29rB0rCS3\DS4'\E"S55GHZrF\A\F\G"\A5-rH\AGHArI\I\H:XaM\.R�"S65 \-R�"SS75S:a\R�\M"\@55 S8\-RZ"5S9-S--\C\H\I4'\G"\C5\G"\A5S-6:�a(\CR�\O"\CR�55S5 \="S:S;9r<\<R�S<5 \<R�S=5 \<R�S>5 \CR�5H+uurSrTrU\<R}\S\T\'"\US?\US@:aSAOSBSC95 M- \BR�\4R�"\<55 GMD GM] SSS5 gg!,(df   g=f)D�)�annotationsN)�Event�RLock�Thread)�
TracebackType)	�IO�
TYPE_CHECKING�Any�Callable�List�Optional�TextIO�Type�cast�)�get_console)�Console�ConsoleRenderable�Group�RenderableType�7RenderHook)�Control)�	FileProxy)�JupyterMixin)�8LiveRender�VerticalOverflowMethod)�Screen)�Text)�Selfc�D^�\rSrSrSrSU4SjjrSSjrSSjrSrU=r	$)	�_RefreshThread�z3A thread that calls refresh() at regular intervals.c�V>�XlX l[5Ul[TU]SS9 g)NT)�daemon)�live�refresh_per_secondr�done�super�__init__)�selfr%r&�	__class__s   ��OD:\code\apps\devtools\python\user_packages\Python313\site-packages\rich/live.pyr)�_RefreshThread.__init__s'����	�"4���G��	�
�����%�c�8�URR5 g�N)r'�set�r*s r,�stop�_RefreshThread.stops���	�	�
�
�r.c��URRSUR-5(d�URR URR5(dURR
5 SSS5 URRSUR-5(dM�gg!,(df   N?=f)Nr)r'�waitr&r%�_lock�is_set�refreshr2s r,�run�_RefreshThread.run"sy���)�)�.�.��T�%<�%<�!<�=�=�������y�y�'�'�)�)��I�I�%�%�'�!��)�)�.�.��T�%<�%<�!<�=�=� ��s�:B7�79C)r'r%r&)r%z'Live'r&�float�return�None�r=r>)10�__name__�11__module__�__qualname__�__firstlineno__�__doc__r)r3r:�__static_attributes__�
__classcell__)r+s@r,r!r!s���=�&��(�(r.r!c��\rSrSrSrSSSSSSSSSSS.	SS	jjjr\SS12j5rSSjrSSSjjr	SS
jr13SSjrS SjrSSjr
SSjr\SSj5rSS.S!SjjrSSjrS"SjrSrg)#�Live�)a�Renders an auto-updating live display of any given renderable.14 15Args:16    renderable (RenderableType, optional): The renderable to live display. Defaults to displaying nothing.17    console (Console, optional): Optional Console instance. Defaults to an internal Console instance writing to stdout.18    screen (bool, optional): Enable alternate screen mode. Defaults to False.19    auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()` or `update()` with refresh flag. Defaults to True20    refresh_per_second (float, optional): Number of times per second to refresh the live display. Defaults to 4.21    transient (bool, optional): Clear the renderable on exit (has no effect when screen=True). Defaults to False.22    redirect_stdout (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True.23    redirect_stderr (bool, optional): Enable redirection of stderr. Defaults to True.24    vertical_overflow (VerticalOverflowMethod, optional): How to handle renderable when it is too tall for the console. Defaults to "ellipsis".25    get_renderable (Callable[[], RenderableType], optional): Optional callable to get renderable. Defaults to None.26NFT��ellipsis)	�console�screen�auto_refreshr&�	transient�redirect_stdout�redirect_stderr�vertical_overflow�get_renderablec	��US:�dS5eXlUbUO	[5UlX0lSUlXplX�lSUlSUl[5Ul27SUlX@lSUl
U(aSOUUlSUlXPlX�lX�l['UR)5U	S9UlSUlg)Nrzrefresh_per_second must be > 0FT)rR)�_renderablerrL�_screen�_alt_screen�_redirect_stdout�_redirect_stderr�_restore_stdout�_restore_stderrrr7�28ipy_widgetrN�_startedrO�_refresh_threadr&rR�_get_renderablerrS�_live_render�_nested)r*�29renderablerLrMrNr&rOrPrQrRrSs           r,r)�
Live.__init__9s���"�A�%�G�'G�G�%�%��")�"5�w�;�=����� ��� /�� /��26���26����W��30�)-���(��#��
�!'��Y���9=���"4��!2��-��&����!�5F�31�����r.c��UR$)z'Check if live display has been started.)r]r2s r,�32is_started�Live.is_startedbs���}�}�r.c�j�URbUR5OURnU=(d S$)N�)r_rU)r*rbs  r,rS�Live.get_renderablegs9���#�#�/�
� � �"��!�!�	�33��R�r.c���UR UR(a34SSS5 gSUlURRU5(dSUlSSS5 gUR35(a URR
S5UlURRS5 UR5 URRU5 U(aUR5 UR(a4[XR 5UlUR"R%5 SSS5 g![a UR5 ef=f!,(df   g=f)zdStart live rendering display.36 37Args:38    refresh (bool, optional): Also refresh. Defaults to False.39NTF)r7r]rL�set_liverarV�set_alt_screenrW�show_cursor�_enable_redirect_io�push_render_hookr9�	Exceptionr3rNr!r&r^�start)r*r9s  r,rq�40Live.startos41���Z�Z��}�}���Z�!�D�M��<�<�(�(��.�.�#�����Z��|�|�#'�<�<�#>�#>�t�#D�� ��L�L�$�$�U�+��$�$�&��L�L�)�)�$�/����L�L�N�� � �'5�d�<S�<S�'T��$��$�$�*�*�,�5�Z��"!��42�I�I�K��
��#�Z�s0�E�/E�!A>E� D>�0AE�>E�E�43E+c�H�UR UR(d44SSS5 gSUlURR5 UR(a@UR45(d%URR
UR5 SSS5 gUR(a.URb!URR5 SUl	SUlUR UR(d+URR(dUR5 UR5 URR!5 UR(dPURR"(a5UR$R&(aURR)5 URR+S5 UR(aURR-S5 UR46(aDUR(d3URR/UR$R155 UR2b+UR47(aUR2R55 SSS5 SSS5 g!UR5 URR!5 UR(dPURR"(a5UR$R&(aURR)5 URR+S5 UR(aURR-S5 UR48(aDUR(d3URR/UR$R155 UR2b-UR49(aUR2R55 fff=f!,(df   GN~=f!,(df   g=f)zStop live rendering display.NF�visibleT)r7r]rL�50clear_liverarO�printrbrNr^r3rRrW�51is_jupyterr9�_disable_redirect_io�pop_render_hook�is_terminalr`�last_render_height�linermrl�control�restore_cursorr\�closer2s r,r3�	Live.stop�s���
�Z�Z��=�=���Z�"�D�M��L�L�#�#�%��|�|��~�~��L�L�&�&�t���7���Z�� � �T�%9�%9�%E��$�$�)�)�+�'+��$�%.�D�"����0��+�+�D�L�L�4K�4K������-�-�/��L�L�0�0�2� �,�,� �L�L�4�4� �-�-�@�@����)�)�+��L�L�,�,�T�2��'�'����3�3�E�:��~�~�d�.>�.>����,�,�T�->�->�-M�-M�-O�P����2�t�~�~����-�-�/�'��Z��(�-�-�/��L�L�0�0�2� �,�,� �L�L�4�4� �-�-�@�@����)�)�+��L�L�,�,�T�2��'�'����3�3�E�:��~�~�d�.>�.>����,�,�T�->�->�-M�-M�-O�P����2�t�~�~����-�-�/�8F�2��%����Z�sJ�P�A)P�AP�-P�/<J�+EP�52P�E#O>�>P�53P	�P�54P!c�<�URURSLS9 U$)N�r9)rqrUr2s r,�	__enter__�Live.__enter__�s ���55�56�4�+�+�4�7�57�8��r.c�$�UR5 gr0)r3)r*�exc_type�exc_val�exc_tbs    r,�__exit__�
Live.__exit__�s
��	
�	�	�r.c�x�URR(dURR(GaUR(ao[	[58R[5(dL[59RUl[S[UR[60R55[61lUR(aq[	[62R[5(dM[63RUl[S[UR[64R55[65lgggg)z&Enable redirecting of stdout / stderr.rN)
rLrzrwrX�66isinstance�sys�stdoutrrZrrY�stderrr[r2s r,rn�Live._enable_redirect_io�s����<�<�#�#�t�|�|�'>�'>�'>��$�$�Z��67�68�I�-N�-N�'*�z�z��$�!�(�I�d�l�l�C�J�J�,O�P��69��$�$�Z��70�71�I�-N�-N�'*�z�z��$�!�(�I�d�l�l�C�J�J�,O�P��72�.O�$�	(?r.c���UR(a&[SUR5[lSUlUR(a'[SUR5[lSUlgg)z'Disable redirecting of stdout / stderr.rN)rZrr�r�r[r�r2s r,rx�Live._disable_redirect_io�sQ������h��(<�(<�=�C�J�#'�D� �����h��(<�(<�=�C�J�#'�D� � r.c���URRnU(a.XSLa'[UVs/sHo"R5PM sn6nOUR5nUR(a[U5$U$s snf)z_Get the renderable that is being displayed73 74Returns:75    RenderableType: Displayed renderable.76r)rL�_live_stackrrSrWr)r*�77live_stackr%rbs    r,rb�Live.renderable�sk���\�\�-�-�78��$�Q�-�/��:� N�:�4�!4�!4�!6�:� N�O�J��,�,�.�J�%)�%5�%5�v�j�!�E�:�E��!Os�A:r�c���[U[5(aURRU5nUR XlU(aUR
5 SSS5 g!,(df   g=f)z�Update the renderable that is being displayed79 80Args:81    renderable (RenderableType): New renderable to use.82    refresh (bool, optional): Refresh the display. Defaults to False.83N)r��strrL�84render_strr7rUr9)r*rbr9s   r,�update�Live.update�sH���j�#�&�&����0�0��<�J�
�Z�Z�)��������Z�Z�s�A$�$85A2c���UR URRUR5 UR(aLUR86R(a'UR87RSR5 SSS5 gUR88R(a�SSK	J89n SSKJn URcU"5Ul
U"UR5 UR URRSS9 UR90RURR5 SSS5 O�UR91R&(aTUR92R((d9UR93 UR94R[+55 SSS5 OZUR,(dIUR.(d8UR95 UR96R[+55 SSS5 SSS5 g!,(df   N=f![ a SSKnUR%S5 N;f=f!,(df   NM=f!,(df   N^=f!,(df   g=f)z&Update the display of the Live Render.rN)�display)�OutputT)r6z(install "ipywidgets" for Jupyter support)r7r`�set_renderablerbrarLr�r9rw�IPython.displayr��97ipywidgetsr�r\�clear_outputrv�ImportError�warnings�warnrz�is_dumb_terminalrr]rO)r*r�r�r�s    r,r9�Live.refresh�s���
�Z�Z����,�,�T�_�_�=��|�|��<�<�+�+��L�L�,�,�Q�/�7�7�9���Z��|�|�&�&�I�7�1����.�*0�(�������0�������4�4�$�4�?����*�*�4�+<�+<�+G�+G�H�)�����)�)�$�,�,�2O�2O��\�\��L�L�&�&�w�y�1�"�\��M�M�$�.�.��\�\��L�L�&�&�w�y�1�"�;�Z�()���#�N�#��M�M�"L�M�N��"�\��98"�\��;�Z�s��A:I+�I+�,H$�87I+�/A	H�8AI+�$I	�'7I+�$I�I+�99H!	�I+�$I�I+�I�I+�	100I	�I+�101I(	�$I+�+102I9c���URURlURR(ahUR UR103(a[R"5OURR5nU/UQURPnSSS5 U$UR(d!UR(d/UQURPnU$!,(df   U$=f)z;Process renderables to restore cursor and display progress.N)rRr`rL�is_interactiver7rWr�home�position_cursorr]rO)r*�renderables�resets   r,�process_renderables�Live.process_renderabless���/3�.D�.D����+��<�<�&�&�����'�'��L�L�N��*�*�:�:�<��104 %�F�{�F�D�4E�4E�F��
���	�
�
�d�n�n�;�K�;��):�):�;�K�������s
�AC�105C")rWr_r`r7rarYrXr^rUr[rZrVr]rNrLr\r&rOrRr0)rbzOptional[RenderableType]rLzOptional[Console]rM�boolrNr�r&r<rOr�rPr�rQr�rRrrSz&Optional[Callable[[], RenderableType]]r=r>)r=r�)r=r)F)r9r�r=r>r?)r=r)r�zOptional[Type[BaseException]]r�zOptional[BaseException]r�zOptional[TracebackType]r=r>)rbrr9r�r=r>)r��List[ConsoleRenderable]r=r�)r@rArBrCrDr)�propertyrerSrqr3r�r�rnrxrbr�r9r�rE�r.r,rHrH)s=��
�"04�'�&*��!�$%�� $� $�4>�AE�'�,�'�#�	'�106�'��
'�"�'��'��'��'�2�'�?�'�107�'�R���� � -�D$0�L��/��)��(�	�108109��Q�(��
F��
F�EJ�� 2�D�2��	 �r.rH�__main__)�cycle)�Dictr�Tuple)�Align)r)rH)�Panel)�Rule)�Syntax)�Tablea~def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:110    """Iterate and generate a tuple with a flag for last value."""111    iter_values = iter(values)112    try:113        previous_value = next(iter_values)114    except StopIteration:115        return116    for value in iter_values:117        yield False, previous_value118        previous_value = value119    yield True, previous_value�pythonT)�line_numbers�foo�bar�baz�1�2�3z�You 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)�type�textz	Syntax...zGive it a try!)�SGD�MYR�EUR�USD�AUD�JPY�CNH�HKD�CAD�INR�DKK�GBP�RUB�NZD�MXN�IDR�TWD�THB�VND)rLzDict[Tuple[str, str], float]�exchange_rate_dict�dg�������?�120��i@zExchange Rates)�titlezSource CurrencyzDestination Currencyz
Exchange Ratez.4fg�?�red�green)�style)X�121__future__rr��	threadingrrr�typesr�typingrr	r122rrr
rrrrhrrLrrrrrr}r�123file_proxyr�jupyterr�live_renderrrrMrr�r�typing_extensionsrr!rHr@�random�time�	itertoolsr�r�r��alignr�r%�panelr��ruler��syntaxr��tabler��add_row�progress_renderables�examples�	exchanges�124live_tabler��__annotations__�range�index�len�select_exchange�exchange�sleep�randint�log�next�pop�list�keys�125add_column�items�source�dest�
exchange_rater��centerr�r.r,�<module>rs���"�126�*�*��W�W�W��R�R��!�!�;����&�(�V�(�&@�<��@�F�z�����(�(�� �"������i�G�
�127	"�	���F� 
�%���&�E�	�M�M�#�s�C� �	E�
�8�9�'�
�&��$4�5����
�����)�*�H��I�*128�g�	�*�;=��8�=��3�Z�E�'���I��(>�?�O�%����.���129�130�3���>�>�!�R�(�1�,��K�K��X��/�BE��]�]�_�s�*�a�/�C�"�O�X�#>�?��)�*�S��^�a�-?�?�&�*�*�4�0B�0G�0G�0I�+J�1�+M�N��$4�5��� � �!2�3�� � �!7�8�� � ��1�5G�5M�5M�5O�1�N�V�T�M��M�M����,�S�1�+8�3�+>�%�G���6P��!�!�%�,�,�u�"5�6�7&� �131�	�O�N132�	�s
�1E/J*�*133J8
codekingpro/portable-devtools · Team Ai