
    Dhߠ                    Z   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl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 d dlmZ d dlmZmZ d dlZd dlZd dlZddlmZmZmZmZ dd	lmZ  ej>                  e       Z!e"Z#ejH                  e#ejJ                  ejL                     df   Z' ejP                  d
      Z) G d dejT                        Z+ G d dejX                  e#   e+      Z- G d de+      Z. G d de+      Z/ G d de.      Z0 G d de0e/e-      Z1 G d de1      Z2 G d de1      Z3y)    )annotationsN)deepcopy)datetime)	FrameType)
converterstypes   )baseutilswidgetsr   )os_specificTc                  h   e Zd ZU dZdZdZded<   dZded<   ded	<   d
ed<   ded<   ded<   d
ed<   ded<   ded<   ded<   ded<   ded<   dZded<   dZ	ded<   ded<   ded<   ded <   d!ed"<   ded#<   ded$<   ded%<   ded&<   d2d'Z
d3d(Z ee
e      Zd4d)Zd4d*Zd5d6d+Zd, Zd- Zd. Zd7d/Zd8d0Zd8d1Zy)9ProgressBarMixinBaseFNtypes.Optional[float]_last_update_timeP   int
term_widthz6types.MutableSequence[widgets_module.WidgetBase | str]r   bool	max_errorztypes.Optional[str]prefixsuffixleft_justifytypes.Dict[str, types.Any]widget_kwargstypes.Callable[[str], int]
custom_lentypes.Optional[datetime]initial_start_timepoll_intervalfloatmin_poll_intervalr   num_intervalsnext_updateNumberTvaluetypes.Optional[NumberT]previous_value	min_valueValueT	max_valueend_time
start_timeseconds_elapsedextrac                Z    | j                   rt        j                  | j                         S y N)r   r   fromtimestampselfs    q/var/www/fastuser/data/www/generator.snapmosaic.io/flask_app/venv/lib/python3.12/site-packages/progressbar/bar.pyget_last_update_timez)ProgressBarMixinBase.get_last_update_timej   s%    !!))$*@*@AA    c                h    |r)t        j                  |j                               | _        y d | _        y r2   )timemktime	timetupler   r5   r'   s     r6   set_last_update_timez)ProgressBarMixinBase.set_last_update_timep   s%    %)[[1B%CD"%)D"r8   c                     y r2    r5   kwargss     r6   __init__zProgressBarMixinBase.__init__x       r8   c                    d| _         y NT)_startedrA   s     r6   startzProgressBarMixinBase.start{   s	    r8   c                     y r2   r@   r=   s     r6   updatezProgressBarMixinBase.update~   rD   r8   c                    d| _         y rF   	_finishedr4   s    r6   finishzProgressBarMixinBase.finish   s	    r8   c                x    | j                   s| j                  r	 | j                          y y y # t        $ r Y y w xY wr2   )rM   rG   rN   AttributeErrorr4   s    r6   __del__zProgressBarMixinBase.__del__   s8    ~~$--	 #0~
 " s   - 	99c                    | j                   S r2   )__dict__r4   s    r6   __getstate__z!ProgressBarMixinBase.__getstate__   s    }}r8   c                    t               r2   )NotImplementedErrorr4   s    r6   datazProgressBarMixinBase.data   s    !##r8   c                6    | j                   xs | j                  S r2   )rM   rG   r4   s    r6   startedzProgressBarMixinBase.started   s    ~~..r8   c                    | j                   S r2   rL   r4   s    r6   finishedzProgressBarMixinBase.finished   s    ~~r8   )returnr   )r'   r   rB   
typing.Anyr2   r'   r+   r\   r   )r\   r   )__name__
__module____qualname__rG   rM   r   __annotations__r   r$   r%   r7   r>   propertylast_update_timerC   rH   rJ   rN   rQ   rT   rW   rY   r[   r@   r8   r6   r   r   *   s    HI/3,3 JCC O .-
 +*00((  M3 K N++  '&((
 &%*   46JK$/r8   r   c                  f     e Zd ZU  ej                         ZdZded<   dZded<   d	 fdZ	d Z
 xZS )
ProgressBarBaser   index strlabelc                X    t        | j                        | _        t        |   di | y Nr@   )next_index_counterrj   superrC   r5   rB   	__class__s     r6   rC   zProgressBarBase.__init__   s%    $--.
"6"r8   c                    | j                   rd| j                    nd}d| j                  j                   d| j                   | dS )Nz: rk   <#>)rm   rt   ra   rj   )r5   rm   s     r6   __repr__zProgressBarBase.__repr__   sB    %)ZZ"TZZL!R4>>**+1TZZLqAAr8   r]   )ra   rb   rc   	itertoolscountrq   rj   rd   rm   rC   ry   __classcell__rt   s   @r6   rh   rh      s.    $Y__&NE3OE3O#Br8   rh   c                  P    e Zd ZU ej                  Zded<   dZded<   ded<   dZded<   e	j                  j                  Zd	ed
<   ej                  ddddf	 	 	 	 	 	 	 	 	 	 	 d fdZ	 	 	 	 	 	 ddZddZ	 	 	 	 ddZddZd fdZddZ	 	 	 	 	 	 ddZd Zd Zedd       Z xZS )DefaultFdMixinbase.TextIOfdFbool | Noneis_ansi_terminalis_terminalTline_breaksprogressbar.env.ColorSupportenable_colorsNr   c                   |t         j                  u rt        j                  j                  }n,|t         j
                  u rt        j                  j                  }| j                  ||      }|| _        t        j                  j                  |      | _        t        j                  j                  ||      | _        | j                  |      | _        | j                  |      | _        t#        | H  di | y ro   )sysstdoutr   streamsoriginal_stdoutstderroriginal_stderr_apply_line_offsetr   progressbarenvr   r   _determine_line_breaksr   _determine_enable_colorsr   rr   rC   )r5   r   r   r   r   line_offsetrB   rt   s          r6   rC   zDefaultFdMixin.__init__   s     ..B3::..B$$R5 + @ @ D&??66r;G66{C!::=I"6"r8   c                ^    |r*t         j                  j                  j                  ||      S |S r2   )r   terminalstreamLineOffsetStreamWrapper)r5   r   r   s      r6   r   z!DefaultFdMixin._apply_line_offset   s3    
 ''..FF 
 Ir8   c                `    |+t         j                  j                  d| j                         S |S )NPROGRESSBAR_LINE_BREAKS)r   r   env_flagr   )r5   r   s     r6   r   z%DefaultFdMixin._determine_line_breaks   s6    ??++)$$$ 
 r8   c                   |t         j                  j                  d      t         j                  j                  d      | j                  f}|D ]H  }||rt         j                  j                  }n$t         j                  j
                  j                  } |S  t         j                  j
                  j                  }|S |du r&t         j                  j
                  j                  }|S |du r&t         j                  j
                  j                  }|S t        |t         j                  j
                        r|}|S t        d|       )aE  
        Determines the color support for the progress bar.

        This method checks the `enable_colors` parameter and the environment
        variables `PROGRESSBAR_ENABLE_COLORS` and `FORCE_COLOR` to determine
        the color support.

        If `enable_colors` is:
         - `None`, it checks the environment variables and the terminal
            compatibility to ANSI.
         - `True`, it sets the color support to XTERM_256.
         - `False`, it sets the color support to NONE.
         - For different values that are not instances of
           `progressbar.env.ColorSupport`, it raises a ValueError.

        Args:
             enable_colors (progressbar.env.ColorSupport | None): The color
             support setting from the user. It can be None, True, False,
             or an instance of `progressbar.env.ColorSupport`.

        Returns:
            progressbar.env.ColorSupport: The determined color support.

        Raises:
            ValueError: If `enable_colors` is not None, True, False, or an
            instance of `progressbar.env.ColorSupport`.
        PROGRESSBAR_ENABLE_COLORSFORCE_COLORTFzInvalid color support value: )
r   r   r   r   COLOR_SUPPORTColorSupportNONE	XTERM_256
isinstance
ValueError)r5   r   colorscolor_enabledcolor_supports        r6   r   z'DefaultFdMixin._determine_enable_colors   s0   @  (()DE((7%%F "( B ,$(3(E(E(3(D(D(I(I 'B !, < < A A  d"'OO88BBM  e#'OO88==M  {'C'CD)M  <]OLMMr8   c                2    t        |d| j                  i| y )Nfile)printr   r5   argsrB   s      r6   r   zDefaultFdMixin.print*  s    t,$'',V,r8   c                J    t        j                          t        |           y r2   )r   set_console_moderr   rH   rs   s     r6   rH   zDefaultFdMixin.start-  s    $$&r8   c           
        t        j                  | g|i | t        j                  | j	                               }| j
                  st        j                  |      }| j                  r|j                         dz   nd|z   }	 | j                  j                  |       y # t        $ rF | j                  j                  t        j                  t        |j!                  dd                   Y y w xY w)N
asciireplace)r   rJ   r   
to_unicode_format_liner   r   no_colorr   rstripr   writeUnicodeEncodeErrorr   castrl   encode)r5   r   rB   lines       r6   rJ   zDefaultFdMixin.update1  s    ##D:4:6:))$*;*;*=>!!>>$'D'+'7'7t{{}t#TD[	LGGMM$! 	LGGMM%**S$++gy*IJK	Ls   B AC.-C.c                "   t        j                          | j                  ry |j                  dd      }t	        j
                  | g|i | |r'| j                  s| j                  j                  |       | j                  j                          y )Nendr   )
r   reset_console_moderM   popr   rN   r   r   r   flush)r5   r   rB   r   s       r6   rN   zDefaultFdMixin.finish?  sj    
 	&&(>>jj%##D:4:6:t''GGMM#r8   c                    dj                  | j                  | j                                     }| j                  r |j                  | j
                        S  |j                  | j
                        S )z)Joins the widgets and justifies the line.rk   )join_to_unicode_format_widgetsr   ljustr   rjust)r5   r   s     r6   r   zDefaultFdMixin._format_lineQ  sW    ''$**4+?+?+ABC 7==11 7==11r8   c                8   g }g }| j                   }| j                         }t        | j                        D ]  \  }}t	        |t        j
                        r|j                  |       s2t	        |t        j                        r$|j                  |       |j                  d|       pt	        |t              r&|j                  |       || j                  |      z  }t        j                   || |            }|j                  |       || j                  |      z  } t        |      }|rnt        t!        t#        j$                  |dz  |z              d      }	|j'                         }||   }|dz  } || ||	      }|| j                  |      z  }|||<   |rn|S )Nr   g      ?r	   )r   rW   	enumerater   r   
WidgetBase
check_sizeAutoWidthWidgetBaseappendinsertrl   r   r   r   lenmaxr   mathceilr   )
r5   result	expandingwidthrW   rj   widgetwidget_outputr{   portions
             r6   r   zDefaultFdMixin._format_widgetsZ  sr   	yy{&t||4 	8ME6"" ''-FG$?$?@f%  E*FC(f%00 * 5 5fT46H Im,77	8" I#diie(;<=qAGMMOEE]FQJE"4w7MT__]33E)F5M  r8   c              #  H   K   |D ]  }t        j                  |        y wr2   )r   r   )clsr   args      r6   r   zDefaultFdMixin._to_unicode~  s&      	-C'',,	-s    ")r   r   r   r   r   r   r   #progressbar.env.ColorSupport | Noner   r   rB   r^   )r   r   r   r   r\   r   )r   r   r\   r   )r   r   r\   r   )r   	types.AnyrB   r   r\   Noner]   )r   r^   )ra   rb   rc   r   r   r   rd   r   r   r   r   r   r   rC   r   r   r   r   rH   rJ   rN   r   r   classmethodr   r|   r}   s   @r6   r   r      s+   jjB  %*k)   $K# 3>//2O2OM/O **#'#'=A## !# !	#
 ;# # #.  
	::: 
&:x-L  
	$2"H - -r8   r   c                  .    e Zd ZdddZ	 d	 	 	 ddZd Zy)	ResizableMixinNc                p   t        j                  | fi | d| _        |r|| _        y t	        j
                  t              5  | j                          dd l}|j                  |j                        | _        |j                  |j                  | j                         d| _        d d d        y # 1 sw Y   y xY w)NFr   T)r   rC   
signal_setr   
contextlibsuppress	Exception_handle_resizesignal	getsignalSIGWINCH_prev_handle)r5   r   rB   r   s       r6   rC   zResizableMixin.__init__  s    %%d5f5(DO$$Y/ '##%$*$4$4OO%! OO'' #'' ' 's   A"B,,B5c                @    t        j                         \  }}|| _        y)z5Tries to catch resize signals sent from the terminal.N)r   get_terminal_sizer   )r5   signumframewhs        r6   r   zResizableMixin._handle_resize  s     &&(1r8   c                    t         j                  |        | j                  rMt        j                  t
              5  dd l}|j                  |j                  | j                         d d d        y y # 1 sw Y   y xY w)Nr   )	r   rN   r   r   r   r   r   r   r   )r5   r   s     r6   rN   zResizableMixin.finish  sc    ##D)??$$Y/ OO%%   s   +A00A9r2   )r   
int | NonerB   r^   )NN)r   r   r   zNone | FrameType)ra   rb   rc   rC   r   rN   r@   r8   r6   r   r     s(    '* DH 0@	r8   r   c                      e Zd ZU dZded<   dZded<   ded<   ded<   ded	<   ded
<   	 	 d	 	 	 ddZddZdddZddZ	y)StdRedirectMixinFr   redirect_stderrredirect_stdoutz&utils.WrappingIO | base.IO[typing.Any]r   r   zbase.IO[typing.Any]_stdout_stderrc                    t        j                  | fi | || _        || _        t        j
                  x| _        | _        t        j                  x| _        | _        y r2   )	r   rC   r   r   r   r   r   r   r   )r5   r   r   rB   s       r6   rC   zStdRedirectMixin.__init__  sK     	//..%(ZZ/t{%(ZZ/t{r8   c                   | j                   rt        j                  j                          | j                  rt        j                  j                          t        j                  j                  | _        t        j                  j                  | _	        t        j                  j                  | _
        t        j                  j                  | _        t        j                  j                  |        t        j                  | g|i | y r2   )r   r   r   wrap_stdoutr   wrap_stderrr   r   r   r   r   r   start_capturingr   rH   r   s      r6   rH   zStdRedirectMixin.start  s    MM%%'MM%%'}}44}}44mm**mm**%%d+T3D3F3r8   Nc                   | j                   sLt        j                  j                         r.| j                  j                  dd| j                  z  z   dz          t        j                  j                          t        j                  | |       y )Nr    r'   )
r   r   r   needs_clearr   r   r   r   r   rJ   r=   s     r6   rJ   zStdRedirectMixin.update  s`    EMM$=$=$?GGMM$t!66=>d%0r8   c                   t         j                  | |       t        j                  j	                  |        | j
                  rt        j                  j                          | j                  rt        j                  j                          y y )Nr   )	r   rN   r   r   stop_capturingr   unwrap_stdoutr   unwrap_stderr)r5   r   s     r6   rN   zStdRedirectMixin.finish  s^    d,$$T*MM'')MM'')  r8   )FF)r   r   r   r   r   r^   rB   r^   r2   )r'   r(   )r   )
ra   rb   rc   r   rd   r   rC   rH   rJ   rN   r@   r8   r6   r   r     s\    !OT!!OT!2222     !& %
0
0 
04 1*r8   r   c                     e Zd ZU dZded<   ej                  Zded<   dZded<   d	Z	d
ed<   dZ
ded<   dd	d	ddd	d	ej                  dd	d	d	d	f	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d*dZed        Zej                   d        Zd Zed+d       Zd,dZd Zd-dZd Zd Zd Zd ZeZd Z	 d.	 	 	 	 	 d/dZd Z	 d0	 	 	 	 	 d1d Zd! Zd2d"Z 	 	 d3	 	 	 	 	 	 	 	 	 d4d#Z!d$ Z"d% Z#d& Z$d5d'Z%d6d7d(Z&ed)        Z'y	)8ProgressBara*  The ProgressBar class which updates and prints the bar.

    Args:
        min_value (int): The minimum/start value for the progress bar
        max_value (int): The maximum/end value for the progress bar.
                            Defaults to `_DEFAULT_MAXVAL`
        widgets (list): The widgets to render, defaults to the result of
                        `default_widget()`
        left_justify (bool): Justify to the left if `True` or the right if
                                `False`
        initial_value (int): The value to start with
        poll_interval (float): The update interval in seconds.
            Note that if your widgets include timers or animations, the actual
            interval may be smaller (faster updates).  Also note that updates
            never happens faster than `min_poll_interval` which can be used for
            reduced output in logs
        min_poll_interval (float): The minimum update interval in seconds.
            The bar will _not_ be updated faster than this, despite changes in
            the progress, unless `force=True`.  This is limited to be at least
            `_MINIMUM_UPDATE_INTERVAL`.  If available, it is also bound by the
            environment variable PROGRESSBAR_MINIMUM_UPDATE_INTERVAL
        widget_kwargs (dict): The default keyword arguments for widgets
        custom_len (function): Method to override how the line width is
            calculated. When using non-latin characters the width
            calculation might be off by default
        max_error (bool): When True the progressbar will raise an error if it
            goes beyond it's set max_value. Otherwise the max_value is simply
            raised when needed
            prefix (str): Prefix the progressbar with the given string
            suffix (str): Prefix the progressbar with the given string
        variables (dict): User-defined variables variables that can be used
            from a label using `format='{variables.my_var}'`.  These values can
            be updated using `bar.update(my_var='newValue')` This can also be
            used to set initial values for variables' widgets
        line_offset (int): The number of lines to offset the progressbar from
            your current line. This is useful if you have other output or
            multiple progressbars

    A common way of using it is like:

    >>> progress = ProgressBar().start()
    >>> for i in range(100):
    ...     progress.update(i + 1)
    ...     # do something
    >>> progress.finish()

    You can also use a ProgressBar as an iterator:

    >>> progress = ProgressBar()
    >>> some_iterable = range(100)
    >>> for i in progress(some_iterable):
    ...     # do something
    ...     pass

    Since the progress bar is incredibly customizable you can specify
    different widgets of any type in any order. You can even write your own
    widgets! However, since there are already a good number of widgets you
    should probably play around with them before moving on to create your own
    widgets.

    The term_width parameter represents the current terminal width. If the
    parameter is set to an integer then the progress bar will use that,
    otherwise it will attempt to determine the terminal width falling back to
    80 columns if the width cannot be determined.

    When implementing a widget's update method you are passed a reference to
    the current progress bar. As a result, you have access to the
    ProgressBar's methods and attributes. Although there is nothing preventing
    you from changing the ProgressBar you should treat it as read only.
    ztypes.Optional[types.Iterator]	_iterableztype[base.UnknownLength]_DEFAULT_MAXVALg?r"   _MINIMUM_UPDATE_INTERVALNr   r   Fr   pausedr   Tc           
        t        j                  | fi | t        j                  | fi | t        j                  | fi | |s>|j	                  d      -t        j                  dt        d       |j	                  d      }|s>|j	                  d      r-t        j                  dt        d       |j	                  d      }|r(|t        j                  t        |      kD  rt        d      || _        || _        |	| _        g | _        |xs g D ]5  }t!        |d	d
      rt#        |      }| j                  j%                  |       7 |
| _        || _        |xs i | _        || _        || _        d| _        || _        |j	                  d      | _        | j7                          t9        j:                  |d      }t9        j:                  |d      }t9        j:                  | j<                        xs | j<                  | _        || _        tA        |xs | j<                  | j<                  tC        tD        jF                  j	                  dd                  | _$        t9        jJ                  |xs i       | _&        | j                  D ]O  }tO        |tP        jR                        s|jT                  | jL                  vs7d| jL                  |jT                  <   Q y)z.Initializes a progress bar with sane defaults.maxvalNzCThe usage of `maxval` is deprecated, please use `max_value` insteadr	   
stacklevelpollzEThe usage of `poll` is deprecated, please use `poll_interval` insteadz/Max value needs to be bigger than the min valuecopyTr.   default#PROGRESSBAR_MINIMUM_UPDATE_INTERVALr   )+r   rC   r   rh   getwarningswarnDeprecationWarningr   r   r&   r   r*   r,   r   r   getattrr   r   r   r   r   r   r'   r  r   r    initr   deltas_to_secondsr  r!   r   r"   osenvironr#   AttributeDict	variablesr   widgets_moduleVariableMixinname)r5   r*   r,   r   r   initial_valuer!   r   r   r   r   r   r"  r#   rB   r   s                   r6   rC   zProgressBar.__init__5  sz   ( 	!!$1&1//  00VZZ1=MM&"	 

8,IF!3MM*"	 #JJv.MUZZ%CCA  # #" m 	(Fvvt,!&)LL'	(
 *0b("
$"(**\":		 //tL!33

 ##D$A$AB -,, 	% +!$>!>!>))"**..!FJK"
 ,,Y_"=ll 	3F6>#?#?@KKt~~5.2v{{+	3r8   c                    | j                   S r2   r"  r4   s    r6   dynamic_messageszProgressBar.dynamic_messages  s    ~~r8   c                    || _         y r2   r(  r=   s     r6   r)  zProgressBar.dynamic_messages  s	    r8   c                    d| _         d| _        d| _        d| _        d| _        t               | _        t        j                         | _	        y)zi
        (re)initialize values to original state so the progressbar can be
        used (again).
        Nr   )
r)   rf   r.   updatesr-   dictr0   timeitdefault_timer_last_update_timerr4   s    r6   r  zProgressBar.init  sC    
 # $V
"("6"6"8r8   c                    | j                   | j                   t        j                  u ry| j                   r<| j                  | j                  z
  }| j                   | j                  z
  }d|z  |z  }|S d}|S )a&  Return current percentage, returns None if no max_value is given.

        >>> progress = ProgressBar()
        >>> progress.max_value = 10
        >>> progress.min_value = 0
        >>> progress.value = 0
        >>> progress.percentage
        0.0
        >>>
        >>> progress.value = 1
        >>> progress.percentage
        10.0
        >>> progress.value = 10
        >>> progress.percentage
        100.0
        >>> progress.min_value = -10
        >>> progress.percentage
        100.0
        >>> progress.value = 0
        >>> progress.percentage
        50.0
        >>> progress.value = 5
        >>> progress.percentage
        75.0
        >>> progress.value = -5
        >>> progress.percentage
        25.0
        >>> progress.max_value = None
        >>> progress.percentage
        Ng      Y@)r,   r
   UnknownLengthr'   r*   )r5   todototal
percentages       r6   r5  zProgressBar.percentage  sq    @ >>!T^^t7I7I%I^^::.DNNT^^3E-J  Jr8   c                   t        j                          | _        t        j                         | _        | j
                  | j                  z
  }t        j                  |      }t        di d| j                  d| j                  d| j
                  d| j                  d| j                  d| j                  d| j                  d|d	|j                  d
z  |j                   dz  z   d|j                  d
z  d
z  d|j                  dz  dz  d|j                  dz  d|d| j"                  d| j$                  d| j$                  S )a  

        Returns:
            dict:
                - `max_value`: The maximum value (can be None with
                  iterators)
                - `start_time`: Start time of the widget
                - `last_update_time`: Last update time of the widget
                - `end_time`: End time of the widget
                - `value`: The current value
                - `previous_value`: The previous value
                - `updates`: The total update count
                - `total_seconds_elapsed`: The seconds since the bar started
                - `seconds_elapsed`: The seconds since the bar started modulo
                  60
                - `minutes_elapsed`: The minutes since the bar started modulo
                  60
                - `hours_elapsed`: The hours since the bar started modulo 24
                - `days_elapsed`: The hours since the bar started
                - `time_elapsed`: The raw elapsed `datetime.timedelta` object
                - `percentage`: Percentage as a float or `None` if no max_value
                  is available
                - `dynamic_messages`: Deprecated, use `variables` instead.
                - `variables`: Dictionary of user-defined variables for the
                  :py:class:`~progressbar.widgets.Variable`'s.

        r,   r.   rf   r-   r'   r)   r,  total_seconds_elapsedr/   <   g    .Aminutes_elapsedhours_elapsedi     days_elapsediQ time_elapsedr5  r"  r)  r@   )r:   r   r.  r/  r0  rf   r.   r   r  r-  r,   r-   r'   r)   r,  secondsmicrosecondsr5  r"  )r5   elapsedr7  s      r6   rW   zProgressBar.data  sf   8 "&"("6"6"8''$//9 !& 7 7 @ #
nn#
 	#
 "22#
 ]]#
 **#
  ..#
 LL#
  #8!#
$ %__r1##i/1%#
* %__r1R7+#
. #??g6"</#
2 "//\:3#
6 !7#
: ;#
@ nnA#
D "^^E#
 #	
r8   c                   | j                   rt        j                  di | j                  dt        j                  dddt        j                  j
                   di| j                  dt        j                  di | j                  dt        j                  di | j                  dt        j                  di | j                  g	S t        j                  di | j                  dt        j                  di | j                  dt        j                  di | j                  dt        j                  di | j                  gS )Nr   format()r@   )r,   r   
Percentager   SimpleProgressDEFAULT_FORMATBarTimerSmoothingETAAnimatedMarkerBouncingBarCounterr4   s    r6   default_widgetszProgressBar.default_widgets$  s    >>""8T%7%78&& w55DDEQG(( 1d0013 2 23$$:t'9'9:   &&<););<##9d&8&895$"4"453 2 23 r8   c                    ||| _         n| j                   	 t        |      | _         t        |      | _        | S # t        $ r t        j                  | _         Y 2w xY w)z1Use a ProgressBar to iterate through an iterable.)r,   r   	TypeErrorr
   r2  iterr  )r5   iterabler,   s      r6   __call__zProgressBar.__call__?  sY     &DN^^#4!$X h	  4!%!3!34s   : AAc                    | S r2   r@   r4   s    r6   __iter__zProgressBar.__iter__L      r8   c                P   	 | j                   | j                  }nt        | j                         }| j                  | j	                          |S | j                  | j                  dz          	 |S # t        $ r | j                           t        $ r | j                  d        w xY w)Nr	   Tdirty)	r  r'   rp   r.   rH   rJ   StopIterationrN   GeneratorExitr=   s     r6   __next__zProgressBar.__next__O  s    	~~%

T^^,&

 L DJJN+ L  	KKM 	KKdK#	s   A
A/ A/ /6B%c                :    | j                  t        |             y )NrX  )rN   r   )r5   exc_type	exc_value	tracebacks       r6   __exit__zProgressBar.__exit__d  s    $x.)r8   c                    | S r2   r@   r4   s    r6   	__enter__zProgressBar.__enter__g  rV  r8   c                $    | j                  |      S )z.Updates the ProgressBar by adding a new value.)	incrementr=   s     r6   __iadd__zProgressBar.__iadd__n  s    ~~e$$r8   c                L     | j                   | j                  |z   g|i | | S r2   )rJ   r'   )r5   r'   r   rB   s       r6   re  zProgressBar.incrementr  s*     	DJJ&888r8   c                   | j                   ryt        j                         | j                  z
  }|| j                  k  ry| j
                  r|| j
                  kD  ryt        j                  t              5  | j                  | j                  z  }| j                  |z  }| j                  |z  }||k7  r
	 ddd       y	 ddd       y# 1 sw Y   yxY w)z7Returns whether the ProgressBar should redraw the line.FTN)r  r.  r/  r0  r#   r!   r   r   r   r,   r   r'   r)   )r5   deltadivisorvalue_divisorpvalue_divisors        r6   _needs_updatezProgressBar._needs_updatex  s    ;;$$&)@)@@4)))ED,>,>$>
   + 	!^^doo=G JJ'1M!00G;N.	 	 /		 	 s   4>CCc                   | j                   | j                          ||t        j                  urt	        |t
        t        f      r| j                  t        j                  u rn| j                  |kD  r(t        d| d| j                   d| j                         | j                  |k  rX| j                  r(t        d| d| j                   d| j                         t        j                  t        | j                        }| j                  | _        || _        | j!                  |      }| j#                         s|s|r| j%                  |       yy)z'Updates the ProgressBar to a new value.NzValue z! is too small. Should be between z and z! is too large. Should be between )r.   rH   r
   r2  r   r   r"   r,   r*   r   r   typingr   r&   r'   r)   _update_variablesrm  _update_parents)r5   r'   forcerB   variables_changeds        r6   rJ   zProgressBar.update  s7    ??"JJL T///53,/~~!3!33%' UG $#~~.eDNN3CE  %'>>$ 'H>>*%/?A 
 #KK@E"&**DDJ !226:#4  ' 9>r8   c                    d}|j                         D ]E  \  }}|| j                  vrt        d      | j                  |   |k7  s2||   | j                  |<   d}G |S )NFz<update() got an unexpected variable name as argument {key!r}T)itemsr"  rP  )r5   rB   rs  keyvalue_s        r6   rp  zProgressBar._update_variables  sr    !!<<> 	)KC$..(  $.&,Sks#$(!	) ! r8   c                    | xj                   dz  c_         t        j                  | |       t        j                  | |       t        j                  | |       | j
                  j                          y )Nr	   r  )r,  r   rJ   rh   r   r   r   r=   s     r6   rq  zProgressBar._update_parents  sX    d%0t51E2 	r8   c                   |r| j                          | j                  | S ||| _        | j                  | j                  | _        t        j                  | |       t        j                  | |       t        j                  | |       | j                  s| j                         | _        | j                          | j                          | j                          | j                          t        j                         }| j                   xs || _        || _        t%        j&                         | _        | j+                  | j,                  d       | S )a8  Starts measuring time, and prints the bar at 0%.

        It returns self so you can use it like this:

        Args:
            max_value (int): The maximum value of the progressbar
            init (bool): (Re)Initialize the progressbar, this is useful if you
                wish to reuse the same progressbar but can be disabled if
                data needs to be persisted between runs

        >>> pbar = ProgressBar().start()
        >>> for i in range(100):
        ...     # do something
        ...     pbar.update(i + 1)
        >>> pbar.finish()
        )r,   Trr  )r  r.   r,   r  r   rH   r   rh   r   rN  _init_prefix_init_suffix_calculate_poll_interval_verify_max_valuer   nowr    rf   r.  r/  r0  rJ   r*   )r5   r,   r  r   rB   r  s         r6   rH   zProgressBar.start  s   . IIK ??&K &DN>>!!11DNty9TY7di8 ||//1DL%%' lln118S #"("6"6"8DNN$/r8   c                    | j                   rB| j                  j                  t        j                  | j                   d             d | _         y y )NT	new_style)r   r   r   FormatLabelr4   s    r6   r|  zProgressBar._init_suffix  s=    ;;LL##DKK4@
 DK r8   c                    | j                   rC| j                  j                  dt        j                  | j                   d             d | _         y y )Nr   Tr  )r   r   r   r  r4   s    r6   r{  zProgressBar._init_prefix  s@    ;;LL##DKK4@ DK r8   c                    | j                   t        j                  ur5| j                   (| j                   dk  rt        d| j                         y y y )Nr   zmax_value out of range, got )r,   r
   r2  r   r4   s    r6   r~  zProgressBar._verify_max_value  sQ    NN$"4"44*";DNN;MNOO # + 5r8   c                    t        d| j                        | _        | j                  D ]F  }t	        j
                  t        |dd       d       }|(t        | j                  xs ||      | _        H y )Nd   INTERVALr  )	r   r   r$   r   r   r  r  minr!   )r5   r   intervals      r6   r}  z$ProgressBar._calculate_poll_interval   sm     doo6ll 		F+0+B+B
D1,H #%(&&2(&"		r8   c                    |s6t        j                         | _        | j                  | j                  d       t
        j                  | |       t        j                  |        t        j                  |        y)a  
        Puts the ProgressBar bar in the finished state.

        Also flushes and disables output buffering if this was the last
        progressbar running.

        Args:
            end (str): The string to end the progressbar with, defaults to a
                newline
            dirty (bool): When True the progressbar kept the current state and
                won't be set to 100 percent
        Trz  r  N)	r   r  r-   rJ   r,   r   rN   r   rh   )r5   r   rY  s      r6   rN   zProgressBar.finish-  sW     $LLNDMKKdK3#.d#t$r8   c                R    t        j                  dt        d       | j                  S )zo
        Legacy method to make progressbar-2 compatible with the original
        progressbar package.
        z@The usage of `currval` is deprecated, please use `value` insteadr	   r  )r  r  r  r'   r4   s    r6   currvalzProgressBar.currvalB  s'     			
 zzr8   )r*   r&   r,   r+   r   z?types.Optional[types.Sequence[widgets_module.WidgetBase | str]]r   r   r&  r&   r!   r   r   z*types.Optional[types.Dict[str, types.Any]]r   r   )r\   zfloat | Noner`   r2   )r	   )r'   r&   r   r^   rB   r^   )NF)r'   r+   rr  r   rB   r^   r_   rF   )
r,   zNumberT | Noner  r   r   r^   rB   r^   r\   r
  )r\   r   )r   F)r   rl   rY  r   )(ra   rb   rc   __doc__rd   r
   r2  r  r  r   r  r   	len_colorrC   re   r)  setterr  r5  rW   rN  rS  rU  r\  ra  rc  rp   rf  re  rm  rJ   rp  rq  rH   r|  r{  r~  r}  rN   r  r@   r8   r6   r
  r
    s	   
EN .-040B0BO-B&+e+/3,3FD   !!"/3DH16!f3f3 f3
	f3 f3 f3 -f3 Bf3 /f3P    9 ( (TE
N6**
 D%
  !)3?I2 38$($(+/$(CM$(L! %)7!7 7 	7
 7 
7rP%*  r8   r
  c                      e Zd ZdZd Zy)DataTransferBarzA progress bar with sensible defaults for downloads etc.

    This assumes that the values its given are numbers of bytes.
    c           
     `   | j                   rft        j                         dt        j                  d      dt        j                         dt        j
                         dt        j                         g	S t        j                         dt        j                         dt        j
                         gS )Nz of r,   r   )r,   r   rE  DataSizerH  rI  rJ  rK  r4   s    r6   rN  zDataTransferBar.default_widgetsW  s    >>""$  -$$&
 
 &&(  " r8   N)ra   rb   rc   r  rN  r@   r8   r6   r  r  Q  s    
r8   r  c                  (    e Zd ZdZddZddZddZy)NullBarz[
    Progress bar that does absolutely nothing. Useful for single verbosity
    flags.
    c                    | S r2   r@   r   s      r6   rH   zNullBar.startt  rV  r8   c                    | S r2   r@   r   s      r6   rJ   zNullBar.updatew  rV  r8   c                    | S r2   r@   r   s      r6   rN   zNullBar.finishz  rV  r8   Nr  )ra   rb   rc   r  rH   rJ   rN   r@   r8   r6   r  r  n  s    
r8   r  )4
__future__r   abcr   rz   loggingr   r  r   r:   r.  ro  r  r  r   r   r   r   python_utilsr   progressbar.envr   progressbar.terminalprogressbar.terminal.streamrk   r
   r   r   r#  r   r   	getLoggerra   loggerr"   r&   UnionTyper2  r+   TypeVarr   ABCr   Iterablerh   r   r   r   r
  r  r  r@   r8   r6   <module>r     s    " 
     	 
        *   "  "			8	$ 	gv{{4+=+=>D	EEMM#m377 m`BennW-/C BY-) Y-x%) %P2*~ 2*jm	m	`k :k r8   