+
    j,iB8                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
HtHtHtHtHtHtHtHtHt ^ RIHt ^ RIHt ^ RIHtHtHt ^ RIHtHtHt ^ RI H!t! ^ R	I"H#t# ^ R
I$H%t% ^ RI&H't'H(t(H)t)H*t*H+t+H,t, ^ RI-H.t.H/t/ ^ RI0H1t1H2t2 ^ RI3H4t4H5t5 ^ RI6H7t7 ^ RI8H9t9 ^RI:H;t;H<t< R.t=]%t>]?! ]RR4      t@R R ltA]! R4      tB ! R R4      tC ! R R]/4      tD]! RRR7      tE ! R R]]E,          4      tFR# )z
Progress bar implementation on top of prompt_toolkit.

::

    with ProgressBar(...) as pb:
        for item in pb(data):
            ...
)annotationsN)	CallableGenericIterableIteratorSequenceSizedTextIOTypeVarcast)Application)get_app_session)	Conditionis_donerenderer_height_is_known)AnyFormattedTextStyleAndTextTuplesto_formatted_text)Input)KeyBindings)KeyPressEvent)ConditionalContainerFormattedTextControlHSplitLayoutVSplitWindow)	UIContent	UIControl)AnyDimensionD)
ColorDepthOutput)	BaseStyle)in_main_thread)	Formattercreate_default_formattersProgressBarSIGWINCHc                    V ^8  d   QhRRRR/# )   cancel_callbackCallable[[], None] | Nonereturnr    )formats   "L/usr/lib/python3/dist-packages/prompt_toolkit/shortcuts/progress_bar/base.py__annotate__r1   B   s      )B {     c                   a  \        4       pVP                  R4      R R l4       pS e   VP                  R4      R V 3R ll4       pV# )zi
Key bindings handled by the progress bar.
(The main thread is not supposed to handle any key bindings.)
zc-lc                    V ^8  d   QhRRRR/# r*   eventEr-   Noner.   )r/   s   "r0   r1   )create_key_bindings.<locals>.__annotate__J   s     # #a #D #r2   c                N    V P                   P                  P                  4        R # N)apprendererclear)r6   s   &r0   _clear#create_key_bindings.<locals>._clearI   s    		  "r2   zc-cc                    V ^8  d   QhRRRR/# r5   r.   )r/   s   "r0   r1   r9   P   s     	 	a 	D 	r2   c                "   < Sf   Q hS! 4        R# )zMKill the 'body' of the progress bar, but only if we run from the main thread.Nr.   )r6   r+   s   &r0   
_interrupt'create_key_bindings.<locals>._interruptO   s     #...r2   )r   add)r+   kbr?   rC   s   f   r0   create_key_bindingsrG   B   sO    
 
BVVE]# # "		 
	
 Ir2   _Tc                  ^    ] tR t^[tRtRR R lltR R ltR R ltRR	 R
 lltR R lt	Rt
R# )r'   a  
Progress bar context manager.

Usage ::

    with ProgressBar(...) as pb:
        for item in pb(data):
            ...

:param title: Text to be displayed above the progress bars. This can be a
    callable or formatted text as well.
:param formatters: List of :class:`.Formatter` instances.
:param bottom_toolbar: Text to be displayed in the bottom toolbar. This
    can be a callable or formatted text.
:param style: :class:`prompt_toolkit.styles.BaseStyle` instance.
:param key_bindings: :class:`.KeyBindings` instance.
:param cancel_callback: Callback function that's called when control-c is
    pressed by the user. This can be used for instance to start "proper"
    cancellation if the wrapped code supports it.
:param file: The file object used for rendering, by default `sys.stderr` is used.

:param color_depth: `prompt_toolkit` `ColorDepth` instance.
:param output: :class:`~prompt_toolkit.output.Output` instance.
:param input: :class:`~prompt_toolkit.input.Input` instance.
Nc               D    V ^8  d   QhRRRRRRRRRR	R
RRRRRRRRRRR/# )r*   titler   
formatterszSequence[Formatter] | Nonebottom_toolbarstylezBaseStyle | Nonekey_bindingszKeyBindings | Noner+   r,   filezTextIO | Nonecolor_depthzColorDepth | NoneoutputzOutput | NoneinputzInput | Noner-   r8   r.   )r/   s   "r0   r1   ProgressBar.__annotate__v   sx     (. (.(. /(. )	(.
  (. )(. 3(. (. '(. (. (. 
(.r2   c                	   Wn         T;'       g    \        4       V n        W0n        . V n        W@n        WPn        W`n        V P                  f   \        4       '       d   R R lpWn        Wn	        T	;'       g    \        4       P                  V n        T
;'       g    \        4       P                  V n        R V n        RV n        \        P                   ! 4       V n        R # )Nc                   V ^8  d   QhRR/# r*   r-   r8   r.   )r/   s   "r0   r1   *ProgressBar.__init__.<locals>.__annotate__   s     4 4t 4r2   c                 v    \         P                  ! \         P                  ! 4       \        P                  4       R # r;   )oskillgetpidsignalSIGINTr.   r2   r0   !keyboard_interrupt_to_main_thread?ProgressBar.__init__.<locals>.keyboard_interrupt_to_main_thread   s    		V]]3r2   F)rK   r&   rL   rM   countersrN   rO   r+   r$   rQ   r   rR   rS   _thread_has_sigwinch	threadingEvent_app_started)selfrK   rL   rM   rN   rO   r+   rP   rQ   rR   rS   r_   s   &&&&&&&&&&& r0   __init__ProgressBar.__init__v   s     
$CC(A(C,:<
(.
 'N,<,<4 $E  '88 1 8 855o/55
04"%OO-r2   c                   V ^8  d   QhRR/# )r*   r-   r'   r.   )r/   s   "r0   r1   rT      s     K K; Kr2   c                	n  a  \        \        \        V 3R  l4      ^RR7      \        V 3R l4      R7      p\        \        \        V 3R lRR7      R^R	7      \        ( \
        ,          \        V 3R
 l4      ,          R7      pR V 3R llpS P                   Uu. uF9  p\        \        S VS P                  4      \        P                  ! W44      R7      NK;  	  pp\        R\        \        V\        VV 3R lR7      \        4       V.4      4      S P                  S P                   RS P"                  S P$                  S P&                  R7      S n        R V 3R llp\*        P,                  ! 4       p\.        P0                  ! VP2                  V3R7      S n        S P4                  P7                  4        S # u upi )c                    < S P                   # r;   rK   rg   s   r0   <lambda>'ProgressBar.__enter__.<locals>.<lambda>   s	    TZZr2   zclass:progressbar,title)heightrN   c                     < S P                   R J# r;   rm   rn   s   r0   ro   rp      s    TZZt%;r2   )filterc                    < S P                   # r;   rM   rn   s   r0   ro   rp      s    D//r2   zclass:bottom-toolbar.text)rN   zclass:bottom-toolbar)rN   rq   c                     < S P                   R J# r;   ru   rn   s   r0   ro   rp      s     3 34 ?r2   c                    V ^8  d   QhRRRR/# )r*   	formatterr%   r-   r   r.   )r/   s   "r0   r1   +ProgressBar.__enter__.<locals>.__annotate__   s     	: 	:9 	: 	:r2   c                (   < V P                  SR 7      # ))progress_bar)	get_width)rx   rg   s   &r0   width_for_formatter2ProgressBar.__enter__.<locals>.width_for_formatter   s     &&D&99r2   )contentwidthg?c                 j   < \        \        S P                  4      \        S P                  4      R 7      # ))	preferredmax)r    lenra   rn   s   r0   ro   rp      s!    1*-dmm*<#dmmBT,r2   )rq   g333333?)min_redraw_intervallayoutrN   rO   refresh_intervalrQ   rR   rS   c                   V ^8  d   QhRR/# rW   r.   )r/   s   "r0   r1   ry      s     	 	T 	r2   c                    <  SP                   P                  SP                  P                  R 7       R#   \         d,   p \
        P                  ! 4        \        T 4        Rp ? R# Rp ? ii ; i))pre_runN)r<   runrf   setBaseException	traceback	print_excprint)erg   s    r0   r   "ProgressBar.__enter__.<locals>.run   sK    T%6%6%:%:;  ##%as   05 A+  A&&A+)targetargs)r   r   r   r   r   r   rL   _ProgressControlr+   	functoolspartialr   r   r   r   rN   rO   rQ   rR   rS   r<   contextvarscopy_contextrd   Threadr   rb   start)rg   title_toolbarrM   r}   fprogress_controlsr   ctxs   f       r0   	__enter__ProgressBar.__enter__   s   ,$%78/
 ;<
 .$/7R - 8&'?@A
	: 	: __

 %	 (q$2F2FG''(;? % 	 
 '2 $%-$ &
 **** ((;;**-'
4	 	 $/#;#;#= ''swwcVD]
s   ?F2c                    V ^8  d   QhRRRR/# )r*   aobjectr-   r8   r.   )r/   s   "r0   r1   rT      s        6  d  r2   c                	h   V P                   P                  4        V P                  P                  '       dR   V P                  P                  e:   V P                  P                  P                  V P                  P                  4       V P                  e   V P                  P                  4        R # R # r;   )	rf   waitr<   
is_runningloopcall_soon_threadsafeexitrb   join)rg   r   s   &*r0   __exit__ProgressBar.__exit__   sr     	  88488==#<HHMM..txx}}=<<#LL $r2   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r*   datazIterable[_T] | Nonelabelr   remove_when_donebooltotal
int | Noner-   zProgressBarCounter[_T]r.   )r/   s   "r0   r1   rT      s<      !   	
  
 r2   c                X    \        WW#VR7      pV P                  P                  V4       V# )a  
Start a new counter.

:param label: Title text or description for this progress. (This can be
    formatted text as well).
:param remove_when_done: When `True`, hide this progress bar.
:param total: Specify the maximum value if it can't be calculated by
    calling ``len``.
)r   r   r   )ProgressBarCounterra   append)rg   r   r   r   r   counters   &&&&& r0   __call__ProgressBar.__call__   s.      %ee
 	W%r2   c                   V ^8  d   QhRR/# rW   r.   )r/   s   "r0   r1   rT     s      D r2   c                	:    V P                   P                  4        R # r;   )r<   
invalidatern   s   &r0   r   ProgressBar.invalidate  s    r2   )rf   rc   rb   r<   rM   r+   rQ   ra   rL   rS   rO   rR   rN   rK   )
NNNNNNNNNNN FN)__name__
__module____qualname____firstlineno____doc__rh   r   r   r   r   __static_attributes__r.   r2   r0   r'   r'   [   s(    4(.TKZ , r2   c                  J    ] tR tRtRtR R ltR R ltR R ltR	 R
 ltRt	R# )r   i  z$
User control for the progress bar.
c               (    V ^8  d   QhRRRRRRRR/# )	r*   r{   r'   rx   r%   r+   r,   r-   r8   r.   )r/   s   "r0   r1   _ProgressControl.__annotate__  s8     B B!B B 3	B
 
Br2   c                	>    Wn         W n        \        V4      V n        R # r;   )r{   rx   rG   _key_bindings)rg   r{   rx   r+   s   &&&&r0   rh   _ProgressControl.__init__  s     )"0Ar2   c               $    V ^8  d   QhRRRRRR/# )r*   r   intrq   r-   r   r.   )r/   s   "r0   r1   r   #  s&     V VC V V Vr2   c                	T  a . oV P                   P                   FD  p V P                  P                  V P                   W14      pSP                  \        V4      4       KF  	  R V3R llp\        V\        S4      RR7      #   \         d    \
        P                  ! 4        R p Lbi ; i)ERRORc                    V ^8  d   QhRRRR/# )r*   ir   r-   r   r.   )r/   s   "r0   r1   5_ProgressControl.create_content.<locals>.__annotate__/  s     	 	 	 2 	r2   c                   < SV ,          # r;   r.   )r   itemss   &r0   get_line1_ProgressControl.create_content.<locals>.get_line/  s    8Or2   F)r   
line_countshow_cursor)r{   ra   rx   r/   r   r   r   r   r   r   r   )rg   r   rq   prtextr   r   s   &&&   @r0   create_content_ProgressControl.create_content#  s    *,##,,B~~,,T->->J
 LL*401 -	 	 (s5zuUU ! ##%s   &B"B'&B'c                   V ^8  d   QhRR/# r*   r-   r   r.   )r/   s   "r0   r1   r   4  s      d r2   c                	    R # )Tr.   rn   s   &r0   is_focusable_ProgressControl.is_focusable4  s    r2   c                   V ^8  d   QhRR/# )r*   r-   r   r.   )r/   s   "r0   r1   r   7  s     " "+ "r2   c                	    V P                   # r;   )r   rn   s   &r0   get_key_bindings!_ProgressControl.get_key_bindings7  s    !!!r2   )r   rx   r{   N)
r   r   r   r   r   rh   r   r   r   r   r.   r2   r0   r   r     s"    BV"" "r2   r   _CounterItemT)	covariantc                     ] tR tRtRtRR R lltR R ltR R	 lt]R
 R l4       t	]	P                  R R l4       t	]R R l4       t]P                  R R l4       t]R R l4       t]R R l4       t]R R l4       tRtR# )r   i>  zD
An individual counter (A progress bar can have multiple counters).
Nc               0    V ^8  d   QhRRRRRRRRR	R
RR/# )r*   r{   r'   r   zIterable[_CounterItem] | Noner   r   r   r   r   r   r-   r8   r.   )r/   s   "r0   r1   ProgressBarCounter.__annotate__C  sF      ! ,  	
   
r2   c                	2   \         P                   P                  4       V n        R V n        Wn        W n        ^ V n        W0n        W@n        RV n	        V  Vf"    \        \        \        V4      4      V n        R # WPn        R #   \         d    R T n         R # i ; i)NF)datetimenow
start_time	stop_timer{   r   items_completedr   r   _doner   r   r   r   	TypeError)rg   r{   r   r   r   r   s   &&&&&&r0   rh   ProgressBarCounter.__init__C  s     #++//137(	 
 0
=" eT!23
 J  "!
"s   B   BBc                   V ^8  d   QhRR/# )r*   r-   zIterator[_CounterItem]r.   )r/   s   "r0   r1   r   ]  s     J J0 Jr2   c              #  	   "   V P                   e9    V P                    F  pVx  V P                  4        K  	  RV n        RV n        R # \	        R4      h  RT n        i ; i5i)NTz No data defined to iterate over.)r   item_completeddonestoppedNotImplementedError)rg   items   & r0   __iter__ProgressBarCounter.__iter__]  s[     99 
$ IIDJ'') &
 !	  $%&HII  $s   A .A  A 	AA c                   V ^8  d   QhRR/# rW   r.   )r/   s   "r0   r1   r   m  s     ' ' 'r2   c                l    V ;P                   ^,          un         V P                  P                  4        R# )zm
Start handling the next item.

(Can be called manually in case we don't have a collection to loop through.)
N)r   r{   r   rn   s   &r0   r   !ProgressBarCounter.item_completedm  s'     	!$$&r2   c                   V ^8  d   QhRR/# r   r.   )r/   s   "r0   r1   r   w  s     	 	d 	r2   c                    V P                   # )a  Whether a counter has been completed.

Done counter have been stopped (see stopped) and removed depending on
remove_when_done value.

Contrast this with stopped. A stopped counter may be terminated before
100% completion. A done counter has reached its 100% completion.
)r   rn   s   &r0   r   ProgressBarCounter.donev  s     zzr2   c                    V ^8  d   QhRRRR/# r*   valuer   r-   r8   r.   )r/   s   "r0   r1   r     s     4 4$ 44 4r2   c                	    Wn         Wn        V'       d<   V P                  '       d(   V P                  P                  P                  V 4       R # R # R # r;   )r   r   r   r{   ra   removerg   r  s   &&r0   r   r    s;    
T***&&--d3 +5r2   c                   V ^8  d   QhRR/# r   r.   )r/   s   "r0   r1   r     s     * * *r2   c                    V P                   RJ# )ay  Whether a counter has been stopped.

Stopped counters no longer have increasing time_elapsed. This distinction is
also used to prevent the Bar formatter with unknown totals from continuing to run.

A stopped counter (but not done) can be used to signal that a given counter has
encountered an error but allows other counters to continue
(e.g. download X of Y failed). Given how only done counters are removed
(see remove_when_done) this can help aggregate failures from a large number of
successes.

Contrast this with done. A done counter has reached its 100% completion.
A stopped counter may be terminated before 100% completion.
N)r   rn   s   &r0   r   ProgressBarCounter.stopped  s      ~~T))r2   c                    V ^8  d   QhRRRR/# r  r.   )r/   s   "r0   r1   r     s     " "T "d "r2   c                	    V'       d:   V P                   '       g&   \        P                  P                  4       V n         R # R # R V n         R # r;   )r   r   r   r	  s   &&r0   r   r    s2    >>>!)!2!2!6!6!8 " "DNr2   c                   V ^8  d   QhRR/# )r*   r-   floatr.   )r/   s   "r0   r1   r     s     C CE Cr2   c                	~    V P                   f   ^ # V P                  ^d,          \        V P                   ^4      ,          # r;   )r   r   r   rn   s   &r0   
percentageProgressBarCounter.percentage  s0    ::''#-DJJ0BBBr2   c                   V ^8  d   QhRR/# )r*   r-   zdatetime.timedeltar.   )r/   s   "r0   r1   r     s     4 40 4r2   c                    V P                   f0   \        P                  P                  4       V P                  ,
          # V P                   V P                  ,
          # )z8
Return how much time has been elapsed since the start.
)r   r   r   r   rn   s   &r0   time_elapsedProgressBarCounter.time_elapsed  s?    
 >>!$$((*T__<<>>DOO33r2   c                   V ^8  d   QhRR/# )r*   r-   zdatetime.timedelta | Noner.   )r/   s   "r0   r1   r     s     	Q 	Q4 	Qr2   c                $   V P                   e   V P                  '       g   R# V P                  '       g   V P                  '       d   \        P
                  ! ^ 4      # V P                  ^dV P                  ,
          ,          V P                  ,          # )z'
Timedelta representing the time left.
N)r   r  r   r   r   	timedeltar  rn   s   &r0   	time_leftProgressBarCounter.time_left  s^    
 ::T___YYY$,,,%%a(($$doo(=>PPr2   )r   r   r   r   r   r{   r   r   r   r   r   r   )r   r   r   r   r   rh   r   r   propertyr   setterr   r  r  r  r   r.   r2   r0   r   r   >  s    4J ' 	 	 
[[4 4 * *" ^^" " C C 4 4 	Q 	Qr2   r   )Gr   
__future__r   r   r   r   rZ   r]   rd   r   typingr   r   r   r   r   r   r	   r
   r   prompt_toolkit.applicationr   "prompt_toolkit.application.currentr   prompt_toolkit.filtersr   r   r   prompt_toolkit.formatted_textr   r   r   prompt_toolkit.inputr   prompt_toolkit.key_bindingr   (prompt_toolkit.key_binding.key_processorr   prompt_toolkit.layoutr   r   r   r   r   r   prompt_toolkit.layout.controlsr   r   prompt_toolkit.layout.dimensionr   r    prompt_toolkit.outputr!   r"   prompt_toolkit.stylesr#   prompt_toolkit.utilsr$   rL   r%   r&   __all__r7   getattr	_SIGWINCHrG   rH   r'   r   r   r   r.   r2   r0   <module>r1     s    #    	   
 
 
 3 > O O 
 ' 2 B  @ ; 4 + / </FJ-	, T]v vr$"y $"N ~6CQ. CQr2   