o
    c~                     @   s  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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                   @   s<   e Zd ZdZejdddefddZdd	d
ZdddZ	dS )
retry_basez)Abstract base class for retry strategies.retry_stater   returnc                 C   s   d S N selfr   r   r   G/opt/certbot/lib/python3.10/site-packages/pip/_vendor/tenacity/retry.py__call__   s   zretry_base.__call__other	retry_allc                 C   
   t | |S r   )r   r	   r   r   r   r
   __and__       
zretry_base.__and__	retry_anyc                 C   r   r   )r   r   r   r   r
   __or__#   r   zretry_base.__or__N)r   r   r   r   )r   r   r   r   )
__name__
__module____qualname____doc__abcabstractmethodboolr   r   r   r   r   r   r
   r      s    
r   c                   @   "   e Zd ZdZdddefddZdS )_retry_neverz-Retry strategy that never rejects any result.r   r   r   c                 C      dS NFr   r   r   r   r
   r   *      z_retry_never.__call__Nr   r   r   r   r   r   r   r   r   r
   r   '       r   c                   @   r   )_retry_alwaysz.Retry strategy that always rejects any result.r   r   r   c                 C   r   NTr   r   r   r   r
   r   4   r   z_retry_always.__call__Nr    r   r   r   r
   r"   1   r!   r"   c                   @   s@   e Zd ZdZdejegef ddfddZdddefd	d
Z	dS )retry_if_exceptionzARetry strategy that retries if an exception verifies a predicate.	predicater   Nc                 C   
   || _ d S r   r%   r	   r%   r   r   r
   __init__>   r   zretry_if_exception.__init__r   r   c                 C   s   |j jr| |j  S dS r   outcomefailedr%   	exceptionr   r   r   r
   r   A      zretry_if_exception.__call__)
r   r   r   r   typingCallableBaseExceptionr   r)   r   r   r   r   r
   r$   ;   s    r$   c                       N   e Zd ZdZefdejeje ej	eje df f ddf fddZ
  ZS )retry_if_exception_typez=Retries if an exception has been raised of one or more types.exception_types.r   Nc                        | _ t  fdd d S )Nc                    s
   t |  S r   
isinstanceer4   r   r
   <lambda>S   s   
 z2retry_if_exception_type.__init__.<locals>.<lambda>r4   superr)   r	   r4   	__class__r:   r
   r)   K      z retry_if_exception_type.__init__r   r   r   r   	Exceptionr/   UnionTyper1   Tupler)   __classcell__r   r   r?   r
   r3   H       r3   c                       r2   )retry_if_not_exception_typezARetries except an exception has been raised of one or more types.r4   .r   Nc                    r5   )Nc                       t |   S r   r6   r8   r:   r   r
   r;   a       z6retry_if_not_exception_type.__init__.<locals>.<lambda>r<   r>   r?   r:   r
   r)   Y   rA   z$retry_if_not_exception_type.__init__rB   r   r   r?   r
   rI   V   rH   rI   c                       s`   e Zd ZdZefdejeje ej	eje df f ddf fddZ
dd	defd
dZ  ZS )retry_unless_exception_typez:Retries until an exception is raised of one or more types.r4   .r   Nc                    r5   )Nc                    rJ   r   r6   r8   r:   r   r
   r;   o   rK   z6retry_unless_exception_type.__init__.<locals>.<lambda>r<   r>   r?   r:   r
   r)   g   rA   z$retry_unless_exception_type.__init__r   r   c                 C      |j jsdS | |j  S r#   r*   r   r   r   r
   r   q   s   z$retry_unless_exception_type.__call__)r   r   r   r   rC   r/   rD   rE   r1   rF   r)   r   r   rG   r   r   r?   r
   rL   d   s    
rL   c                   @   sX   e Zd ZdZefdejeje ej	eje df f ddfddZ
dd	def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__`)
    r4   .r   Nc                 C   r&   r   )exception_cause_typesr>   r   r   r
   r)      s   
z&retry_if_exception_cause_type.__init__r   r   c                 C   s>   |j jr|j  }|d urt|j| jrdS |j}|d usdS )NTF)r+   r,   r-   r7   	__cause__rO   )r	   r   excr   r   r
   r      s   
z&retry_if_exception_cause_type.__call__)r   r   r   r   rC   r/   rD   rE   r1   rF   r)   r   r   r   r   r   r
   rN   x   s    
	rN   c                   @   B   e Zd ZdZdejejgef ddfddZdddefd	d
Z	dS )retry_if_resultz+Retries if the result verifies a predicate.r%   r   Nc                 C   r&   r   r'   r(   r   r   r
   r)      r   zretry_if_result.__init__r   r   c                 C   s   |j js| |j  S dS r   r+   r,   r%   resultr   r   r   r
   r      r.   zretry_if_result.__call__
r   r   r   r   r/   r0   Anyr   r)   r   r   r   r   r
   rS           rS   c                   @   rR   )retry_if_not_resultz*Retries if the result refutes a predicate.r%   r   Nc                 C   r&   r   r'   r(   r   r   r
   r)      r   zretry_if_not_result.__init__r   r   c                 C   s   |j js| |j   S dS r   rT   r   r   r   r
   r      s   zretry_if_not_result.__call__rV   r   r   r   r
   rY      rX   rY   c                       s@   e Zd ZdZ		ddeje deje ddf 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 rdtdtf fdd}|}n|r2t|dtdtffdd}|}n	t | jj dt | d S )	Nz.() takes either 'message' or 'match', not bothr-   r   c                    s    t | kS r   )strr-   )r[   r   r
   message_fnc   s   z8retry_if_exception_message.__init__.<locals>.message_fncc                    s   t  t| S r   )r   r\   r]   r^   )progr   r
   	match_fnc   s   z6retry_if_exception_message.__init__.<locals>.match_fncz3() missing 1 required argument 'message' or 'match')		TypeErrorr@   r   r1   r   recompiler=   r)   )r	   r[   r\   r_   r%   ra   r?   )r[   r`   r
   r)      s   
z#retry_if_exception_message.__init__NN)	r   r   r   r   r/   Optionalr]   r)   rG   r   r   r?   r
   rZ      s    rZ   c                       sR   e Zd ZdZ		ddeje deje ddf fddZdd	defd
dZ	  Z
S )retry_if_not_exception_messagez5Retries until an exception message equals or matches.Nr[   r\   r   c                    s&   t  || | j  fdd| _d S )Nc                     s    | i | S r   r   )args_kwargs_if_predicater   r
   r;      s    z9retry_if_not_exception_message.__init__.<locals>.<lambda>)r=   r)   r%   )r	   r[   r\   r?   rj   r
   r)      s   z'retry_if_not_exception_message.__init__r   r   c                 C   rM   r#   r*   r   r   r   r
   r      s   z'retry_if_not_exception_message.__call__re   )r   r   r   r   r/   rf   r]   r)   r   r   rG   r   r   r?   r
   rg      s    
rg   c                   @   4   e Zd ZdZdeddfddZdddefd	d
ZdS )r   z1Retries if any of the retries condition is valid.retriesr   Nc                 G   r&   r   rm   r	   rm   r   r   r
   r)      r   zretry_any.__init__r   r   c                       t  fdd| jD S )Nc                 3       | ]}| V  qd S r   r   .0rr   r   r
   	<genexpr>       z%retry_any.__call__.<locals>.<genexpr>)anyrm   r   r   ru   r
   r         zretry_any.__call__r   r   r   r   r   r)   r   r   r   r   r   r
   r          r   c                   @   rl   )r   z/Retries if all the retries condition are valid.rm   r   Nc                 G   r&   r   rn   ro   r   r   r
   r)      r   zretry_all.__init__r   r   c                    rp   )Nc                 3   rq   r   r   rr   ru   r   r
   rv      rw   z%retry_all.__call__.<locals>.<genexpr>)allrm   r   r   ru   r
   r      ry   zretry_all.__call__rz   r   r   r   r
   r      r{   r   )r   rc   r/   TYPE_CHECKINGpip._vendor.tenacityr   ABCr   r   retry_neverr"   retry_alwaysr$   r3   rI   rL   rN   rS   rY   rZ   rg   r   r   r   r   r   r
   <module>   s*   
