HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_vendor/rich/__pycache__/live.cpython-310.pyc
o

@%Ne�5�@sJUddlZddlmZmZmZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZmZmZmZddlmZdd	lmZdd
lmZddlmZmZddl m!Z!dd
l"m#Z#Gdd�de�Z$Gdd�dee�Z%e&dk�r�ddl'Z'ddl(Z(ddl)m*Z*ddlm+Z+mZm,Z,ddl-m.Z.ddlmZddl/m%Z%ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7e�Ze5dddd�Z4e7d d!d"�Z6e6�8d#d$d%�d&e1d'�d(e6d)d*d+d,�d-e4e3d.�g	Z9e*e9�Z:gd/�Z;e%ed0���Z<iZ=e+e,e>e>fe?fe@d1<eAd2�D]�ZBe;eBeCe;�ZDe;D]ZEeEeDk�r�qe(�Fd3�e'�Gdd4�dk�r,e�HeIe:��d5e'�'�d6de=eDeEf<eCe=�eCe;�dk�rPe=�JeKe=�L��d�e7d7d8�Z6e6�Md9�e6�Md:�e6�Md;�e=�N�D]\\ZOZPZQe6�8eOePe#eQd<�eQd=k�r}d>nd?d@���qhe<�Re.�Se6���q�qWd�dS1�s�wYdSdS)A�N)�Event�RLock�Thread)�
TracebackType)�IO�Any�Callable�List�Optional�TextIO�Type�cast�)�get_console)�Console�ConsoleRenderable�RenderableType�
RenderHook)�Control)�	FileProxy)�JupyterMixin)�
LiveRender�VerticalOverflowMethod)�Screen)�TextcsBeZdZdZdddeddf�fdd�Zd
d	d
�Zd
dd�Z�ZS)�_RefreshThreadz3A thread that calls refresh() at regular intervals.�live�Live�refresh_per_second�returnNcs&||_||_t�|_t�jdd�dS)NT)�daemon)rrr�done�super�__init__)�selfrr��	__class__��7/usr/lib/python3/dist-packages/pip/_vendor/rich/live.pyr#sz_RefreshThread.__init__cCs|j��dS�N)r!�set�r$r'r'r(�stopsz_RefreshThread.stopcCsh|j�d|j�s2|jj�|j��s|j��Wd�n1s"wY|j�d|j�r	dSdS)Nr)r!�waitrr�_lock�is_set�refreshr+r'r'r(�runs


���z_RefreshThread.run�rN)	�__name__�
__module__�__qualname__�__doc__�floatr#r,r1�
__classcell__r'r'r%r(rs

rc@sLeZdZdZ	d3dddddddddd�	deed	eed
ededed
ededede	dee
gefddfdd�Zedefdd��Z
defdd�Zd4deddfdd�Zd5dd�Zd6dd�Zd eeed!eed"eeddfd#d$�Zd5d%d&�Zd5d'd(�Zedefd)d*��Zdd+�dededdfd,d-�Zd5d.d/�Zd0eedeefd1d2�ZdS)7ra�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. Default will 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�
renderabler;r<r=rr>r?r@rArBrc	Cs�|dksJd��||_|dur|nt�|_||_d|_||_||_d|_d|_t	�|_
d|_||_d|_
|r8dn||_d|_||_|	|_|
|_t|��|	d�|_dS)Nrzrefresh_per_second must be > 0FT)rA)�_renderablerr;�_screen�_alt_screen�_redirect_stdout�_redirect_stderr�_restore_stdout�_restore_stderrrr.�
ipy_widgetr=�_startedr>�_refresh_threadrrA�_get_renderablerrB�_live_render)r$rCr;r<r=rr>r?r@rArBr'r'r(r#3s*�z
Live.__init__cCs|jS)z'Check if live display has been started.)rLr+r'r'r(�
is_started[szLive.is_startedcCs |jdur	|��n|j}|pdS)N�)rNrD�r$rCr'r'r(rB`s

��zLive.get_renderabler0cCs�|j�U|jr	Wd�dS|j�|�d|_|jr#|j�d�|_|j�d�|��|j�	|�|r9|�
�|jrPt||j
�|_|j��Wd�dSWd�dS1s[wYdS)z|Start live rendering display.

        Args:
            refresh (bool, optional): Also refresh. Defaults to False.
        NTF)r.rLr;�set_liverE�set_alt_screenrF�show_cursor�_enable_redirect_io�push_render_hookr0r=rrrM�start)r$r0r'r'r(rXhs&��"�z
Live.startcCs�|j��|js	Wd�dS|j��d|_|jr(|jdur(|j��d|_d|_|j��zM|js;|jj	s;|�
�W|��|j��|jsQ|jj
rQ|j��|j�d�|jr`|j�d�|jro|jso|j�|j���|jdur||jr||j��nC|��|j��|js�|jj
r�|j��|j�d�|jr�|j�d�|jr�|js�|j�|j���|jdur�|jr�|j��wwwWd�n1s�wYWd�dSWd�dS1s�wYdS)zStop live rendering display.NF�visibleT)r.rLr;�
clear_liver=rMr,rArF�
is_jupyterr0�_disable_redirect_io�pop_render_hook�is_terminal�linerUrTr>�controlrO�restore_cursorrK�closer+r'r'r(r,~sX�

�


��

����"�z	Live.stopcCs|j|jdud�|S)N�r0)rXrDr+r'r'r(�	__enter__�szLive.__enter__�exc_type�exc_val�exc_tbcCs|��dSr))r,)r$rerfrgr'r'r(�__exit__�sz
Live.__exit__cCs�|jjs|jjr:|jr ttjt�s tj|_t	dt|jtj��t_|j
r<ttjt�s>tj|_t	dt|jtj��t_dSdSdSdS)z&Enable redirecting of stdout / stderr.rN)
r;r^r[rG�
isinstance�sys�stdoutrrIr
rH�stderrrJr+r'r'r(rV�s�zLive._enable_redirect_iocCs<|jr
td|j�t_d|_|jrtd|j�t_d|_dSdS)z'Disable redirecting of stdout / stderr.rN)rIr
rjrkrJrlr+r'r'r(r\�s
�zLive._disable_redirect_iocCs|��}|jrt|�S|S)zwGet the renderable that is being displayed

        Returns:
            RenderableType: Displayed renderable.
        )rBrFrrRr'r'r(rC�szLive.renderablerccCsN|j�||_|r|��Wd�dSWd�dS1s wYdS)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.rDr0)r$rCr0r'r'r(�update�s
�"�zLive.updatec	Cs�|j��|j�|j�|jjrazddlm}ddlm	}Wnt
y/ddl}|�d�Yn�w|j
dur>|�|_
||j
�|j
�|j
jdd�|j�|jj�Wd�n1s[wYnK|jjr�|jjs�|j�|j�t��Wd�n1s~wYn@|js�|js�|j�|j�t��Wd�n81s�wYWd�dSWd�dSWd�dSWd�dSWd�dSWd�dSWd�dS1s�wYdS)z&Update the display of the Live Render.r)�display)�OutputNz(install "ipywidgets" for Jupyter supportT)r-)r.rO�set_renderablerCr;r[�IPython.displayrn�
ipywidgetsro�ImportError�warnings�warnrK�clear_output�printr^�is_dumb_terminalrrLr>)r$rnrortr'r'r(r0�sV�

���������	����"�zLive.refresh�renderablescCs�|j|j_|jjr3|j�|jrt��n|j��}|g|�|j�}Wd�|S1s,wY|S|j	s@|j
s@g|�|j�}|S)z;Process renderables to restore cursor and display progress.N)rArOr;�is_interactiver.rFr�home�position_cursorrLr>)r$ry�resetr'r'r(�process_renderables�s$

��
�����zLive.process_renderablesr))Fr2)rr)r3r4r5r6r
rr�boolr7rrr#�propertyrPrBrXr,rdr�
BaseExceptionrrhrVr\rCrmr0r	rr~r'r'r'r(r#s|��������	�
���
�(


���
�


		
��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_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)r;�exchange_rate_dict�dg�������?�
��i@zExchange Rates)�titlezSource CurrencyzDestination Currencyz
Exchange Ratez.4fg�?�red�green)�style)Trj�	threadingrrr�typesr�typingrrrr	r
rrr
rQrr;rrrrr`r�
file_proxyr�jupyterr�live_renderrrr<rr�rrrr3�random�time�	itertoolsr�r�r��alignr�r�panelr��ruler��syntaxr��tabler��add_row�progress_renderables�examples�	exchanges�
live_tabler��strr7�__annotations__�range�index�len�select_exchange�exchange�sleep�randint�log�next�pop�list�keys�
add_column�items�source�dest�
exchange_raterm�centerr'r'r'r(�<module>s�
(
c��


�



��	��$��