HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/tqdm/__pycache__/_tqdm.cpython-38.pyc
U

��L\���@sfdZddlmZddlmZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZddlmZddlZddlmZdd	lmZdd
lmZddlZddlZddlmZdd
dddddgiZddddddddgZGdd�de �Z!Gdd�de"�Z#Gdd�de$�Z%Gdd�de%e&�Z'Gdd�de%e(�Z)Gd d�de%e*�Z+Gd!d"�d"e,�Z-e-�.�Gd#d�de�Z/d$d�Z0dS)%z�
Customisable progressbar decorator for iterators.
Includes a default (x)range iterator printing to stderr.

Usage:
  >>> from tqdm import trange[, tqdm]
  >>> for i in trange(10): #same as: for i in tqdm(xrange(10))
  ...     ...
�)�absolute_import)�division�)�_supports_unicode�_environ_cols_wrapper�_range�_unich�
_term_move_up�_unicode�WeakSet�_basestring�_OrderedDict�
Comparable�RE_ANSI)�TMonitorN)�Number)�time)�contextmanager)�warnzgithub.com/ZnoamraphZobiwanusZkmikeZhadimZ	casperdclZlrq3000�tqdm�trange�
TqdmTypeError�TqdmKeyError�TqdmWarning�TqdmExperimentalWarning�TqdmDeprecationWarning�TqdmMonitorWarningc@seZdZdS)rN��__name__�
__module__�__qualname__�r!r!�,/usr/lib/python3/dist-packages/tqdm/_tqdm.pyr$sc@seZdZdS)rNrr!r!r!r"r(scs"eZdZdZd�fdd�	Z�ZS)rzqbase class for all tqdm warnings.

    Used for non-external-code-breaking errors, such as garbled printing.
    NcsJ|dk	r.|d|jjdt|���d�ntt|�j|f|�|�dS)N�
�: )�	__class__r�str�rstrip�superr�__init__)�self�msg�fp_write�a�k�r%r!r"r)1s
��zTqdmWarning.__init__)N)rrr �__doc__r)�
__classcell__r!r!r/r"r,sc@seZdZdZdS)rz(beta feature, unstable API and behaviourN�rrr r0r!r!r!r"r9sc@seZdZdS)rNrr!r!r!r"r>sc@seZdZdZdS)rz>tqdm monitor errors which do not affect external functionalityNr2r!r!r!r"rCsc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	dd
��Z
e	dd��ZdS)�TqdmDefaultWriteLocka�
    Provide a default write lock for thread and multiprocessing safety.
    Works only on platforms supporting `fork` (so Windows is excluded).
    You must initialise a `tqdm` or `TqdmDefaultWriteLock` instance
    before forking in order for the write lock to work.
    On Windows, you need to supply the lock from the parent to the children as
    an argument to joblib or the parallelism lib you use.
    cCs4|��|��t|�}dd�|j|jfD�|_dS)NcSsg|]}|dk	r|�qS�Nr!)�.0Zlkr!r!r"�
<listcomp>Wsz1TqdmDefaultWriteLock.__init__.<locals>.<listcomp>)�create_mp_lock�create_th_lock�type�mp_lock�th_lock�locks)r*�clsr!r!r"r)QszTqdmDefaultWriteLock.__init__cCs|jD]}|��qdSr4)r<�acquire�r*�lockr!r!r"r>Ys
zTqdmDefaultWriteLock.acquirecCs"|jddd�D]}|��qdS)N���)r<�releaser?r!r!r"rB]szTqdmDefaultWriteLock.releasecCs|��dSr4)r>�r*r!r!r"�	__enter__aszTqdmDefaultWriteLock.__enter__cGs|��dSr4)rB�r*�excr!r!r"�__exit__dszTqdmDefaultWriteLock.__exit__cCsPt|d�sLzt��|_Wn2tk
r2d|_Yntk
rJd|_YnXdS)Nr:)�hasattr�mp�RLockr:�ImportError�OSError�r=r!r!r"r7gs

z#TqdmDefaultWriteLock.create_mp_lockcCs8t|d�s4zt��|_Wntk
r2d|_YnXdS)Nr;)rH�thrJr;rLrMr!r!r"r8qs

z#TqdmDefaultWriteLock.create_th_lockN)rrr r0r)r>rBrDrG�classmethodr7r8r!r!r!r"r3Hs
	r3c@s�eZdZdZdZdZedUdd��Zedd	��Zed
d��Z	edVd
d��Z
edd��ZedWdd��Zdd�Z
edXdd��Zedd��ZedYdd��ZeedZdd���Zed d!��Zed"d#��Zed$d%��Zd[d*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zed4d5��Zd6d7�Zed8d9��Zd:d;�Z d<d=�Z!d\d?d@�Z"dAdB�Z#dCdD�Z$d]dEdF�Z%d^dGdH�Z&d_dIdJ�Z'd`dKdL�Z(dMdN�Z)dadOdP�Z*dbdQdR�Z+dcdSdT�Z,dS)drz�
    Decorate an iterable object, returning an iterator which acts exactly
    like the original iterable, but prints a dynamically updating
    progressbar every time a value is requested.
    �
N���cCs�dD]r}t|�dkrnt|�dkrXt|�dkrBd�|�||Sd�|�||Sd�|�||S||}qd�|�|S)	a�
        Formats a number (greater than unity) with SI Order of Magnitude
        prefixes.

        Parameters
        ----------
        num  : float
            Number ( >= 1) to format.
        suffix  : str, optional
            Post-postfix [default: ''].
        divisor  : float, optionl
            Divisor between prefixes [default: 1000].

        Returns
        -------
        out  : str
            Number with Order of Magnitude SI unit postfix.
        )rQr.�M�G�T�P�E�Zg<�@g�����X@g=
ףp�#@z{0:1.2f}z{0:2.1f}z{0:3.0f}z	{0:3.1f}Y)�abs�format)Znum�suffix�divisor�unitr!r!r"�
format_sizeof�s
ztqdm.format_sizeofcCsBtt|�d�\}}t|d�\}}|r2d�|||�Sd�||�SdS)z�
        Formats a number of seconds as a clock time, [H:]MM:SS

        Parameters
        ----------
        t  : int
            Number of seconds.

        Returns
        -------
        out  : str
            [H:]MM:SS
        �<z{0:d}:{1:02d}:{2:02d}z{0:02d}:{1:02d}N)�divmod�intrZ)�tZmins�s�h�mr!r!r"�format_interval�s
ztqdm.format_intervalcCs:d�|��dd��dd�}t|�}t|�t|�kr6|S|S)z�
        Intelligent scientific notation (.3g).

        Parameters
        ----------
        n  : int or float or Numeric
            A Number.

        Returns
        -------
        out  : str
            Formatted number.
        z{0:.3g}z+0�+z-0�-)rZ�replacer&�len)�n�fr!r!r"�
format_num�sztqdm.format_num�333333�?cCs |dkr|S||d||S)a�
        Exponential moving average: smoothing to give progressively lower
        weights to older values.

        Parameters
        ----------
        x  : float
            New value to include in EMA.
        mu  : float, optional
            Previous EMA value.
        alpha  : float, optional
            Smoothing factor in range [0, 1], [default: 0.3].
            Increase to give more weight to recent values.
            Ranges from 0 (yields mu) to 1 (yields x).
        Nrr!)�xZmuZalphar!r!r"�ema�sztqdm.emacs:|�t�ddd�����fdd��dg���fdd�}|S)	z�
        Manage the printing and in-place updating of a line of characters.
        Note that if the string is longer than a line, then in-place
        updating may not work (it will print a new line at each refresh).
        �flushcSsdSr4r!r!r!r!r"�<lambda>��z%tqdm.status_printer.<locals>.<lambda>cs��t|����dSr4)�writer
�rc)�fp�fp_flushr!r"r,�sz%tqdm.status_printer.<locals>.fp_writercs6t|�}�d|dt�d|d��|�d<dS)N�
� r)rj�max)rcZlen_s)r,�last_lenr!r"�print_status�s"z)tqdm.status_printer.<locals>.print_status)�getattr)�filer|r!)rvrwr,r{r"�status_printer�sztqdm.status_printerF�itc%Ks�|r||krd}|r<|dkr<||9}||9}|r8||9}d}tj}
|
|�}|dkr^|r^||}|rjd|nd}tj}|r�|r�||�q�d�|�nd|d}|r�|r�||�q�d�|�ndd|}|r�|dkr�|n|}|r�|||d	�}|r�|||d	�nd}nt|�}t|�}z|
�rd
|
nd}
Wntk
�r6YnX|�rn||}|d}|�rd|
|||�nd}|�r�|d
d�dk}|�r�|n|d}nd}|d�|�7}d�||||||
�}|dk�r�|dd�|dd�S|	�r|tf||||||�r|dk�r|n|||||||||||�pd|
d�|��}|�s>|	�dd�}	d|	k�rp|	�d�\}}|jf|�}|jf|�}n|	jf|�S|�r�t	d|t
t�d||���}nd}|�r�t
t||d�d�\} }!d| }"|!�r�td|!�nd}#n<t
t||d�d�\} }!td�| }"|!�rtd|!�nd}#| |k�rL|"|#dt	|| dd�}$n|"dt	|| d�}$||$|S|�r||dndd�|||||
�SdS)a�

        Return a string-based progress bar given some parameters

        Parameters
        ----------
        n  : int
            Number of finished iterations.
        total  : int
            The expected total number of iterations. If meaningless (), only
            basic progress statistics are displayed (no ETA).
        elapsed  : float
            Number of seconds passed since start.
        ncols  : int, optional
            The width of the entire output message. If specified,
            dynamically resizes the progress meter to stay within this bound
            [default: None]. The fallback meter width is 10 for the progress
            bar + no limit for the iterations counter and statistics. If 0,
            will not print any meter (only stats).
        prefix  : str, optional
            Prefix message (included in total width) [default: ''].
            Use as {desc} in bar_format string.
        ascii  : bool, optional
            If not set, use unicode (smooth blocks) to fill the meter
            [default: False]. The fallback is to use ASCII characters
            (1-9 #).
        unit  : str, optional
            The iteration unit [default: 'it'].
        unit_scale  : bool or int or float, optional
            If 1 or True, the number of iterations will be printed with an
            appropriate SI metric prefix (k = 10^3, M = 10^6, etc.)
            [default: False]. If any other non-zero number, will scale
            `total` and `n`.
        rate  : float, optional
            Manual override for iteration rate.
            If [default: None], uses n/elapsed.
        bar_format  : str, optional
            Specify a custom bar string formatting. May impact performance.
            [default: '{l_bar}{bar}{r_bar}'], where
            l_bar='{desc}: {percentage:3.0f}%|' and
            r_bar='| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, '
              '{rate_fmt}{postfix}]'
            Possible vars: l_bar, bar, r_bar, n, n_fmt, total, total_fmt,
              percentage, rate, rate_fmt, rate_noinv, rate_noinv_fmt,
              rate_inv, rate_inv_fmt, elapsed, remaining, desc, postfix.
            Note that a trailing ": " is automatically removed after {desc}
            if the latter is empty.
        postfix  : *, optional
            Similar to `prefix`, but placed at the end
            (e.g. for additional stats).
            Note: postfix is usually a string (not a dict) for this method,
            and will if possible be set to postfix = ', ' + postfix.
            However other types are supported (#382).
        unit_divisor  : float, optional
            [default: 1000], ignored unless `unit_scale` is True.

        Returns
        -------
        out  : Formatted meter and stats, ready to display.
        N)TrFrz{0:5.2f}�?z/szs/)r\�, rQ�d���r$z
{0:3.0f}%|z| {0}/{1} [{2}<{3}, {4}{5}]rrA)rk�n_fmt�total�	total_fmt�
percentage�rate�rate_fmtZ
rate_noinv�rate_noinv_fmtZrate_inv�rate_inv_fmt�elapsedZ	remaining�l_bar�r_bar�desc�postfixz{desc}: z{bar}rP�#�0ry�i�%i�%z{0}{1} [{2}, {3}{4}])rrfr^rZr&�	TypeError�dictri�splitrzrjr�subr`ra�chrr)%rkr�r��ncols�prefix�asciir]�
unit_scaler��
bar_formatr��unit_divisorZextra_kwargsrfZelapsed_strZinv_rater^r�r�r�r�r�Zfracr�Z
remaining_strZbool_prefix_colon_alreadyr�r��format_dictZ
l_bar_userZ
r_bar_userZN_BARSZ
bar_lengthZfrac_bar_lengthZbarZfrac_barZfull_barr!r!r"�format_meter�sA�������������
�
�

 ����
����ztqdm.format_meterc
Os�t�|�}t|d�st�|_|���|j�|�W5QRX|jr�|jdksV|j�	�s�zt
||j�|_Wn:tk
r�}ztdt
|�t�d|_W5d}~XYnX|S)N�
_instancesz>tqdm:disabling monitor support (monitor_interval = 0) due to:
r)�object�__new__rHrr��get_lock�add�monitor_interval�monitor�reportr�	Exceptionrr&r)r=�args�kwargs�instance�er!r!r"r��s$


���ztqdm.__new__cs6t�fdd�|jD��}tttt|�d���|��S)zSkips specified instancec3s*|]"}|�k	rt|d�rt|j�VqdS)�posN)rHrYr�)r5�inst�r�r!r"�	<genexpr>�s
�z%tqdm._get_free_pos.<locals>.<genexpr>r)�setr��min�rangerj�
difference)r=r�Z	positionsr!r�r"�
_get_free_pos�sztqdm._get_free_posc	Cs�|j�fz|j�|�Wntk
r,YnX|jsh|jD],}t|d�r:|jt|j�kr:|jd8_q:W5QRX|js�|jr�z|j�	�|`Wnt
k
r�YnXd|_dS)zs
        Remove from list and reposition other bars
        so that newer bars won't overlap previous bars
        r�rN)�_lockr��remove�KeyError�guirHr�rYr��exit�AttributeError)r=r�r�r!r!r"�_decr_instances�s 

ztqdm._decr_instancesr#c	CsD|dk	r|ntj}|j||d��|�|�|�|�W5QRXdS)zF
        Print a message via tqdm (without overlap with bars)
        N)r~�nolock)�sys�stdout�external_write_modert)r=rcr~�endr�rvr!r!r"rt�s
z
tqdm.writeccs�|dk	r|ntj}|s"|����g}t|dg�D]F}t|d�r2|j|ksbtdd�||jfD��r2|jdd�|�	|�q2dV|D]}|j
dd�q�|s�|j��dS)z�
        Disable tqdm within context and refresh tqdm when exits.
        Useful when writing to standard output stream
        Nr��start_tcss|]}|tjtjfkVqdSr4)r�r��stderr)r5rlr!r!r"r�sz+tqdm.external_write_mode.<locals>.<genexpr>T)r�)
r�r�r�r>r}rHrv�all�clear�append�refreshr�rB)r=r~r�rvZinst_clearedr�r!r!r"r�s�ztqdm.external_write_modecCs
||_dS)zSet the global lock.N)r�)r=r@r!r!r"�set_lock$sz
tqdm.set_lockcCst|d�st�|_|jS)z7Get the global lock. Construct it if it does not exist.r�)rHr3r�rMr!r!r"r�)s
z
tqdm.get_lockc
s>ddlm}ddlm�ddlm}zddlm�Wntk
rLd�YnXzddl	m
}m}m}m
}Wn,tk
r�ddlm
}m}m}m
}YnX��dd�g�d������fd
d�	}	|	��_|	�|_|	d��_|	d�|_|	�|_|	�|_|	d
�|_|	�|_|	�|_|	�|_|	d�|_|	d�|_�dk	�r:|	��_dS)a&
        Registers the given `tqdm` class with
            pandas.core.
            ( frame.DataFrame
            | series.Series
            | groupby.DataFrameGroupBy
            | groupby.SeriesGroupBy
            ).progress_apply

        A new instance will be create every time `progress_apply` is called,
        and each instance will automatically close() upon completion.

        Parameters
        ----------
        targs, tkwargs  : arguments for the tqdm instance

        Examples
        --------
        >>> import pandas as pd
        >>> import numpy as np
        >>> from tqdm import tqdm, tqdm_gui
        >>>
        >>> df = pd.DataFrame(np.random.randint(0, 100, (100000, 6)))
        >>> tqdm.pandas(ncols=50)  # can use tqdm_gui, optional kwargs, etc
        >>> # Now you can use `progress_apply` instead of `apply`
        >>> df.groupby(0).progress_apply(lambda x: x**2)

        References
        ----------
        https://stackoverflow.com/questions/18603270/
        progress-indicator-during-pandas-operations-python
        r)�	DataFrame)�Series)�Panel)�_Rolling_and_ExpandingN)�DataFrameGroupBy�
SeriesGroupBy�GroupBy�PanelGroupBy�deprecated_t�applycs�������fdd�}|S)Ncs
��dt|dd��}|dkr��dkr,|j}n\t|��r@t|�}nH�dksRt|��s�|�dd�}|dkrld}n|dkrxd	}|j|j|}�ddk	r��d�d�d<n��d|i����t|�dkr�td
t�jdt	j
j�d���fd
d�}t|��|f|�}���|S)aT
                Parameters
                ----------
                df  : (DataFrame|Series)[GroupBy]
                    Data (may be grouped).
                func  : function
                    To be applied on the (grouped) data.
                **kwargs  : optional
                    Transmitted to `df.apply()`.
                r�ZngroupsN�applymap�axisr�index�columnsrz�Except func, normal arguments are intentionally not supported by `(DataFrame|Series|GroupBy).progress_apply`. Use keyword arguments instead.rt�r,cs,�j�jr�j�jkrdndd��||�S)Nrr)rk)�updater�rk�r�r���funcrbr!r"�wrapper�s"zDtqdm.pandas.<locals>.inner_generator.<locals>.inner.<locals>.wrapper)
�popr}�size�
isinstancerj�get�shaperrvr�r�rt�close)Zdfr�r�r�r�r�r��result)r�r�r��df_function�targs�tclass�tkwargsr�r"�inneres8


�
�
z3tqdm.pandas.<locals>.inner_generator.<locals>.innerr!)r�r��r�r�r�r�r�r�)r�r"�inner_generatords?z$tqdm.pandas.<locals>.inner_generator�mapr�Z	aggregateZ	transform)r�)Zpandas.core.framer�Zpandas.core.seriesr��pandasr�Zpandas.core.windowr�rKZpandas.core.groupby.groupbyr�r�r�r�Zpandas.core.groupbyr�Zprogress_applyZprogress_mapZprogress_applymapZprogress_aggregateZprogress_transform)
r�r�r�r�r�r�r�r�r�r�r!r�r"r�0s6"
D





ztqdm.pandasT皙�����?�$@rc	Ks|dkrtj}|dkr,t|d�r,|��s,d}|dkrf|dk	rfzt|�}Wnttfk
rdd}YnX|td�krvd}|r�||_||_	|�
|�|_|j�
|�||_||_dS|�rd|_	|�
|�|_|j�
|�ddlm}d|k�rt|d�t|d	tjj�d
�ntdt|���|dk�r0|tjtjfk�s6|�rf|�rRt�}|�rf||�}nt�}|�rf||�}|	dk�rzd}	d}nd}|dk�r�d}|dk�r�d}|
dk�r�t|�}
|�r�|
�s�t|�}|dk�r�d}||_|�p�d
|_||_||_||_||_||_||_ |	|_!||_"|
|_#||_	||_$|
|_%||_&||_'||_(||_)d|_*t+|_,||_-d|_.|�r�z|j/fddi|��Wntk
�r�||_.YnX||_0||_|j1�&|dk�r�|�
|�|_n||_W5QRX|�s|�2|j�|_3|j1�|�4�W5QRX|�,�|_5|j5|_6dS)as
        Parameters
        ----------
        iterable  : iterable, optional
            Iterable to decorate with a progressbar.
            Leave blank to manually manage the updates.
        desc  : str, optional
            Prefix for the progressbar.
        total  : int, optional
            The number of expected iterations. If unspecified,
            len(iterable) is used if possible. If float("inf") or as a last
            resort, only basic progress statistics are displayed
            (no ETA, no progressbar).
            If `gui` is True and this parameter needs subsequent updating,
            specify an initial arbitrary large positive integer,
            e.g. int(9e9).
        leave  : bool, optional
            If [default: True], keeps all traces of the progressbar
            upon termination of iteration.
        file  : `io.TextIOWrapper` or `io.StringIO`, optional
            Specifies where to output the progress messages
            (default: sys.stderr). Uses `file.write(str)` and `file.flush()`
            methods.
        ncols  : int, optional
            The width of the entire output message. If specified,
            dynamically resizes the progressbar to stay within this bound.
            If unspecified, attempts to use environment width. The
            fallback is a meter width of 10 and no limit for the counter and
            statistics. If 0, will not print any meter (only stats).
        mininterval  : float, optional
            Minimum progress display update interval [default: 0.1] seconds.
        maxinterval  : float, optional
            Maximum progress display update interval [default: 10] seconds.
            Automatically adjusts `miniters` to correspond to `mininterval`
            after long display update lag. Only works if `dynamic_miniters`
            or monitor thread is enabled.
        miniters  : int, optional
            Minimum progress display update interval, in iterations.
            If 0 and `dynamic_miniters`, will automatically adjust to equal
            `mininterval` (more CPU efficient, good for tight loops).
            If > 0, will skip display of specified number of iterations.
            Tweak this and `mininterval` to get very efficient loops.
            If your progress is erratic with both fast and slow iterations
            (network, skipping items, etc) you should set miniters=1.
        ascii  : bool, optional
            If unspecified or False, use unicode (smooth blocks) to fill
            the meter. The fallback is to use ASCII characters `1-9 #`.
        disable  : bool, optional
            Whether to disable the entire progressbar wrapper
            [default: False]. If set to None, disable on non-TTY.
        unit  : str, optional
            String that will be used to define the unit of each iteration
            [default: it].
        unit_scale  : bool or int or float, optional
            If 1 or True, the number of iterations will be reduced/scaled
            automatically and a metric prefix following the
            International System of Units standard will be added
            (kilo, mega, etc.) [default: False]. If any other non-zero
            number, will scale `total` and `n`.
        dynamic_ncols  : bool, optional
            If set, constantly alters `ncols` to the environment (allowing
            for window resizes) [default: False].
        smoothing  : float, optional
            Exponential moving average smoothing factor for speed estimates
            (ignored in GUI mode). Ranges from 0 (average speed) to 1
            (current/instantaneous speed) [default: 0.3].
        bar_format  : str, optional
            Specify a custom bar string formatting. May impact performance.
            [default: '{l_bar}{bar}{r_bar}'], where
            l_bar='{desc}: {percentage:3.0f}%|' and
            r_bar='| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, '
              '{rate_fmt}{postfix}]'
            Possible vars: l_bar, bar, r_bar, n, n_fmt, total, total_fmt,
              percentage, rate, rate_fmt, rate_noinv, rate_noinv_fmt,
              rate_inv, rate_inv_fmt, elapsed, remaining, desc, postfix.
            Note that a trailing ": " is automatically removed after {desc}
            if the latter is empty.
        initial  : int, optional
            The initial counter value. Useful when restarting a progress
            bar [default: 0].
        position  : int, optional
            Specify the line offset to print this bar (starting from 0)
            Automatic if unspecified.
            Useful to manage multiple bars at once (eg, from threads).
        postfix  : dict or *, optional
            Specify additional stats to display at the end of the bar.
            Calls `set_postfix(**postfix)` if possible (dict).
        unit_divisor  : float, optional
            [default: 1000], ignored unless `unit_scale` is True.
        gui  : bool, optional
            WARNING: internal parameter - do not use.
            Use tqdm_gui(...) instead. If set, will attempt to use
            matplotlib animations for a graphical output [default: False].

        Returns
        -------
        out  : decorated iterator.
        N�isattyT�infr��dedent�nestedz�                       `nested` is deprecated and automated.
                       Use `position` instead for manual control.
                       rtr�zUnknown argument(s): FrQr�)7r�r�rHr�rjr�r��float�iterable�disabler�r�r�r�rkr��textwrapr�rr}rtrr&r�rrr
r��leavervr��mininterval�maxinterval�miniters�dynamic_minitersr�r]r�r�r��
dynamic_ncols�	smoothing�avg_timer�_timer�r��set_postfix�last_print_nr�r�sp�display�last_print_tr�)r*r�r�r�r�r~r�r�r�r�r�r�r]r�r�rr��initialZpositionr�r�r�r�r�Z_dynamic_ncolsr�r!r!r"r)�s�i
����








z
tqdm.__init__cCsJ|jdkr|jSt|jd�r(|jjdSt|jd�r>t|j�St|dd�S)Nr�r�__len__r�)r�r�rHr�rjr}rCr!r!r"r	�s

�ztqdm.__len__cCs|Sr4r!rCr!r!r"rD�sztqdm.__enter__cGs|��dS)NF�r�rEr!r!r"rG�sz
tqdm.__exit__cCs|��dSr4r
rCr!r!r"�__del__�sztqdm.__del__cCsnt|j|jt|d�r"|��|jnd|jr6|�|j�n|j|j	|j
|j|j|j
rZd|j
nd|j|j|jd�S)z&Public API for read-only member accessr�rrN)rkr�r�r�r�r�r]r�r�r�r�r�)r�rkr�rHrr�r�rvr�r�r�r]r�rr�r�r�rCr!r!r"r��s$���ztqdm.format_dictcCs|jf|j�Sr4)r�r�rCr!r!r"�__repr__�sz
tqdm.__repr__cCstt|dd��S)Nr�l�rYr}rCr!r!r"�_comparable�sztqdm._comparablecCst|�Sr4)�idrCr!r!r"�__hash__�sz
tqdm.__hash__c
cs�|j}|jr |D]
}|Vq�n�|j}|j}|j}|j}|j}|j}|j}	|j	}
|j
}|j}t|d�s�ddl
m}
t|
d�t|jdtjj�d��|D�](}|V|	d7}	|	||jkr�|j}|�|}||kr�|�}|	|}|
�r
|�r
|�r
||}|�|||
�}||_
|	|_|j�|��W5QRX|�r�|�rb||k�rb|�rT|||}n|||}n<|
�r�|}|�r�|�r�|||9}|�|||
�}n
t||�}|	|_|_}||_}||_q�||_|	|_||_|��dS)	z6Backward-compatibility to use: for x in tqdm(iterable)rrr�z\                Please use `tqdm_gui(...)` instead of `tqdm(..., gui=True)`
                rtr�rN)r�r�r�r�r�r�rrrkrrrrHr�r�rr}rvr�r�rtrpr�rrzr�)r*r��objr�r�r�r�rrrkrrrr��delta_t�cur_t�delta_itr�r!r!r"�__iter__�sj
�



z
tqdm.__iter__rc	Cs�|jr
dS|dkr td�|���|j|7_|j|j|jk�r�|��|j}||jk�r�|��}|j|j}|j	r�|r�|r�||}|�
||j|j	�|_t|d�s�ddl
m}t|d�t|jdtjj�d��|j�|��W5QRX|j�r�|j�r0||jk�r0|j�r||j||_n||j||_nP|j	�rr|j	||j�rX|�rX|j|nd	d	|j	|j|_nt|j|�|_|j|_||_dS)
a~
        Manually update the progress bar, useful for streams
        such as reading files.
        E.g.:
        >>> t = tqdm(total=filesize) # Initialise
        >>> for current_buffer in stream:
        ...    ...
        ...    t.update(len(current_buffer))
        >>> t.close()
        The last line is highly recommended, but possibly not necessary if
        `t.update()` will be called in such a way that `filesize` will be
        exactly reached and printed.

        Parameters
        ----------
        n  : int, optional
            Increment to add to the internal counter of iterations
            [default: 1].
        Nrzn ({0}) cannot be negativerr�zd                    Please use `tqdm_gui(...)` instead of `tqdm(..., gui=True)`
                    rtr�r)r��
ValueErrorrZrkrr�rrr�rrprrHr�r�rr}rvr�r�rtr�rr�r�rz)r*rkrrrr�r�r!r!r"r� s\�
�������ztqdm.updatec
s��jr
dSd�_t�j�}����t�d�s2dS�fdd�}z|d�Wn:tk
r�}zdt|�krrWY�
dS�W5d}~XYnX�j�h�jrֈj	�j
kr�d�_�j|d�t
d	d
��jD�|g�s�|d�n�jd|d�|s�|d
�W5QRXdS)zE
        Cleanup and (if leave=False) close the progressbar.
        NTrcs�j�t|��dSr4)rvrtr
rurCr!r"r,sztqdm.close.<locals>.fp_writerQ�closed)r�cSsg|]}tt|dd���qS)r�rr
)r5�ir!r!r"r6�s�ztqdm.close.<locals>.<listcomp>r#)r+r�rx)r�rYr�r�rHrr&r�r�rrkrrrzr�)r*r�r,r�r!rCr"r�ls8



��
z
tqdm.closecCs&|��}|j||j7_||_dS)z:
        Restart tqdm timer from last print time.
        N)rr�r)r*rr!r!r"�unpause�sztqdm.unpausecCs"|r|dnd|_|r|��dS)z�
        Set/modify description of the progress bar.

        Parameters
        ----------
        desc  : str, optional
        refresh  : bool, optional
            Forces refresh [default: True].
        r$rQN�r�r��r*r�r�r!r!r"�set_description�s
ztqdm.set_descriptioncCs|pd|_|r|��dS)z?
        Set/modify description without ': ' appended.
        rQNrrr!r!r"�set_description_str�s
ztqdm.set_description_strcs�t|dkrgn|��t|���D]}||�|<q ���D]D}t�|t�r`|��|��|<q:t�|t�s:t�|��|<q:d��fdd����D��|_	|r�|�
�dS)a8
        Set/modify postfix (additional stats)
        with automatic formatting based on datatype.

        Parameters
        ----------
        ordered_dict  : dict or OrderedDict, optional
        refresh  : bool, optional
            Forces refresh [default: True].
        kwargs  : dict, optional
        Nr�c3s"|]}|d�|��VqdS)�=N)�strip)r5�key�r�r!r"r��s�z#tqdm.set_postfix.<locals>.<genexpr>)r
�sorted�keysr�rrmrr&�joinr�r�)r*Zordered_dictr�r�r r!r!r"r�s
�
ztqdm.set_postfixcCst|�|_|r|��dS)zS
        Postfix without dictionary expansion, similar to prefix handling.
        N)r&r�r�)r*rcr�r!r!r"�set_postfix_str�s
ztqdm.set_postfix_strcCs.|j�td|t�|��|j��dS)Nr#)rvrtr
r	rq)r*rkr!r!r"�moveto�s ztqdm.movetocCsb|jr
dS|s|j��|�t|j��|�d�|j�d�|�t|j��|s^|j�	�dS)z+
        Clear current bar display
        NrQrx)
r�r�r>r&rYr�rrvrtrB�r*r�r!r!r"r��s

z
tqdm.clearcCs2|jr
dS|s|j��|��|s.|j��dS)z7
        Force refresh the display of this bar
        N)r�r�r>rrBr'r!r!r"r��s
ztqdm.refreshcCsN|dkrt|j�}|r |�|�|�|dkr4|��n|�|rJ|�|�dS)z�
        Use `self.sp` and to display `msg` in the specified `pos`.

        Parameters
        ----------
        msg  : what to display (default: repr(self))
        pos  : position to display in. (default: abs(self.pos))
        N)rYr�r&rr)r*r+r�r!r!r"r�s	

ztqdm.display)rQrR)Nrn)	NrQFr�FNNNrR)N)Nr#F)NF)NNNTNNr�r�NNFr�FFrnNrNNrRF)r)NT)NT)NT)rQT)F)F)NN)-rrr r0r�r��staticmethodr^rfrmrprr�r�rOr�r�rtrr�r�r�r�r)r	rDrGr�propertyr�rrrrr�r�rrrrr%r&r�r�rr!r!r!r"r�s�


�F




�
h

U
L,






cOstt|�f|�S)zh
    A shortcut for tqdm(xrange(*args), **kwargs).
    On Python3+ range is used instead of xrange.
    )rrr�r!r!r"rs)1r0Z
__future__rrZ_utilsrrrrr	r
rrr
rrZ_monitorrr�Znumbersrr�
contextlibrZmultiprocessingrIZ	threadingrN�warningsr�
__author__�__all__r�rr�r�Warningr�
FutureWarningr�DeprecationWarningr�RuntimeWarningrr�r3r8rrr!r!r!r"�<module>sT	4
��
6