o
    _c
                     @   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 progressbar 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                       sf   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Z
  ZS )r   z>
    Asynchronous-friendly version of tqdm (Python 3.6+).
    Nc                    sz   t t| j|g|R i | d| _|d ur;t|dr$|j| _d| _d S t|dr/|j| _d S t|| _	| j	j| _d S d S )NF	__anext__T__next__)
superr   __init__iterable_awaitablehasattrr   iterable_nextr	   iterZiterable_iterator)selfiterableargskwargs	__class__ 7/usr/local/lib/python3.10/dist-packages/tqdm/asyncio.pyr      s   



ztqdm_asyncio.__init__c                 C   s   | S Nr   )r   r   r   r   	__aiter__$   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    6   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*   9   s   ztqdm_asyncio.as_completedc                   s\   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                    s   | |I d H fS r   r   )ifr   r   r   wrap_awaitableK   s   z+tqdm_asyncio.gather.<locals>.wrap_awaitablec                    s   g | ]	\}} ||qS r   r   ).0r.   r/   r0   r   r   
<listcomp>N   s    z'tqdm_asyncio.gather.<locals>.<listcomp>c                    s   g | ]}|I d H qS r   r   )r1   r/   r   r   r   r3   O   s    r!   Nc                 S   s   g | ]\}}|qS r   r   )r1   _r.   r   r   r   r3   Q   s    )	enumerater*   sorted)r+   r"   r#   r$   r,   r-   ifsr   r   r2   r   gatherF   s   ztqdm_asyncio.gatherr   )__name__
__module____qualname____doc__r   r   r   r    classmethodr*   r8   __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   T   s   r   )r<   r)   sysr   Zstdr   Zstd_tqdm
__author____all__r   r   r   r   r   r   r   <module>   s    	
A