o
    ~#gc(                  	   @   sv  U d dl Z d dlZd dlZd dlmZmZmZ d dlmZmZm	Z	m
Z
mZ d dlmZmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlm Z  d d	l!m"Z" zd d
l#m$Z$ W n e%yr   dZ$Y nw ee	e& ge	e& f Z'dededefddZ(e(eeZ)ee*d< G dd dZ+G dd deZ,G dd deZ-G dd dZ.G dd dZ/G dd de/e+e.Z0G dd de0e)Z1G dd  d e0e,Z2G d!d" d"e0eZ3G d#d$ d$e0eZ4G d%d& d&e0e-Z5G d'd( d(e/e+e.eZ6e2e2fe1e6fe3e6fe4e6fe5e6fd)Z7d*e8d+e
e9 de'fd,d-Z:d.e	e& d/e8d0e9de	e& fd1d2Z;dd3d/e8d0e
e9 de'fd4d5Z<dS )6    N)SIGINTdefault_int_handlersignal)AnyCallableIteratorOptionalTuple)BarFillingCirclesBarIncrementalBar)Spinner)
	BarColumnDownloadColumnFileSizeColumnProgressProgressColumnSpinnerColumn
TextColumnTimeElapsedColumnTimeRemainingColumnTransferSpeedColumn)WINDOWS)get_indentation)format_size)colorama	preferredfallbackreturnc                 C   sp   t | jdd }|s|S t | ddt | ddg}|tt | dg 7 }zd|| W | S  ty7   | Y S w )Nencoding
empty_fill fillphases)getattrfilelistjoinencodeUnicodeEncodeError)r   r   r   
characters r+   /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/pip/_internal/cli/progress_bars.py_select_progress_class$   s   

r-   _BaseBarc                       sD   e Zd ZdZdededdf fddZd fdd	Zd
d Z  ZS )InterruptibleMixina  
    Helper to ensure that self.finish() gets called on keyboard interrupt.

    This allows downloads to be interrupted without leaving temporary state
    (like hidden cursors) behind.

    This class is similar to the progress library's existing SigIntMixin
    helper, but as of version 1.2, that helper has the following problems:

    1. It calls sys.exit().
    2. It discards the existing SIGINT handler completely.
    3. It leaves its own handler in place even after an uninterrupted finish,
       which will have unexpected delayed effects if the user triggers an
       unrelated keyboard interrupt some time after a progress-displaying
       download has already completed, for example.
    argskwargsr   Nc                    s8   t  j|i | tt| j| _| jdu rt| _dS dS )z=
        Save the original SIGINT handler for later.
        N)super__init__r   r   handle_sigintoriginal_handlerr   selfr0   r1   	__class__r+   r,   r3   T   s
   

zInterruptibleMixin.__init__c                    s   t    tt| j dS )z
        Restore the original SIGINT handler after finishing.

        This should happen regardless of whether the progress display finishes
        normally, or gets interrupted.
        N)r2   finishr   r   r5   r7   r8   r+   r,   r:   e   s   
zInterruptibleMixin.finishc                 C   s   |    | || dS )z
        Call self.finish() before delegating to the original SIGINT handler.

        This handler should only be in place while the progress display is
        active.
        N)r:   r5   )r7   signumframer+   r+   r,   r4   o   s   z InterruptibleMixin.handle_sigintr   N)	__name__
__module____qualname____doc__r   r3   r:   r4   __classcell__r+   r+   r8   r,   r/   B   s
    
r/   c                   @   s   e Zd ZdddZdS )	SilentBarr   Nc                 C   s   d S Nr+   r;   r+   r+   r,   update{   s   zSilentBar.updater>   )r?   r@   rA   rF   r+   r+   r+   r,   rD   z   s    rD   c                   @   s   e Zd ZdZdZdZdZdS )BlueEmojiBar%(percent)d%% )u   🔹u   🔷u   🔵N)r?   r@   rA   suffix
bar_prefix
bar_suffixr#   r+   r+   r+   r,   rG      s
    rG   c                       sh   e Zd Zdededdf fddZedefddZedefd	d
ZedefddZ	dd Z
  ZS )DownloadProgressMixinr0   r1   r   Nc                    s,   t  j|i | dt d  | j | _d S )NrI      )r2   r3   r   messager6   r8   r+   r,   r3      s   zDownloadProgressMixin.__init__c                 C   s
   t | jS rE   )r   indexr;   r+   r+   r,   
downloaded   s   
z DownloadProgressMixin.downloadedc                 C   s    | j dkrdS td| j  d S )Ng        z...   z/s)avgr   r;   r+   r+   r,   download_speed   s   
z$DownloadProgressMixin.download_speedc                 C   s   | j r	d| j S dS )Nzeta r!   )etaeta_tdr;   r+   r+   r,   
pretty_eta   s   z DownloadProgressMixin.pretty_etac                 c   s,    |D ]}|V  |  t| q|   d S rE   )nextlenr:   )r7   itxr+   r+   r,   iter   s
   zDownloadProgressMixin.iter)r?   r@   rA   r   r3   propertystrrQ   rT   rW   r\   rC   r+   r+   r8   r,   rM      s    rM   c                       s*   e Zd Zdededdf fddZ  ZS )WindowsMixinr0   r1   r   Nc                    sd   t r jrd _t j|i | t r.tr0t j _ fdd j_ fdd j_d S d S d S )NFc                          j j S rE   )r%   wrappedisattyr+   r;   r+   r,   <lambda>       z'WindowsMixin.__init__.<locals>.<lambda>c                      r`   rE   )r%   ra   flushr+   r;   r+   r,   rc      rd   )	r   hide_cursorr2   r3   r   AnsiToWin32r%   rb   re   r6   r8   r;   r,   r3      s   
zWindowsMixin.__init__)r?   r@   rA   r   r3   rC   r+   r+   r8   r,   r_      s    "r_   c                   @   s   e Zd ZejZdZdZdS )BaseDownloadProgressBarrH   z0%(downloaded)s %(download_speed)s %(pretty_eta)sN)r?   r@   rA   sysstdoutr%   rO   rJ   r+   r+   r+   r,   rh      s    rh   c                   @      e Zd ZdS )DefaultDownloadProgressBarNr?   r@   rA   r+   r+   r+   r,   rl          rl   c                   @   rk   )DownloadSilentBarNrm   r+   r+   r+   r,   ro      rn   ro   c                   @   rk   )DownloadBarNrm   r+   r+   r+   r,   rp      rn   rp   c                   @   rk   )DownloadFillingCirclesBarNrm   r+   r+   r+   r,   rq      rn   rq   c                   @   rk   )DownloadBlueEmojiProgressBarNrm   r+   r+   r+   r,   rr      rn   rr   c                   @   s.   e Zd ZejZdZdefddZdddZ	dS )	DownloadProgressSpinnerz!%(downloaded)s %(download_speed)sr   c                 C   s"   t | dst| j| _t| jS )N_phaser)hasattr	itertoolscycler#   rt   rX   r;   r+   r+   r,   
next_phase   s   

z"DownloadProgressSpinner.next_phaseNc                 C   sN   | j |  }|  }| j|  }d||rdnd||rdnd|g}| | d S )Nr!   rI   )rO   rx   rJ   r'   writeln)r7   rO   phaserJ   liner+   r+   r,   rF      s   




zDownloadProgressSpinner.updater>   )
r?   r@   rA   ri   rj   r%   rJ   r^   rx   rF   r+   r+   r+   r,   rs      s
    rs   )offonasciiprettyemojiprogress_barmaxc                 C   s4   |d u s|dkrt |  d  jS t |  d |djS )Nr   rR   )r   )	BAR_TYPESr\   )r   r   r+   r+   r,   _legacy_progress_bar  s   r   iterablebar_typesizec                c   s    |dks	J d|s t d}tdtdddt t t f}n|}tdt t t tdt f}t	|d	d
i}|j
dt d  |d}| | D ]}|V  |j|t|d qJW d    d S 1 sdw   Y  d S )Nr}   z-This should only be used in the default mode.infz([progress.description]{task.description}r{   g      ?)speedrU   refresh_per_second   rI   rN   )total)advance)floatr   r   r   r   r   r   r   r   r   add_taskr   rF   rY   )r   r   r   r   columnsprogresstask_idchunkr+   r+   r,   _rich_progress_bar  s4   
	"r   )r   c                 C   s.   | dkrt jt| |dS | dkrtS t| |S )zGet an object that can be used to render the download progress.

    Returns a callable, that takes an iterable to "wrap".
    r}   r   r   r|   )	functoolspartialr   r\   r   r   r+   r+   r,   get_download_progress_renderer5  s
   
r   )=r   rv   ri   r   r   r   typingr   r   r   r   r	   pip._vendor.progress.barr
   r   r   pip._vendor.progress.spinnerr   pip._vendor.rich.progressr   r   r   r   r   r   r   r   r   r   pip._internal.utils.compatr   pip._internal.utils.loggingr   pip._internal.utils.miscr   pip._vendorr   	ExceptionbytesDownloadProgressRendererr-   r.   __annotations__r/   rD   rG   rM   r_   rh   rl   ro   rp   rq   rr   rs   r   r^   intr   r   r   r+   r+   r+   r,   <module>   s~   
 08 
	

%