
    !2iL;                        U d dl mZ d dlZd dlmZmZmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZmZmZ ddlmZ ddlmZmZmZmZmZ dd	lmZ dd
lmZ ddlm Z  ddl!m"Z"m#Z# ddl$m%Z% ddl&m'Z' erd dl(m)Z)  G d de          Z* G d de e          Z+e,dk    rvd dl-Z-d dl.Z.d dl/m0Z0 d dl	m1Z1mZm2Z2 ddl3m4Z4 ddlmZ ddl5m+Z+ ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z=  e            Z e;ddd !          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@g d1ZA e+e2          5 ZBi ZCd3eDd4<    eEd5          D ]ZFeAeF eGeA          z           ZHeAD ]rZIeIeHk    r
 e.jJ        d6            e-jK        d d7          dk     reL                     eMe@                     d8 e-j-                    d9z  dz   z  eCeHeIf<    eGeC           eGeA          dz
  k    r6eCN                     eOeCP                                          d                      e=d:;          Z<e<Q                    d<           e<Q                    d=           e<Q                    d>           eCR                                D ]4\  \  ZSZTZUe<>                    eSeT e'eUd?eUd@k     rdAndBC                     5eBV                     e4jW        e<                     t	 ddd           dS # 1 swxY w Y   dS dS )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     e Zd ZdZd fdZdd	Zdd
Z xZS )_RefreshThreadz3A thread that calls refresh() at regular intervals.live'Live'refresh_per_secondfloatreturnNonec                    || _         || _        t                      | _        t	                                          d           d S )NT)daemon)r"   r$   r   donesuper__init__)selfr"   r$   	__class__s      T/var/www/html/pixcura-vrs/venv/lib/python3.11/site-packages/pip/_vendor/rich/live.pyr,   z_RefreshThread.__init__   s>    	"4GG	%%%%%    c                8    | j                                          d S N)r*   setr-   s    r/   stopz_RefreshThread.stop   s    	r0   c                >   | j                             d| j        z            sz| j        j        5  | j                                         s| j                                         d d d            n# 1 swxY w Y   | j                             d| j        z            xd S d S )Nr   )r*   waitr$   r"   _lockis_setrefreshr4   s    r/   runz_RefreshThread.run"   s    )..T%<!<== 	( ( (y'')) (I%%'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( )..T%<!<== 	( 	( 	( 	( 	(s   3A..A25A2)r"   r#   r$   r%   r&   r'   r&   r'   )__name__
__module____qualname____doc__r,   r5   r;   __classcell__)r.   s   @r/   r!   r!      sk        ==& & & & & &   ( ( ( ( ( ( ( (r0   r!   c                      e Zd ZdZ	 d3dddddddddd	d4dZed5d            Zd6dZd7d8dZd9d Z	d:d"Z
d;d)Zd9d*Zd9d+Zed6d,            Zdd-d<d.Zd9d/Zd=d2ZdS )>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   boolrH   r$   r%   rI   rJ   rK   rL   r   rM   &Optional[Callable[[], RenderableType]]r&   r'   c       	           |dk    s
J d            || _         ||nt                      | _        || _        d| _        || _        || _        d | _        d | _        t                      | _
        d | _        || _        d| _        |rdn|| _        d | _        || _        |	| _        |
| _        t'          |                                 |	          | _        d| _        d S )Nr   zrefresh_per_second must be > 0FT)rL   )_renderabler   rF   _screen_alt_screen_redirect_stdout_redirect_stderr_restore_stdout_restore_stderrr   r8   
ipy_widgetrH   _startedrI   _refresh_threadr$   rL   _get_renderabler   rM   _live_render_nested)r-   rN   rF   rG   rH   r$   rI   rJ   rK   rL   rM   s              r/   r,   zLive.__init__9   s     "A%%%'G%%%%")"5ww;==  / /2626WW
)-(#!'6Y9="4!2-&!!5F
 
 
 r0   c                    | j         S )z'Check if live display has been started.)r\   r4   s    r/   
is_startedzLive.is_startedb   s     }r0   r   c                N    | j         |                                  n| j        }|pdS )N )r^   rT   )r-   rN   s     r/   rM   zLive.get_renderableg   s9     #/   """! 	
 Rr0   r:   c                   | j         5  | j        r	 ddd           dS d| _        | j                            |           sd| _        	 ddd           dS | j        r| j                            d          | _        | j                            d           | 	                                 | j        
                    |            |r9	 |                                  n## t          $ r |                                   w xY w| j        r3t          | | j                  | _        | j                                         ddd           dS # 1 swxY w Y   dS )z|Start live rendering display.

        Args:
            refresh (bool, optional): Also refresh. Defaults to False.
        NTF)r8   r\   rF   set_liver`   rU   set_alt_screenrV   show_cursor_enable_redirect_iopush_render_hookr:   	Exceptionr5   rH   r!   r$   r]   start)r-   r:   s     r/   rl   z
Live.starto   s    Z 	- 	-} 	- 	- 	- 	- 	- 	- 	- 	- !DM<((.. #	- 	- 	- 	- 	- 	- 	- 	- | E#'<#>#>t#D#D L$$U+++$$&&&L))$/// 	LLNNNN    
 IIKKK   -'5dD<S'T'T$$**,,,5	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s5   	E)EA0ECE C::=EEEc                   | j         5  | j        s	 ddd           dS d| _        | j                                         | j        r4| j        s| j                            | j                   	 ddd           dS | j        r'| j	         | j	        
                                 d| _	        d| _        | j        5  	 | j        s | j        j        s|                                  |                                  | j                                         | j        s%| j        j        r| j                                         | j                            d           | j        r| j                            d           | j        r8| j        s1| j                            | j                                                   | j         | j        r| j                                         n# |                                  | j                                         | j        s%| j        j        r| j                                         | j                            d           | j        r| j                            d           | j        r8| j        s1| j                            | j                                                   | j        !| j        r| j                                         w w w xY wddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )zStop live rendering display.NFvisibleT)r8   r\   rF   
clear_liver`   rI   printrN   rH   r]   r5   rL   rV   
is_jupyterr:   _disable_redirect_iopop_render_hookis_terminallinerh   rg   controlr_   restore_cursorr[   closer4   s    r/   r5   z	Live.stop   s   Z 	0 	0= 	0 	0 	0 	0 	0 	0 	0 	0 "DML##%%%| ~ 8L&&t777	0 	0 	0 	0 	0 	0 	0 	0   ,T%9%E$))+++'+$%.D" 0 00+ 'DL4K '--///L00222+ ,0H ,))+++L,,T222' ;33E:::~ Qd.> Q,,T->-M-M-O-OPPP2t~2--/// --///L00222+ ,0H ,))+++L,,T222' ;33E:::~ Qd.> Q,,T->-M-M-O-OPPP2t~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?AK?9<K?5K'7'GC<K'C>KK'K?'K+	+K?.K+	/K??LLr   c                @    |                      | j        d u           | S )Nr:   )rl   rT   r4   s    r/   	__enter__zLive.__enter__   s#    

4+47
888r0   exc_typeOptional[Type[BaseException]]exc_valOptional[BaseException]exc_tbOptional[TracebackType]c                .    |                                   d S r2   )r5   )r-   r|   r~   r   s       r/   __exit__zLive.__exit__   s     			r0   c                   | j         j        s| j         j        r| j        rgt	          t
          j        t                    sHt
          j        | _        t          dt          | j         t
          j                            t
          _        | j
        rkt	          t
          j        t                    sNt
          j        | _        t          dt          | j         t
          j                            t
          _        dS dS dS dS )z&Enable redirecting of stdout / stderr.r   N)rF   rt   rq   rW   
isinstancesysstdoutr   rY   r   rX   stderrrZ   r4   s    r/   ri   zLive._enable_redirect_io   s    <# 	Qt|'> 	Q$ QZ
I-N-N Q'*z$!(IdlCJ,O,OPP
$ QZ
I-N-N Q'*z$!(IdlCJ,O,OPP


	Q 	QQ Q Q Qr0   c                    | j         r&t          d| j                   t          _        d| _         | j        r(t          d| j                  t          _        d| _        dS dS )z'Disable redirecting of stdout / stderr.r   N)rY   r   r   r   rZ   r   r4   s    r/   rr   zLive._disable_redirect_io   s`     	(h(<==CJ#'D  	(h(<==CJ#'D   	( 	(r0   c                    | j         j        }|r| |d         u rt          d |D              }n|                                 }| j        rt          |          n|S )zwGet the renderable that is being displayed

        Returns:
            RenderableType: Displayed renderable.
        r   c                6    g | ]}|                                 S  )rM   ).0r"   s     r/   
<listcomp>z#Live.renderable.<locals>.<listcomp>   s$     N N N4!4!4!6!6 N N Nr0   )rF   _live_stackr   rM   rV   r   )r-   
live_stackrN   s      r/   rN   zLive.renderable   sk     \-
 	/$*Q-// N N: N N NOJJ,,..J%)%5Evj!!!:Er0   rz   c                   t          |t                    r| j                            |          }| j        5  || _        |r|                                  ddd           dS # 1 swxY w Y   dS )zUpdate 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_strr8   rT   r:   )r-   rN   r:   s      r/   updatezLive.update   s     j#&& 	=00<<JZ 	 	)D 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A""A&)A&c                   | j         5  | j                            | j                   | j        r>| j        j        r$| j        j        d                                          	 ddd           dS | j        j        r	 ddl	m
} ddlm} | j         |            | _         || j                   | j        5  | j                            d           | j                            | j        j                   ddd           n# 1 swxY w Y   n# t           $ r ddl}|                    d           Y nw xY w| j        j        rR| j        j        sF| j        5  | j                            t+                                 ddd           n# 1 swxY w Y   nS| j        sL| j        sE| j        5  | j                            t+                                 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z&Update the display of the Live Render.r   N)display)OutputT)r7   z(install "ipywidgets" for Jupyter support)r8   r_   set_renderablerN   r`   rF   r   r:   rq   IPython.displayr   
ipywidgetsr   r[   clear_outputrp   ImportErrorwarningswarnrt   is_dumb_terminalr   r\   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#OOOMM"LMMMMMN ) 2$,2O 2\ 2 2L&&wyy1112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 M2*..2 \ 2 2L&&wyy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   AG2-G2:D-G23A C?3G2?D	G2D	G2#D1.G20D11"G2'F:G2F
	
G2F
	G2''GG2G	G2!G	"G22G69G6renderablesList[ConsoleRenderable]c                0   | j         | j        _         | j        j        r_| j        5  | j        rt          j                    n| j                                        }|g|| j        }ddd           n# 1 swxY w Y   n| j	        s| j
        sg || j        }|S )z;Process renderables to restore cursor and display progress.N)rL   r_   rF   is_interactiver8   rV   r   homeposition_cursorr\   rI   )r-   r   resets      r/   process_renderableszLive.process_renderables  s    /3.D+<& 	< G G '=GLNNN*::<< 
  %F{FD4EFG G G G G G G G G G G G G G G 	<&*n	< <K;):;Ks   A A11A58A5r2   )rN   rO   rF   rP   rG   rQ   rH   rQ   r$   r%   rI   rQ   rJ   rQ   rK   rQ   rL   r   rM   rR   r&   r'   )r&   rQ   )r&   r   )F)r:   rQ   r&   r'   r<   )r&   r   )r|   r}   r~   r   r   r   r&   r'   )rN   r   r:   rQ   r&   r'   )r   r   r&   r   )r=   r>   r?   r@   r,   propertyrb   rM   rl   r5   r{   r   ri   rr   rN   r   r:   r   r   r0   r/   rC   rC   )   s        " 04' &*!$% $ $4>AE' ' ' ' ' 'R    X        -  -  -  -  -D 0  0  0  0D      Q Q Q Q( ( ( ( F F F XF EJ       2  2  2  2D     r0   rC   __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3zYou 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 workzSuch as [magenta]tables[/]...zPretty printed structures...examplezPretty printed)typetextz	Syntax...zGive it a try!)SGDMYREURUSDAUDJPYCNHHKDCADINRDKKGBPRUBNZDMXNIDRTWDTHBVND)rF   zDict[Tuple[str, str], float]exchange_rate_dictd   g?
      i@  zExchange Rates)titlezSource CurrencyzDestination CurrencyzExchange Ratez.4fg      ?redgreen)style)X
__future__r   r   	threadingr   r   r   typesr   typingr   r	   r
   r   r   r   r   r   r   rd   r   rF   r   r   r   r   r   rv   r   
file_proxyr   jupyterr   live_renderr   r   rG   r   r   r   typing_extensionsr   r!   rC   r=   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   r0   r/   <module>r      s   " " " " " " " 



 * * * * * * * * * *       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MMMKKK((((((((((      """"""giiGV
	" 	  F  E%&&E	MM#sC   	E899'&$455 u)**H  I* 
g			 !7*;=====U3ZZ 	7 	7E'I(>?O% 7 7..
3!6>!R((1,,KKX///BE"V]__s*a/C"OX#>? 3)**SS^^a-???&**440B0G0G0I0I+J+J1+MNNN$4555  !2333  !7888  1115G5M5M5O5O  1NVTMMM,22+83+>+>%%G      !!,%,u"5"5666677	7!7 !7 !7 !7 !7 !7 !7 !7 !7 !7 !7 !7 !7 !7 !7 !7 !7 !7O s   F"LLL