
    SThRb                     8   d Z ddlZddlZddlZddlZddlmZ ddlmZm	Z	m
Z
mZ ddlmZmZ ddlmZmZ ddlmZ dd	lmZmZ d
dlmZ d
dlmZmZmZmZ d
dlmZm Z m!Z!m"Z"m#Z#m$Z$ d.ddde
e%   de
e%   defdZ&ed.dejN                  dddd       Z( G d d      Z) G d d      Z* G d de*      Z+ G d de*      Z, G d de,      Z- G d  d!      Z.d" Z/d# Z0d$ Z1d.d%Z2 ed&      Z3d.ddd'd(ee3   de
e%   d)e	egdf   de
e%   ded*ee3   fd+Z4 G d, d-ee3         Z5y)/z
This module must always be importable, even without the required libs for install!
It's because I import metadata from main init, directly in setup.py, which imports this.
    N)contextmanager)AnyCallableOptionalTypeVar)
CollectionIterable   )calibrated_fps
custom_fps)config_handler)buffered_hook_managerpassthrough_hook_manager   )terminal)combine_cells	fix_cellsprint_cellsto_cells)eta_textfn_simple_eta gen_simple_exponential_smoothingtime_displayRUNEND	calibratetotalr   optionsc                    	 t        di |}t	        || |      S # t        $ r } t        |      t        |            dd}~ww xY w)u  An alive progress bar to keep track of lengthy operations.
    It has a spinner indicator, elapsed time, throughput and ETA.
    When the operation finishes, a receipt is displayed with statistics.

    If the code is executed in a headless environment, ie without a
    connected tty, all features are disabled but the final receipt.

    Another cool feature is that it tracks the actual count in regard of the
    expected count. So it will look different if you send more (or less) than
    expected.

    Also, the bar installs a hook in the system print function that cleans
    any garbage out of the terminal, allowing you to print() effortlessly
    while using the bar.

    Use it like this:

    >>> from alive_progress import alive_bar
    ... with alive_bar(123, title='Title') as bar:  # <-- expected total and bar title
    ...     for item in <iterable>:
    ...         # process item
    ...         bar()  # makes the bar go forward

    The `bar()` method should be called whenever you want the bar to go forward.
    You usually call it in every iteration, but you could do it only when some
    criteria match, depending on what you want to monitor.

    While in a progress bar context, you have two ways to output messages:
      - the usual Python `print()` statement, which will properly clean the line,
        print an enriched message (including the current bar position) and
        continue the bar right below it;
      - the `bar.text('message')` call, which sets a situational message right within
        the bar, usually to display something about the items being processed or the
        phase the processing is in.

    If the bar is over or underused, it will warn you!
    To test all supported scenarios, you can do this:
    >>> for x in 1000, 1500, 700, 0:
    ...    with alive_bar(x) as bar:
    ...        for i in range(1000):
    ...            time.sleep(.005)
    ...            bar()
    Expected results are these (but you have to see them in motion!):
|████████████████████████████████████████| 1000/1000 [100%] in 6.0s (167.93/s)
|██████████████████████████▋⚠            | (!) 1000/1500 [67%] in 6.0s (167.57/s)
|████████████████████████████████████████✗ (!) 1000/700 [143%] in 6.0s (167.96/s)
|████████████████████████████████████████| 1000 in 5.8s (171.91/s)

    Args:
        total (Optional[int]): the total expected count
        calibrate (float): maximum theoretical throughput to calibrate animation speed
        **options: custom configuration options, which override the global configuration:
            title (Optional[str]): an optional, always visible bar title
            length (int): the number of cols to render the actual bar in alive_bar
            max_cols (int): the maximum cols to use if not possible to fetch it, like in jupyter
            spinner (Union[None, str, object]): the spinner style to be rendered next to the bar
                accepts a predefined spinner name, a custom spinner factory, or None
            bar (Union[None, str, object]): the bar style to be rendered in known modes
                accepts a predefined bar name, a custom bar factory, or None
            unknown (Union[str, object]): the bar style to be rendered in the unknown mode
                accepts a predefined spinner name, or a custom spinner factory (cannot be None)
            theme (str): a set of matching spinner, bar and unknown
                accepts a predefined theme name
            force_tty (Optional[int|bool]): forces a specific kind of terminal:
                False -> disables animations, keeping only the the final receipt
                True -> enables animations, and auto-detects Jupyter Notebooks!
                None (default) -> auto select, according to the terminal/Jupyter
            file (object): use `sys.stdout`, `sys.stderr`, or a similar `TextIOWrapper` object
            disable (bool): if True, completely disables all output, do not install hooks
            manual (bool): set to manually control the bar position
            enrich_print (bool): enriches print() and logging messages with the bar position
            enrich_offset (int): the offset to apply to enrich_print
            receipt (bool): prints the nice final receipt, disables if False
            receipt_text (bool): set to repeat the last text message in the final receipt
            monitor (bool|str): configures the monitor widget `152/200 [76%]`
                send a string with `{count}`, `{total}` and `{percent}` to customize it
            elapsed (bool|str): configures the elapsed time widget `in 12s`
                send a string with `{elapsed}` to customize it
            stats (bool|str): configures the stats widget `(~12s, 123.4/s)`
                send a string with `{rate}` and `{eta}` to customize it
            monitor_end (bool|str): configures the monitor widget within final receipt
                same as monitor, the default format is dynamic, it inherits monitor's one
            elapsed_end (bool|str): configures the elapsed time widget within final receipt
                same as elapsed, the default format is dynamic, it inherits elapsed's one
            stats_end (bool|str): configures the stats widget within final receipt
                send a string with `{rate}` to customize it (no relation to stats)
            title_length (int): fixes the title lengths, or 0 for unlimited
                title will be truncated if longer, and a cool ellipsis "…" will appear at the end
            spinner_length (int): forces the spinner length, or `0` for its natural one
            refresh_secs (int): forces the refresh period, `0` for the reactive visual feedback
            ctrl_c (bool): if False, disables CTRL+C (captures it)
            dual_line (bool): if True, places the text below the bar
            unit (str): any text that labels your entities
            scale (any): the scaling to apply to units: 'SI', 'IEC', 'SI2'
            precision (int): how many decimals do display when scaling
    Nr    )r   	Exceptiontypestr__alive_bar)r   r   r   configes        a/home/www/backend.miabetepe.com/venv/lib/python3.12/site-packages/alive_progress/core/progress.py	alive_barr)      sN    D(*'* vu	::  (d1gc!fo4'(s    	A?AF)r   _cond	_sampling_testingc             #        !"#$%&'()*+,-./0123456K   9t        t              s"t        dt              j                   d      dk  rd!$/34fd/d\  /_        /_        /_        /_        d\  /_	        /_
        /_        d\  /_        /_        /_        }d	\  /_        /_        /_        |rd
/_        d/_        t$        *n&-/fd*dG *+/1fd	dH /3fd	}dH /fd	} j&                  r'/fdns	dI'/fd	ndIdd'/fddJ!'/3fd	0'/3fd2t(        !023fd       }	s j&                  s/fdc) j*                  ddc6}
}nd/fdc)d j*                   ddc6}
}r j&                  s/fdn-dt-        j.                          |       c4!t1               \   j2                  rt5         j2                        nt7        |xs |
      $t9        d d!       &&j;                  d        j<                  r t?        j@                         tC               c3'n\t?        jD                   jF                   jH                   jJ                        3tM         jN                  r|nd" jP                  3      '3jR                  r7t-        jT                  /tW               #      4d$4_,        4j[                           j\                  sdH fd%	(/6fd&.nbddl/}d'd(d)d* j\                     \  }}|j`                  jc                  d||      "|jd                  jg                  d||      #dH"6fd+	(#/6fd,. jh                  f(/5fd-	,),fd.}/fd/}/fd0}./6fd1}s j&                  r2%./6fd2}t9        d3tk        )            %%j;                  d       d4}n./fd5}jl                  d6}r j&                  r	d7}/fd8nd9}/fd:nd;  j&                  rd<}nd=} (xs d      5to        , jp                  |      +to        | jr                  +jt                  dd>       }to        | j                  d?       to        | jv                   jt                  dd>       }to        | jx                  |      1to        | jz                  1jt                  dd> rd6nd"      }/fd@}t}        |	||/fdA/fdB/fdC/fdD|	       |        |       f  0        	 |sn	t                 2        4r4dc}4|j                          |r03j                         /j                  z
  dEk  r3j                           j                  rX|||c 1+j                  d"c/_         j                  s |        3j                           3       3j                  dF       n3j                          t$        *3j                          y# t        $ r d$} j                  r Y w xY w#  2        4r4dc}4|j                          |r03j                         /j                  z
  dEk  r3j                           j                  rX|||c 1+j                  d"c/_         j                  s |        3j                           3       3j                  dF       n3j                          t$        *3j                          w xY ww)KzActual alive_bar handler, that exposes internal functions for configuration of
    both normal operation and sampling overhead.Nz integer argument expected, got 'z'.r   c                     5  rJj                           t        |       |       j                  d j                        z         rJd d d        y # 1 sw Y   y xY w)N      ?)waitnextrate)	spinner_playerspinner_suffix
alive_reprcond_refreshevent_rendererfpsruntermthreads	     r(   r9   z__alive_bar.<locals>.run   s[     	6##%4n!5~F!!"s388}"45 	6 	6 	6s   AAA#)        r<   r<   r<   )r   r   r   )NNNF)?r=   r=   gGz?gQEJ@c                      t        j                         j                  z
  _         j	                          j                  f      _        y N)timeperf_counterinitelapsedsendr2   )gen_rate	processedr9   s   r(   main_update_hookz%__alive_bar.<locals>.main_update_hook   s7    ++-8CK}}ik3;;%?@CH    c           	      @            	j                    	j                        ||                 
       g	j                  }t        || j	                         | 	j
                        	_        | j                  	j                         | j                          y r?   )	titlepercenttextr   colslast_lenwritesuffixflush)outspinnerr4   	fragmentsbar_repr
bar_suffixrC   rG   monitorr9   statss       r(   r5   z__alive_bar.<locals>.alive_repr   sx    YY 5z7NY	57?58XX?	 #9chhj#s||L		#**		rH   c                     | rDj                   r8dt        t        |             fj                  j                  c_        _        y t        | d n
t        |             fdc_        _        y )N
 )	dual_liner   r$   cursor_up_1sequencerL   rP   )rL   r&   r9   r:   s    r(   set_textz__alive_bar.<locals>.set_text   s[    F$$$((3t9*=#>@P@P@Y@Y CHcj$,T\Ts4y$Q#SUW CHcjrH   c                     t        | d n
t        |             _        j                  rxj                  dz  c_        y y )N )_render_titler$   rJ   )rJ   r&   r9   s    r(   	set_titlez__alive_bar.<locals>.set_title   s5    !&%-$SZP	99III rH   c                 h    j                          t        dt        |             _                 y )Nr<   )flush_buffersmaxfloatrK   )rK   bar_update_hookhook_managerr9   s    r(   barz__alive_bar.<locals>.bar   s'    &&(b%.1CKrH   c                     j                          xj                  t        |       z  c_        t        dj                        _                 y Nr   )rf   countintrg   )rn   ri   rj   r9   s    r(   rk   z__alive_bar.<locals>.bar   s9    &&(IIU#IAsyy)CIrH   F)skippedc                   j                          t        |       } xj                  | z  c_        t        dj                        _        |s0xj                  | z  c_        t        dj                        _                 y rm   )rf   ro   rn   rg   rF   )rn   rp   ri   rj   r9   s     r(   rk   z__alive_bar.<locals>.bar   sa    &&(JEIIIAsyy)CI& #As}} 5rH   c                     j                          j                          _        t        j                         | z
  _        j                          y r?   )hide_cursorinstall_handler@   rA   rB   set)offsetrk   
bar_handler7   rj   r9   r:   s    r(   start_monitoringz%__alive_bar.<locals>.start_monitoring   sD     
$$&/rH   c                      j                          j                          d  _        t        j                         j
                  z
  S r?   )show_cursor	uninstallru   r@   rA   rB   )rx   rj   r9   r:   s   r(   stop_monitoringz$__alive_bar.<locals>.stop_monitoring   s;     !
  "SXX--rH   c               3      K   j                                  }         j                  d       j                          	 d   |        y #  |        w xY ww)NrZ   )clearrO   rQ   )rw   r5   r7   ry   r}   r:   s    r(   pause_monitoringz%__alive_bar.<locals>.pause_monitoring   sQ      "4

4

	%V$V$s   AAA 		A
AAc                       j                   S r?   )rn   r9   s   r(   <lambda>z__alive_bar.<locals>.<lambda>   s    cii rH   g    .Az	on {:d}: r/   c                       j                   S r?   )rK   r   s   r(   r   z__alive_bar.<locals>.<lambda>   s    3;; rH   %zon {:.1%}: c                       j                   S r?   )rF   r   s   r(   r   z__alive_bar.<locals>.<lambda>   s     rH   g333333?c                     | |z  S r?   r!   )poselapses     r(   r   z__alive_bar.<locals>.<lambda>   s
    f rH   r[   )targetargsTc                 $    |  j                    S r?   )unit)value
_precisionr&   s     r(   human_countz __alive_bar.<locals>.human_count  s    WV[[M**rH   c                 0    j                   d|  d dS )N.fz/sr2   )	precisionr9   r   s    r(   	rate_textz__alive_bar.<locals>.rate_text  s#    hhq1n-dV266rH   )FF)TF)TT)SISI2IECc                      | |      S r?   r!   )r   r   fn_human_countr   s     r(   r   z __alive_bar.<locals>.human_count  s    !%y99rH   c                 ,     j                   |       S r?   r   )r   fn_human_throughputr9   r   s    r(   r   z__alive_bar.<locals>.rate_text  s    &sxxyAArH   c                      j                   |      _        | j                  j                  j                        S )N)rn   r   rK   )rn   monitor_textformatrK   )r   r   r   r9   total_humans     r(   monitor_runz __alive_bar.<locals>.monitor_run  s5    &syy)<xxc..k3;;xWWrH   c                 >            k7  rdnd}|  | d        S )Nz(!) r[   r!   )r   warningcurrentlogic_totalr   r   s     r(   monitor_endz __alive_bar.<locals>.monitor_end  s0    !-'){2J&PR;q$/011rH   c                 X    | j                  t        j                  t                    S NrC   )r   r   rC   r   r   r9   s    r(   elapsed_runz __alive_bar.<locals>.elapsed_run      xxS[[# >x??rH   c                 X    | j                  t        j                  t                    S r   )r   r   rC   r   r   s    r(   elapsed_endz __alive_bar.<locals>.elapsed_end!  r   rH   c                 X     d      _         | j                  j                         S )Nr   )r2   r   r   r   )r   r   r9   r   s    r(   	stats_endz__alive_bar.<locals>.stats_end$  s%    !!xxS]]x66rH   c                      d      _         t        j                          j                  f            _        | j	                  j                   j                        S )Nr
   )r2   r   eta)r   r   rD   r2   r   )r   r   gen_etar   r9   r   s    r(   	stats_runz__alive_bar.<locals>.stats_run)  sK    %aLCM#GLL')SXX1F$GHCL88Ts||8LLrH   g      ?z({eta}, {rate})c                 X     d      _         | j                  j                   d      S )Nr
   r=   )r2   r   r   )r   r   r9   s    r(   r   z__alive_bar.<locals>.stats_run2  s%    %aLCM88C888rH   z({rate})z{percent:.0%} [{count}/{total}]c                  T    t        j                   j                  z         _        y r?   )mathceilrK   rn   r9   r   s   r(   ri   z$__alive_bar.<locals>.bar_update_hook=  s     IIckkE&9:	rH   z{count}/{total} [{percent:.0%}]c                  .     j                   z   _        y r?   )rn   rK   r   s   r(   ri   z$__alive_bar.<locals>.bar_update_hookB  s    !ii%/rH   c                       y r?   r!   r!   rH   r(   ri   z$__alive_bar.<locals>.bar_update_hookE      rH   z{percent:.0%}z{count}zin {elapsed}c                      t        j                         } t        j                  | dd      }d_         |       | j                         j                         S )NTi  r   )ioStringIOr   get_termrN   getvaluestrip)buffertbufr5   r9   s     r(   get_receiptz __alive_bar.<locals>.get_receiptV  sG      t44 &&((rH   c                       j                   S r?   )r   r   s   r(   r   z__alive_bar.<locals>.<lambda>^  s    33C3C rH   c                       j                   S r?   )r   r   s   r(   r   z__alive_bar.<locals>.<lambda>^  s    S]] rH   c                       j                   S r?   )r   r   s   r(   r   z__alive_bar.<locals>.<lambda>_  s    #,, rH   c                       j                   S r?   r   r   s   r(   r   z__alive_bar.<locals>.<lambda>_  s     rH   r   rZ   )NNr?   )r
   )r<   )L
isinstancero   	TypeErrorr#   __name__r2   rB   rC   rK   rn   rF   rN   rL   rJ   rP   r   r   r   _noopmanualr   r   	threadingEvent_create_barsrefresh_secsr   r   r   rD   disabler   get_voidr   r   file	force_ttymax_colsr   enrich_printenrich_offsetinteractiveThread_create_spinner_playerdaemonstartscale
about_timer   r   human_throughputr   r   r   unknown_WidgetrW   r   r   r   rX   r   __AliveBarHandlelocalsKeyboardInterruptctrl_cjoinrM   r]   receiptendreceipt_textclear_end_screenrO   
clear_linerQ   )7r&   r   r   r*   r+   r,   r   r_   rd   r   factorheaderr   d1024iecr   r   r   r   r   stats_defaultmonitor_defaultr   
local_copyr5   rk   rx   rU   rV   ri   r6   r   rC   r7   r   r   r8   r   rE   rj   r   r   rG   rW   r   rF   r   r9   ry   rX   r}   r:   r;   r   r   s7   ``                      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@r(   r%   r%      sH     %%>tE{?S?S>TTVWXXA:E6 6 4B0CHchS[-4*CIs}cl.E+CHciV4A1CclCM 	A X 
 }}	 	 		E 	 	 . 	% 	% FMM$&7W%{{D+ff!#6W!"6;;-0"mff+0&GI+/1BEG(FNL'/Hj.4.A.A:f))*y2F3 /4TUHMM$~~%..02J2Ll  f.>.>P,v7J7JVPR-4f6J6JLZ^` !!3I&3QR<<	+	7 	  
 ,,	
s
 $//>>ueSQ(99MMeUZ\_`	:	B "(!1!1 X2@@7 	M 	M
 32}[7QRT)	9 ##"==?O; @O0	 ==-O'Oejq)Kk6>>?CG+v'9'9799Sb>JKk6>>>BG+v'9'9799Sb>JKIv||];E	6#3#35773B<ZUWXI) ""2Ix")+CEZ"68K[ZJ J	 )jvx7 	!'JOO diikCLL014>>&19k#GUG#+<< Hcj&&
!!#tJJtOO 

3  == 
 	!'JOO diikCLL014>>&19k#GUG#+<< Hcj&&
!!#tJJtOO 

s8   S2[>X &C[>XX XX C[;;[>c                       e Zd Zd Zd Zy)r   c                     || _         t        |t              r|| _        n|r|| _        nd| _        | j                  r| xj                  dz  c_        y y )Nr[   rb   )funcr   r$   r   )selfr   r   defaults       r(   __init__z_Widget.__init__  sD    	eS!DFDFDF66FFcMF rH   c                 8    | j                  | j                        S r?   )r   r   )r   s    r(   __call__z_Widget.__call__  s    yy  rH   N)r   
__module____qualname__r   r   r!   rH   r(   r   r     s    
!rH   r   c                   $    e Zd ZdZd ZddZd Zy)_ReadOnlyPropertyzOA descriptor that provides a read-only property, which calls a getter function.c                     d| | _         y )N_)prop)r   ownernames      r(   __set_name__z_ReadOnlyProperty.__set_name__  s    vJ	rH   Nc                 8     t        || j                               S r?   getattrr  r   objobjtypes      r(   __get__z_ReadOnlyProperty.__get__  s    &wsDII&((rH   c                 :    t        d| j                  dd   d      )NzCannot set "r
   ")AttributeErrorr  r   r  r   s      r(   __set__z_ReadOnlyProperty.__set__  s     |DIIabM?!<==rH   r?   )r   r   r  __doc__r	  r  r  r!   rH   r(   r  r    s    Y)>rH   r  c                       e Zd ZdZddZy)_GatedFunctionzJA gated descriptor that provides a function only while the bar is running.Nc                 R    |j                   rt        || j                        S t        S r?   )ru   r  r  r   r  s      r(   r  z_GatedFunction.__get__  s    ;;3		**rH   r?   r   r   r  r  r  r!   rH   r(   r  r    s
    TrH   r  c                       e Zd ZdZddZy)	_FunctionzOAn ungated descriptor that provides a function even after the bar has finished.Nc                 .    t        || j                        S r?   r  r  s      r(   r  z_Function.__get__  s    sDII&&rH   r?   r  r!   rH   r(   r  r    s
    Y'rH   r  c                       e Zd ZdZd Zy)_AssignFunctionzVAn ungated descriptor that provides a setter function even after the bar has finished.c                 2     | j                  |      |       y r?   )r  r  s      r(   r  z_AssignFunction.__set__  s    S% rH   N)r   r   r  r  r  r!   rH   r(   r  r    s
    `!rH   r  c                       e Zd Z e       Z e       Z e       Z e       Z	 e       Z
 e       Z e       Z e       Z e       Zd Zd Zy)r   c
                     d ||c| _         | _        | _        ||c| _        | _        |||c| _        | _        | _        ||	c| _        | _	        y r?   )
ru   _pause_current_title_text_monitor_rate_eta_elapsed_receipt)
r   pauserd   r_   get_currentget_monitorget_rateget_etaget_elapsedr   s
             r(   r   z__AliveBarHandle.__init__  sN    370dk4="+XTZ/:Hg,tz49'2K$t}rH   c                 B    | j                   r | j                   |i | y y r?   )ru   r   r   kwargss      r(   r   z__AliveBarHandle.__call__  s!    <<DLL$)&) rH   N)r   r   r  r  r,  r  r   r  rL   rJ   rW   r2   r   rC   r  r   r   r   r!   rH   r(   r   r     sT    E!GDE!GD

C!GkG@*rH   r   c                       y r?   r!   _args_kwargss     r(   r   r     s    rH   c                     | j                   }|d }||c|_        |_        |dfS  || j                  | j                        dfS )Nc                       y r?   r!   r6  s     r(   r  z_create_bars.<locals>.obj  r   rH   r[   rb   )rk   r   r   length)r&   rk   r  s      r(   r   r     sJ    
**C
{	  #CSWBwv}}fnn-s22rH   c                 ~    | j                   }|ddlm}  |d      dfS ddlm}  | || j
                              dfS )Nr   )repeatr[   r   )r3   rb   )rS   	itertoolsr=  animations.utilsr3   spinner_length)r&   rS   r=  r3   s       r(   r   r     s?    nnG$bz2~1'&"7"7893>>rH   c                     t        |d u xr | j                  xs |      | j                  }}|s|S t        |      }||k  rt	        |d||z
  z        S |dk(  ryt	        t        |d |dz
         d      S )Nra   r
   )u   …)r   rJ   title_lengthlenr   r   )r&   rJ   r;  	len_titles       r(   rc   rc     s    Ud];v||DuEvGZGZ6EE
IF UFfy.@$ABB{5&1*#56AArH   T)finalizer   itrF  returnc          	      V   	 t        di |}|j                  rt        d      |t        | d      rt        |       }t        |       } |t        | d      r| j                         }t        | |t        |||            S # t        $ r } t        |      t        |            dd}~ww xY w)u  New iterator adapter in 2.0, which makes it simpler to monitor any processing.

    Simply wrap your iterable with `alive_it`, and process your items normally!
    >>> from alive_progress import alive_it
    ...
    ... items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    ... for item in alive_it(items):
    ...     # process item.

    And the bar will just work, it's that simple!

    All `alive_bar` parameters apply as usual, except `total` (which is smarter: if not supplied
    it will be inferred from the iterable using len or length_hint), and `manual` (which can't
    be used in this mode at all).
    To force unknown mode, even when the total would be available, send `total=0`.

    If you want to use other alive_bar's more advanced features, like for example setting
    situational messages, you can simply assign it to a variable.

    >>> from alive_progress import alive_it
    ...
    ... items = range(100000)
    ... bar = alive_it(items)
    ... for item in bar:
    ...     bar.text = f'Wow, it works! Item: {item}'
    ...     # process item.

    You can also send a `finalize` function to set the final receipt title and text, and any other
    alive_bar options you'd like!

    >>> from alive_progress import alive_it
    ...
    ... def ending(bar):
    ...     bar.title = 'DB updated'
    ...     bar.text = f'{bar.current} entries changed'
    ...
    ... items = range(100000)
    ... for item in alive_it(items, finalize=ending, length=20, receipt_text=True)
    ...     # process item.

    This prints:
DB updated |████████████████████| 100k/100k [100%] in 2.6s (38.7k/s) 100000 entries changed

    Args:
        it: the input iterable to be processed
        total: same as alive_bar
        finalize: a function to be called when the bar is going to finalize
        calibrate: same as alive_bar
        options: same as alive_bar

    See Also:
        alive_bar

    Returns:
        Generator

    Nz.Manual mode can't be used in iterator adapter.__len____length_hint__r   r!   )r   r"   r#   r$   r   UserWarninghasattrrC  iterrK  __AliveBarIteratorAdapterr%   )rG  r   rF  r   r   r&   r'   s          r(   alive_itrP    s    x(*'* }}JKK}Y/B	bB}%67""$$R;vuXa3bcc  (d1gc!fo4'(s   A? ?	B(B##B(c                   6     e Zd Zd Zd Zd Zd Z fdZ xZS )rO  c                 0    |||c| _         | _        | _        y r?   )_it	_finalize
_inner_bar)r   rG  rF  	inner_bars       r(   r   z"__AliveBarIteratorAdapter.__init__G  s    46)1$.$/rH   c              #     K   d| j                   v ry | j                  5 | _        | `| j                  D ]  }| | j                           | j                  r| j	                  | j                         d d d        y # 1 sw Y   y xY wwN_bar)__dict__rU  rY  rS  rT  r   items     r(   __iter__z"__AliveBarIteratorAdapter.__iter__J  ss     T]]"__ 	*	 
		 ~~tyy)	* 	* 	*s   BAA;2	B;B Bc                     t        d      )Nz;The bar position is controlled automatically by `alive_it`.)rL  r3  s      r(   r   z"__AliveBarIteratorAdapter.__call__V  s    WXXrH   c                 `    d| j                   v rt        | j                  |      S t        d      )NrY  zAConfigure this bar either via `alive_it()` or after iterating it.)rZ  r  rY  rL  r[  s     r(   __getattr__z%__AliveBarIteratorAdapter.__getattr__Y  s+    T]]"499d++]^^rH   c                 n    d| j                   v rt        | j                  ||      S t        |   ||      S rX  )rZ  setattrrY  super__setattr__)r   keyr   	__class__s      r(   rd  z%__AliveBarIteratorAdapter.__setattr___  s4    T]]"499c511w"3..rH   )	r   r   r  r   r]  r   r`  rd  __classcell__)rf  s   @r(   rO  rO  F  s$    L
*Y_/ /rH   rO  r?   )6r  r   r   r@   r   
contextlibr   typingr   r   r   r   collections.abcr   r	   calibrationr   r   configurationr   rj   r   r   utilsr   utils.cellsr   r   r   r   utils.timingr   r   r   r   r   r   ro   r)   	Conditionr%   r   r  r  r  r  r   r   r   r   rc   rE  rP  rO  r!   rH   r(   <module>rq     sz      	 % 3 3 0 3 ) I  I I f; f;Xc] f;# f;Z] f;R }))UT} }@! !"
> 
>& '! '!i !* *0		3?B" CLHd/3(,HdA Hdx} Hdt,Hd Hd9<HdAI!HdV/ /rH   