o
    QDi                     @   sH  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
 ddlmZ dZdZzd dlZdZW n	 ey9   Y nw zd dlZdZW n	 eyK   Y nw d	eee d
f fddZd	eee d
f fddZd	eee d
f fddZdee d	efddZeeddfdee deee ef d	efddZdded	efddZdS )    )datetime	timedeltatimezone)OptionalSequenceTupleTypeUnion   )HTTP_DATE_FORMAT)HTTPDateFNTreturn.c                  C   s>   g } t r| tjtjtjg tr| tjtj	j
g t| S )zGet all network errors to use by default.

    Args:
        N/A

    Returns:
        Tuple of network error exceptions.

    Raises:
        N/A

    )_HTTPX_INSTALLEDextendhttpxConnectError	ReadError
WriteError_REQUESTS_INSTALLEDrequestsConnectionError
exceptionsChunkedEncodingErrortupler    r   I/var/www/Datamplify/venv/lib/python3.10/site-packages/retryhttp/_utils.pyget_default_network_errors   s   r   c                  C   ,   g } t r
| tj tr| tj t| S )zdGet all timeout exceptions to use by default.

    Returns:
        tuple: Timeout exceptions.

    )r   appendr   TimeoutExceptionr   r   Timeoutr   r   r   r   r   get_default_timeouts9      r"   c                  C   r   )ziGet default HTTP status 4xx or 5xx exceptions.

    Returns:
        tuple: HTTP status exceptions.

    )r   r   r   HTTPStatusErrorr   r   	HTTPErrorr   r   r   r   r   "get_default_http_status_exceptionsH   r#   r&   excc                 C   s6   | du rdS t  }t| |rt| dr| jjdkS dS )zWhether a given exception indicates the user has been rate limited.

    Args:
        exc: Exception to consider.

    Returns:
        bool: Whether exc indicates rate limiting.

    NFresponsei  )r&   
isinstancehasattrr(   status_code)r'   r   r   r   r   is_rate_limitedW   s   
r,   i  iX  status_codesc                 C   sF   | du rdS t |tr|g}t }t | |r!t| dr!| jj|v S dS )a(  Whether a given exception indicates a 5xx server error.

    Args:
        exc: Exception to consider.
        status_codes: One or more 5xx status codes to consider. Defaults
            to all (500-599).

    Returns:
        bool: whether exc indicates an error included in status_codes.

    NFr(   )r)   intr&   r*   r(   r+   )r'   r-   r   r   r   r   is_server_errori   s   
r/   delta_secondsc                 C   s,   t tj}| r|t| d }t|tS )a  Builds a valid HTTP-date timestamp string according to RFC 7231.

    By default, returns an HTTP-date string for the current timestamp.
    May be offset by a positive or negative integer, in seconds.

    Args:
        delta_seconds (int): Number of seconds to offset the timestamp
            by. If a negative integer is passed, result will be in the
            past.

    Returns:
        HTTPDate: A valid HTTP-date string.

    )seconds)r   nowr   utcr   r   strftimer   )r0   dater   r   r   get_http_date   s   r6   )r   )r   r   r   typingr   r   r   r   r	   
_constantsr   _typesr   r   r   r   ImportErrorr   BaseExceptionr   r"   r&   boolr,   r   ranger.   r/   r6   r   r   r   r   <module>   s>     
