U
    ~f*"                     @   s6  d dl Z d dlZd dlZejr*d dlmZ G dd de jZejeej	dge
f f ZG dd deZe ZG dd	 d	eZe ZG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZdS )     N)RetryCallStatec                   @   sF   e Zd ZdZejdedddZd dddd	Zd d
dddZ	dS )
retry_basez)Abstract base class for retry strategies.r   retry_statereturnc                 C   s   d S N selfr   r   r   M/home/mars/bis/venv/lib/python3.8/site-packages/pip/_vendor/tenacity/retry.py__call__   s    zretry_base.__call__	retry_all)otherr   c                 C   s
   t | |S r   )r   r
   r   r   r   r   __and__    s    zretry_base.__and__	retry_anyc                 C   s
   t | |S r   )r   r   r   r   r   __or__#   s    zretry_base.__or__N)
__name__
__module____qualname____doc__abcabstractmethodboolr   r   r   r   r   r   r   r      s
   r   r   c                   @   s    e Zd ZdZdedddZdS )_retry_neverz-Retry strategy that never rejects any result.r   r   c                 C   s   dS )NFr   r	   r   r   r   r   -   s    z_retry_never.__call__Nr   r   r   r   r   r   r   r   r   r   r   *   s   r   c                   @   s    e Zd ZdZdedddZdS )_retry_alwaysz.Retry strategy that always rejects any result.r   r   c                 C   s   dS )NTr   r	   r   r   r   r   7   s    z_retry_always.__call__Nr   r   r   r   r   r   4   s   r   c                   @   s<   e Zd ZdZejegef ddddZdeddd	Z	dS )
retry_if_exceptionzARetry strategy that retries if an exception verifies a predicate.N	predicater   c                 C   s
   || _ d S r   r   r
   r   r   r   r   __init__A   s    zretry_if_exception.__init__r   r   c                 C   sF   |j d krtd|j jr>|j  }|d kr4td| |S dS d S )N(__call__() called before outcome was set(outcome failed but the exception is NoneFoutcomeRuntimeErrorfailed	exceptionr   r
   r   r)   r   r   r   r   D   s    


zretry_if_exception.__call__)
r   r   r   r   typingCallableBaseExceptionr   r"   r   r   r   r   r   r   >   s   r   c                       sL   e Zd ZdZefejeje ej	eje df f dd fddZ
  ZS )retry_if_exception_typez=Retries if an exception has been raised of one or more types..Nexception_typesr   c                    s    | _ t  fdd d S )Nc                    s
   t |  S r   
isinstanceer0   r   r   <lambda>\       z2retry_if_exception_type.__init__.<locals>.<lambda>r0   superr"   r
   r0   	__class__r5   r   r"   T   s    z retry_if_exception_type.__init__r   r   r   r   	Exceptionr+   UnionTyper-   Tupler"   __classcell__r   r   r;   r   r.   Q   s   r.   c                       sL   e Zd ZdZefejeje ej	eje df f dd fddZ
  ZS )retry_if_not_exception_typezARetries except an exception has been raised of one or more types..Nr/   c                    s    | _ t  fdd d S )Nc                    s   t |   S r   r1   r3   r5   r   r   r6   j   r7   z6retry_if_not_exception_type.__init__.<locals>.<lambda>r8   r:   r;   r5   r   r"   b   s    z$retry_if_not_exception_type.__init__r=   r   r   r;   r   rC   _   s   rC   c                       s\   e Zd ZdZefejeje ej	eje df f dd fddZ
dedd	d
Z  ZS )retry_unless_exception_typez:Retries until an exception is raised of one or more types..Nr/   c                    s    | _ t  fdd d S )Nc                    s   t |   S r   r1   r3   r5   r   r   r6   x   r7   z6retry_unless_exception_type.__init__.<locals>.<lambda>r8   r:   r;   r5   r   r"   p   s    z$retry_unless_exception_type.__init__r   r   c                 C   sB   |j d krtd|j jsdS |j  }|d kr8td| |S Nr#   Tr$   r%   r*   r   r   r   r   z   s    

z$retry_unless_exception_type.__call__)r   r   r   r   r>   r+   r?   r@   r-   rA   r"   r   r   rB   r   r   r;   r   rD   m   s   
rD   c                   @   sT   e Zd ZdZefejeje ej	eje df f ddddZ
dedd	d
ZdS )retry_if_exception_cause_typezRetries if any of the causes of the raised exception is of one or more types.

    The check on the type of the cause of the exception is done recursively (until finding
    an exception in the chain that has no `__cause__`)
    .Nr/   c                 C   s
   || _ d S r   )exception_cause_typesr:   r   r   r   r"      s    z&retry_if_exception_cause_type.__init__r   r   c                 C   sJ   |j d krtd|j jrF|j  }|d k	rFt|j| jr>dS |j}q$dS )Nz&__call__ called before outcome was setTF)r&   r'   r(   r)   r2   	__cause__rG   )r
   r   excr   r   r   r      s    

z&retry_if_exception_cause_type.__call__)r   r   r   r   r>   r+   r?   r@   r-   rA   r"   r   r   r   r   r   r   rF      s   	rF   c                   @   s>   e Zd ZdZejejgef ddddZdeddd	Z	dS )
retry_if_resultz+Retries if the result verifies a predicate.Nr   c                 C   s
   || _ d S r   r    r!   r   r   r   r"      s    zretry_if_result.__init__r   r   c                 C   s2   |j d krtd|j js*| |j  S dS d S Nr#   Fr&   r'   r(   r   resultr	   r   r   r   r      s
    
zretry_if_result.__call__
r   r   r   r   r+   r,   Anyr   r"   r   r   r   r   r   rJ      s   rJ   c                   @   s>   e Zd ZdZejejgef ddddZdeddd	Z	dS )
retry_if_not_resultz*Retries if the result refutes a predicate.Nr   c                 C   s
   || _ d S r   r    r!   r   r   r   r"      s    zretry_if_not_result.__init__r   r   c                 C   s4   |j d krtd|j js,| |j   S dS d S rK   rL   r	   r   r   r   r      s
    
zretry_if_not_result.__call__rN   r   r   r   r   rP      s   rP   c                       s8   e Zd ZdZdeje eje dd fddZ  ZS )retry_if_exception_messagez2Retries if an exception message equals or matches.Nmessagematchr   c                    s    r|rt | jj d r8ttd fdd}|}n:|r`t|ttdfdd}|}nt | jj dt | d S )Nz.() takes either 'message' or 'match', not both)r)   r   c                    s    t | kS r   )strr)   )rS   r   r   message_fnc   s    z8retry_if_exception_message.__init__.<locals>.message_fncc                    s   t  t| S r   )r   rT   rU   rV   )progr   r   	match_fnc   s    z6retry_if_exception_message.__init__.<locals>.match_fncz3() missing 1 required argument 'message' or 'match')		TypeErrorr<   r   r-   r   recompiler9   r"   )r
   rS   rT   rW   r   rY   r;   )rS   rX   r   r"      s    
z#retry_if_exception_message.__init__)NN)	r   r   r   r   r+   OptionalrU   r"   rB   r   r   r;   r   rQ      s     rQ   c                       sH   e Zd ZdZd
eje eje dd fddZdeddd	Z	  Z
S )retry_if_not_exception_messagez5Retries until an exception message equals or matches.NrR   c                    s&   t  || | j  fdd| _d S )Nc                     s    | | S r   r   )args_kwargs_if_predicater   r   r6      r7   z9retry_if_not_exception_message.__init__.<locals>.<lambda>)r9   r"   r   )r
   rS   rT   r;   ra   r   r"      s    z'retry_if_not_exception_message.__init__r   r   c                 C   sB   |j d krtd|j jsdS |j  }|d kr8td| |S rE   r%   r*   r   r   r   r      s    

z'retry_if_not_exception_message.__call__)NN)r   r   r   r   r+   r]   rU   r"   r   r   rB   r   r   r;   r   r^      s     
r^   c                   @   s0   e Zd ZdZeddddZdeddd	ZdS )
r   z1Retries if any of the retries condition is valid.Nretriesr   c                 G   s
   || _ d S r   rd   r
   rd   r   r   r   r"     s    zretry_any.__init__r   r   c                    s   t  fdd| jD S )Nc                 3   s   | ]}| V  qd S r   r   .0rr   r   r   	<genexpr>  s     z%retry_any.__call__.<locals>.<genexpr>)anyrd   r	   r   rj   r   r     s    zretry_any.__call__r   r   r   r   r   r"   r   r   r   r   r   r   r      s   r   c                   @   s0   e Zd ZdZeddddZdeddd	ZdS )
r   z/Retries if all the retries condition are valid.Nrc   c                 G   s
   || _ d S r   re   rf   r   r   r   r"     s    zretry_all.__init__r   r   c                    s   t  fdd| jD S )Nc                 3   s   | ]}| V  qd S r   r   rg   rj   r   r   rk     s     z%retry_all.__call__.<locals>.<genexpr>)allrd   r	   r   rj   r   r     s    zretry_all.__call__rm   r   r   r   r   r   	  s   r   )r   r[   r+   TYPE_CHECKINGpip._vendor.tenacityr   ABCr   r?   r,   r   
RetryBaseTr   retry_neverr   retry_alwaysr   r.   rC   rD   rF   rJ   rP   rQ   r^   r   r   r   r   r   r   <module>   s*   
