o
    ¨Ýj|  ã                   @   sZ   d Z ddlZddlmZ ddlmZ ddgiZg d¢ZG d	d
„ d
eƒZ	dd„ Z
e	Ze
ZdS )zË
Asynchronous progress bar decorator for iterators.
Includes a default `range` iterator printing to `stderr`.

Usage:
>>> from tqdm.asyncio import trange, tqdm
>>> async for i in trange(10):
...     ...
é    N)Úversion_infoé   )Útqdmzgithub.com/Z	casperdcl)Útqdm_asyncioÚtaranger   Útrangec                       sh   e Zd ZdZd‡ fdd„	Zdd„ Zdd„ Zd	d
„ Zeddddœdd„ƒZ	edddddœdd„ƒZ
‡  ZS )r   z0
    Asynchronous-friendly version of tqdm.
    Nc                    sž   t ƒ j|g|¢R i |¤Ž d| _|d urMt|dƒr"|j| _d| _d S t|dƒr6| ¡ | _| jj| _d| _d S t|dƒrA|j| _d S t	|ƒ| _| jj| _d S d S )NFÚ	__anext__TÚ	__aiter__Ú__next__)
ÚsuperÚ__init__Úiterable_awaitableÚhasattrr   Úiterable_nextr	   Ziterable_iteratorr
   Úiter)ÚselfÚiterableÚargsÚkwargs©Ú	__class__© úG/var/www/html/chatgpt/venv/lib/python3.10/site-packages/tqdm/asyncio.pyr      s   







ôztqdm_asyncio.__init__c                 C   s   | S ©Nr   )r   r   r   r   r	   (   s   ztqdm_asyncio.__aiter__c                 Ã   s`   �z| j r|  ¡ I d H }n|  ¡ }|  ¡  |W S  ty$   |  ¡  t‚ ty/   |  ¡  ‚ w r   )r   r   ÚupdateÚStopIterationÚcloseÚStopAsyncIterationÚBaseException)r   Úresr   r   r   r   +   s   €þztqdm_asyncio.__anext__c                 O   s   | j j|i |¤ŽS r   )r   Úsend)r   r   r   r   r   r   r    :   s   ztqdm_asyncio.send©ÚloopÚtimeoutÚtotalc                k   s^   � |du r	t |ƒ}i }tdd… dk r||d< | tj|fd|i|¤Žfd|i|¤ŽE dH  dS )z5
        Wrapper for `asyncio.as_completed`.
        Né   )é   é
   r"   r#   r$   )Úlenr   ÚasyncioÚas_completed)ÚclsÚfsr"   r#   r$   Útqdm_kwargsr   r   r   r   r*   =   s   €ÿÿztqdm_asyncio.as_completedF)r"   r#   r$   Úreturn_exceptionsc          	      �   s`   �‡ fdd„‰‡fdd„t |ƒD ƒ}dd„ | j|f|||dœ|¤ŽD ƒI dH }dd„ t|ƒD ƒS )	z/
        Wrapper for `asyncio.gather`.
        c              
   “   sF   �z| |I d H fW S  t y" } zˆ r| |fW  Y d }~S ‚ d }~ww r   )Ú	Exception)ÚiÚfÚe)r.   r   r   Úwrap_awaitableP   s   €€ýz+tqdm_asyncio.gather.<locals>.wrap_awaitablec                    s   g | ]	\}}ˆ ||ƒ‘qS r   r   )Ú.0r0   r1   )r3   r   r   Ú
<listcomp>X   s    z'tqdm_asyncio.gather.<locals>.<listcomp>c                 Ó   s   �g | ]}|I d H ‘qS r   r   )r4   r1   r   r   r   r5   Y   s   € r!   Nc                 S   s   g | ]\}}|‘qS r   r   )r4   Ú_r0   r   r   r   r5   [   s    )Ú	enumerater*   Úsorted)	r+   r"   r#   r$   r.   r,   r-   Úifsr   r   )r.   r3   r   ÚgatherJ   s   €ÿÿztqdm_asyncio.gatherr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   r   r    Úclassmethodr*   r:   Ú__classcell__r   r   r   r   r      s    r   c                  O   s   t t| Ž fi |¤ŽS )zE
    A shortcut for `tqdm.asyncio.tqdm(range(*args), **kwargs)`.
    )r   Úrange)r   r   r   r   r   r   ^   s   r   )r>   r)   Úsysr   Zstdr   Zstd_tqdmÚ
__author__Ú__all__r   r   r   r   r   r   r   Ú<module>   s    	
K