Viewing File: /opt/cloudlinux/venv/lib/python3.11/site-packages/pip/_vendor/rich/__pycache__/live.cpython-311.pyc

�

.|oiL;�
� �UddlmZddlZddlmZmZmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZmZddlmZddlmZmZmZmZmZdd	lmZdd
lmZddlm Z ddl!m"Z"m#Z#dd
l$m%Z%ddl&m'Z'erddl(m)Z)Gd�de��Z*Gd�de e��Z+e,dk�rvddl-Z-ddl.Z.ddl/m0Z0ddl	m1Z1mZm2Z2ddl3m4Z4ddlmZddl5m+Z+ddl6m7Z7ddl8m9Z9ddl:m;Z;ddl<m=Z=e��Ze;ddd �!��Z:e=d"d#d$��Z<e<�>d%d&d'��d(e7d)��d*e<d+d,d-d.�d/e:e9d0��g	Z?e0e?��Z@gd1�ZAe+e�2��5ZBiZCd3eDd4<eEd5��D�]�ZFeAeFeGeA��zZHeAD�]rZIeIeHkr�
e.jJd6��e-jKdd7��dkre�LeMe@����d8e-j-��d9zdzzeCeHeIf<eGeC��eGeA��dz
kr6eC�NeOeC�P����d��e=d:�;��Z<e<�Qd<��e<�Qd=��e<�Qd>��eC�R��D]4\\ZSZTZUe<�>eSeTe'eUd?�eUd@krdAndB�C�����5eB�Ve4jWe<������t���	ddd��dS#1swxYwYdSdS)D�)�annotationsN)�Event�RLock�Thread)�
TracebackType)	�IO�
TYPE_CHECKING�Any�Callable�List�Optional�TextIO�Type�cast�)�get_console)�Console�ConsoleRenderable�Group�RenderableType�
RenderHook)�Control)�	FileProxy)�JupyterMixin)�
LiveRender�VerticalOverflowMethod)�Screen)�Text)�Selfc�4��eZdZdZd�fd�Zdd	�Zdd
�Z�xZS)
�_RefreshThreadz3A thread that calls refresh() at regular intervals.�live�'Live'�refresh_per_second�float�return�Nonec���||_||_t��|_t	���d���dS)NT)�daemon)r"r$r�done�super�__init__)�selfr"r$�	__class__s   ��g/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pip/_vendor/rich/live.pyr,z_RefreshThread.__init__s>�����	�"4����G�G��	�
�������%�%�%�%�%�c�8�|j���dS�N)r*�set�r-s r/�stopz_RefreshThread.stops���	�
�
�����r0c�>�|j�d|jz��sz|jj5|j���s|j���ddd��n#1swxYwY|j�d|jz���xdSdS)Nr)r*�waitr$r"�_lock�is_set�refreshr4s r/�runz_RefreshThread.run"s����)�.�.��T�%<�!<�=�=�	(����
(�
(��y�'�'�)�)�(��I�%�%�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(��)�.�.��T�%<�!<�=�=�	(�	(�	(�	(�	(s�3A.�.A2�5A2)r"r#r$r%r&r'�r&r')�__name__�
__module__�__qualname__�__doc__r,r5r;�
__classcell__)r.s@r/r!r!sk�������=�=�&�&�&�&�&�&�����(�(�(�(�(�(�(�(r0r!c��eZdZdZ	d3dddddddddd�	d4d�Zed5d���Zd6d�Zd7d8d�Zd9d �Z	d:d"�Z
d;d)�Zd9d*�Zd9d+�Z
ed6d,���Zdd-�d<d.�Zd9d/�Zd=d2�ZdS)>�Livea�Renders 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.
    NFT��ellipsis)	�console�screen�auto_refreshr$�	transient�redirect_stdout�redirect_stderr�vertical_overflow�get_renderable�
renderable�Optional[RenderableType]rF�Optional[Console]rG�boolrHr$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�%�%�%�%���")�"5�w�w�;�=�=������ ��� /��� /���26���26����W�W��
�)-���(���#��
�!'�6���Y���9=���"4���!2���-���&����!�!�5F�
�
�
�������r0c��|jS)z'Check if live display has been started.)r\r4s r/�
is_startedzLive.is_startedbs���}�r0rc�N�|j�|���n|j}|pdS)N�)r^rT)r-rNs  r/rMzLive.get_renderablegs9���#�/�
� � �"�"�"��!�	�
��R�r0r:c��|j5|jr	ddd��dSd|_|j�|��sd|_	ddd��dS|jr|j�d��|_|j�d��|�	��|j�
|��|r9	|���n##t$r|�
���wxYw|jr3t||j��|_|j���ddd��dS#1swxYwYdS)z|Start live rendering display.

        Args:
            refresh (bool, optional): Also refresh. Defaults to False.
        NTF)r8r\rF�set_liver`rU�set_alt_screenrV�show_cursor�_enable_redirect_io�push_render_hookr:�	Exceptionr5rHr!r$r]�start)r-r:s  r/rlz
Live.startos����Z�	-�	-��}�
��	-�	-�	-�	-�	-�	-�	-�	-�!�D�M��<�(�(��.�.�
�#����	-�	-�	-�	-�	-�	-�	-�	-��|�
E�#'�<�#>�#>�t�#D�#D�� ��L�$�$�U�+�+�+��$�$�&�&�&��L�)�)�$�/�/�/��	
���L�L�N�N�N�N�� ����
�I�I�K�K�K��
����� �
-�'5�d�D�<S�'T�'T��$��$�*�*�,�,�,�5	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-s5�	E�)E�A0E�C�E� C:�:=E�E�Ec��|j5|js	ddd��dSd|_|j���|jr4|js|j�|j��	ddd��dS|jr'|j	� |j	�
��d|_	d|_|j5	|js |jj
s|���|���|j���|js%|jjr|j���|j�d��|jr|j�d��|jr8|js1|j�|j�����|j� |jr|j����n#|���|j���|js%|jjr|j���|j�d��|jr|j�d��|jr8|js1|j�|j�����|j�!|jr|j���wwwxYwddd��n#1swxYwYddd��dS#1swxYwYdS)zStop live rendering display.NF�visibleT)r8r\rF�
clear_liver`rI�printrNrHr]r5rLrV�
is_jupyterr:�_disable_redirect_io�pop_render_hook�is_terminal�linerhrg�controlr_�restore_cursorr[�closer4s r/r5z	Live.stop�s���
�Z�	0�	0��=�
��	0�	0�	0�	0�	0�	0�	0�	0�"�D�M��L�#�#�%�%�%��|�
��~�8��L�&�&�t��7�7�7��	0�	0�	0�	0�	0�	0�	0�	0�� �
,�T�%9�%E��$�)�)�+�+�+�'+��$�%.�D�"���
0�
0�0��+�'�D�L�4K�'��������-�-�/�/�/��L�0�0�2�2�2��+�,���0H�,���)�)�+�+�+��L�,�,�T�2�2�2��'�;���3�3�E�:�:�:��~�Q�d�.>�Q���,�,�T�->�-M�-M�-O�-O�P�P�P���2�t�~�2���-�-�/�/�/����-�-�/�/�/��L�0�0�2�2�2��+�,���0H�,���)�)�+�+�+��L�,�,�T�2�2�2��'�;���3�3�E�:�:�:��~�Q�d�.>�Q���,�,�T�->�-M�-M�-O�-O�P�P�P���2�t�~�2���-�-�/�/�/�/�3�2����
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?�9<K?�5K'�7'G�C<K'�C>K�K'�K?�'K+	�+K?�.K+	�/K?�?L�Lrc�@�|�|jdu���|S)N�r:)rlrTr4s r/�	__enter__zLive.__enter__�s#���
�
�4�+�4�7�
�8�8�8��r0�exc_type�Optional[Type[BaseException]]�exc_val�Optional[BaseException]�exc_tb�Optional[TracebackType]c�.�|���dSr2)r5)r-r|r~r�s    r/�__exit__z
Live.__exit__�s��	
�	�	�����r0c��|jjs|jjr�|jrgt	t
jt��sHt
j|_tdt|jt
j����t
_|j
rkt	t
jt��sNt
j|_tdt|jt
j����t
_dSdSdSdS)z&Enable redirecting of stdout / stderr.rN)
rFrtrqrW�
isinstance�sys�stdoutrrYrrX�stderrrZr4s r/rizLive._enable_redirect_io�s����<�#�	Q�t�|�'>�	Q��$�
Q�Z��
�I�-N�-N�
Q�'*�z��$�!�(�I�d�l�C�J�,O�,O�P�P��
��$�
Q�Z��
�I�-N�-N�
Q�'*�z��$�!�(�I�d�l�C�J�,O�,O�P�P��
�
�
�
	Q�	Q�
Q�
Q�
Q�
Qr0c��|jr&td|j��t_d|_|jr(td|j��t_d|_dSdS)z'Disable redirecting of stdout / stderr.rN)rYrr�r�rZr�r4s r/rrzLive._disable_redirect_io�s`����	(��h��(<�=�=�C�J�#'�D� ���	(��h��(<�=�=�C�J�#'�D� � � �	(�	(r0c��|jj}|r||durtd�|D���}n|���}|jrt|��n|S)zwGet the renderable that is being displayed

        Returns:
            RenderableType: Displayed renderable.
        rc�6�g|]}|�����S�)rM)�.0r"s  r/�
<listcomp>z#Live.renderable.<locals>.<listcomp>�s$�� N� N� N�4��!4�!4�!6�!6� N� N� Nr0)rF�_live_stackrrMrVr)r-�
live_stackrNs   r/rNzLive.renderable�sk���\�-�
��	/�$�*�Q�-�/�/�� N� N�:� N� N� N�O�J�J��,�,�.�.�J�%)�%5�E�v�j�!�!�!�:�Er0rzc���t|t��r|j�|��}|j5||_|r|���ddd��dS#1swxYwYdS)z�Update the renderable that is being displayed

        Args:
            renderable (RenderableType): New renderable to use.
            refresh (bool, optional): Refresh the display. Defaults to False.
        N)r��strrF�
render_strr8rTr:)r-rNr:s   r/�updatezLive.update�s����j�#�&�&�	=���0�0��<�<�J�
�Z�	�	�)�D���
�������	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A"�"A&�)A&c��|j5|j�|j��|jr>|jjr$|jjd���	ddd��dS|jjr�	ddl	m
}ddlm}|j
�|��|_
||j
��|j
5|j
�d���|j�|jj��ddd��n#1swxYwYn�#t $rddl}|�d��Yn�wxYw|jjrR|jjsF|j5|j�t+����ddd��n#1swxYwYnS|jsL|jsE|j5|j�t+����ddd��n#1swxYwYddd��dS#1swxYwYdS)z&Update the display of the Live Render.rN)�display)�OutputT)r7z(install "ipywidgets" for Jupyter support)r8r_�set_renderablerNr`rFr�r:rq�IPython.displayr��
ipywidgetsr�r[�clear_outputrp�ImportError�warnings�warnrt�is_dumb_terminalrr\rI)r-r�r�r�s    r/r:zLive.refresh�sP��
�Z�	2�	2���,�,�T�_�=�=�=��|�
��<�+�:��L�,�Q�/�7�7�9�9�9��	2�	2�	2�	2�	2�	2�	2�	2��|�&�
2�I�7�7�7�7�7�7�1�1�1�1�1�1���.�*0�&�(�(�������0�0�0���I�I���4�4�$�4�?�?�?���*�*�4�+<�+G�H�H�H�I�I�I�I�I�I�I�I�I�I�I����I�I�I�I���#�N�N�N�#�O�O�O��M�M�"L�M�M�M�M�M�N������)�
2�$�,�2O�
2��\�2�2��L�&�&�w�y�y�1�1�1�2�2�2�2�2�2�2�2�2�2�2����2�2�2�2���M�
2�*.�.�
2��\�2�2��L�&�&�w�y�y�1�1�1�2�2�2�2�2�2�2�2�2�2�2����2�2�2�2�;	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2s��AG2�-G2�:D�-G2�3AC?�3G2�?D	�G2�D	�G2�#D1�.G2�0D1�1"G2�'F�:G2�F
	�
G2�
F
	�G2�''G�G2�G	�G2�!G	�"G2�2G6�9G6�renderables�List[ConsoleRenderable]c�0�|j|j_|jjr_|j5|jrt
j��n|j���}|g|�|j�}ddd��n#1swxYwYn|j	s|j
sg|�|j�}|S)z;Process renderables to restore cursor and display progress.N)rLr_rF�is_interactiver8rVr�home�position_cursorr\rI)r-r��resets   r/�process_renderableszLive.process_renderabless��/3�.D���+��<�&�	<���
G�
G��'�=�G�L�N�N�N��*�:�:�<�<��
 %�F�{�F�D�4E�F��

G�
G�
G�
G�
G�
G�
G�
G�
G�
G�
G����
G�
G�
G�
G���
�	<�&*�n�	<�<�K�;��):�;�K��s�AA1�1A5�8A5r2)rNrOrFrPrGrQrHrQr$r%rIrQrJrQrKrQrLrrMrRr&r')r&rQ)r&r)F)r:rQr&r'r<)r&r)r|r}r~rr�r�r&r')rNrr:rQr&r')r�r�r&r�)r=r>r?r@r,�propertyrbrMrlr5r{r�rirrrNr�r:r�r�r0r/rCrC)s�������
�
�"04�'�&*��!�$%�� $� $�4>�AE�'�'�'�'�'�'�R�����X�� � � � � -� -� -� -� -�D 0� 0� 0� 0�D��������Q�Q�Q�Q�(�(�(�(��
F�
F�
F��X�
F�EJ������� 2� 2� 2� 2�D�����r0rC�__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_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)rFzDict[Tuple[str, str], float]�exchange_rate_dict�dg�������?�
��i@zExchange Rates)�titlezSource CurrencyzDestination Currencyz
Exchange Ratez.4fg�?�red�green)�style)X�
__future__rr��	threadingrrr�typesr�typingrr	r
rrr
rrrrdrrFrrrrrrvr�
file_proxyr�jupyterr�live_renderrrrGrr�r�typing_extensionsrr!rCr=�random�time�	itertoolsr�r�r��alignr�r"�panelr��ruler��syntaxr��tabler��add_row�progress_renderables�examples�	exchanges�
live_tabler��__annotations__�range�index�len�select_exchange�exchange�sleep�randint�log�next�pop�list�keys�
add_column�items�source�dest�
exchange_rater��centerr�r0r/�<module>rs���"�"�"�"�"�"�"�
�
�
�
�*�*�*�*�*�*�*�*�*�*�������W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�������R�R�R�R�R�R�R�R�R�R�R�R�R�R�������!�!�!�!�!�!�!�!�!�!�!�!�;�;�;�;�;�;�;�;��������������'�&�&�&�&�&�&�(�(�(�(�(�V�(�(�(�&|�|�|�|�|�<��|�|�|�~�z����M�M�M��K�K�K�������(�(�(�(�(�(�(�(�(�(������� � � � � � �"�"�"�"�"�"��������������������������g�i�i�G�
�V�
	"�	�����F� 
�E�%���&�&�E�	�M�M�#�s�C� � � �	E�
��8�9�9�'�
�&��$4�5�5�����
������u�)�*�*�H����I�*
��g�	�	�	�!7�*�;=��=�=�=�=��U�3�Z�Z�	7�	7�E�'����I���(>�?�O�%�
7�
7����.�.����
�3����!�6�>�!�R�(�(�1�,�,��K�K���X���/�/�/�BE�"�V�]�_�_�s�*�a�/�C�"�O�X�#>�?��3�)�*�*�S�S��^�^�a�-?�?�?�&�*�*�4�4�0B�0G�0G�0I�0I�+J�+J�1�+M�N�N�N���$4�5�5�5��� � �!2�3�3�3�� � �!7�8�8�8�� � ��1�1�1�5G�5M�5M�5O�5O���1�N�V�T�M��M�M�����,�2�2�+8�3�+>�+>�%�%�G���������!�!�,�%�,�u�"5�"5�6�6�6�6�7
7�	7�!7�!7�!7�!7�!7�!7�!7�!7�!7�!7�!7�!7����!7�!7�!7�!7�!7�!7�O�s�F"L�L�L
Back to Directory File Manager