
    g/                        d Z ddlZdZdZ	 ej
                  j                  Z	 ej
                  j                  Z	 dZ	 dZ		 ej
                  j                  ej
                  j                  ej
                  j                  ej
                  j                  ej
                  j                  ej
                  j                  fZ	  G d de      Z G d	 d
e      Z G d de      Zy)zCommon utilities for Google Media Downloads and Resumable Uploads.

Includes custom exception types, useful constants and shared helpers.
    NzIAt most one of `max_cumulative_retry` and `max_retries` can be specified.i   g      P@g     @c                   "     e Zd ZdZ fdZ xZS )InvalidResponsezError class for responses which are not in the correct state.

    Args:
        response (object): The HTTP response which caused the failure.
        args (tuple): The positional arguments typically passed to an
            exception class.
    c                 4    t        t        | 
  |  || _        y N)superr   __init__responseselfr	   args	__class__s      z/var/www/html/FastMealFinder_FlaskServer-InitialRelease/venv/lib/python3.12/site-packages/google/resumable_media/common.pyr   zInvalidResponse.__init__\   s    ot-t4 G    __name__
__module____qualname____doc__r   __classcell__r   s   @r   r   r   S       H Hr   r   c                   "     e Zd ZdZ fdZ xZS )DataCorruptionzError class for corrupt media transfers.

    Args:
        response (object): The HTTP response which caused the failure.
        args (tuple): The positional arguments typically passed to an
            exception class.
    c                 4    t        t        | 
  |  || _        y r   )r   r   r   r	   r
   s      r   r   zDataCorruption.__init__k   s    nd,d3 Gr   r   r   s   @r   r   r   b   r   r   r   c                   (    e Zd ZdZeddddfdZd Zy)RetryStrategyaK  Configuration class for retrying failed requests.

    At most one of ``max_cumulative_retry`` and ``max_retries`` can be
    specified (they are both caps on the total number of retries). If
    neither are specified, then ``max_cumulative_retry`` is set as
    :data:`MAX_CUMULATIVE_RETRY`.

    Args:
        max_sleep (Optional[float]): The maximum amount of time to sleep after
            a failed request. Default is :attr:`MAX_SLEEP`.
        max_cumulative_retry (Optional[float]): The maximum **total** amount of
            time to sleep during retry process.
        max_retries (Optional[int]): The number of retries to attempt.
        initial_delay (Optional[float]): The initial delay. Default 1.0 second.
        muiltiplier (Optional[float]): Exponent of the backoff. Default is 2.0.

    Attributes:
        max_sleep (float): Maximum amount of time allowed between requests.
        max_cumulative_retry (Optional[float]): Maximum total sleep time
            allowed during retry process.
        max_retries (Optional[int]): The number retries to attempt.
        initial_delay (Optional[float]): The initial delay. Default 1.0 second.
        muiltiplier (Optional[float]): Exponent of the backoff. Default is 2.0.

    Raises:
        ValueError: If both of ``max_cumulative_retry`` and ``max_retries``
            are passed.
    Ng      ?g       @c                     ||t        t              ||t        }|| _        || _        || _        || _        || _        y r   )
ValueError_SLEEP_RETRY_ERROR_MSGMAX_CUMULATIVE_RETRY	max_sleepmax_cumulative_retrymax_retriesinitial_delay
multiplier)r   r!   r"   r#   r$   r%   s         r   r   zRetryStrategy.__init__   sR      +0G344'K,?#7 "$8!&*$r   c                 V    | j                   || j                  k  S || j                   k  S )a  Check if another retry is allowed.

        Args:
            total_sleep (float): With another retry, the amount of sleep that
                will be accumulated by the caller.
            num_retries (int): With another retry, the number of retries that
                will be attempted by the caller.

        Returns:
            bool: Indicating if another retry is allowed (depending on either
            the cumulative sleep allowed or the maximum number of retries
            allowed.
        )r"   r#   )r   total_sleepnum_retriess      r   retry_allowedzRetryStrategy.retry_allowed   s2     $$,$"2"222$";";;;r   )r   r   r   r   	MAX_SLEEPr   r)    r   r   r   r   q   s"    > !%&<r   r   )r   http.clienthttpr   UPLOAD_CHUNK_SIZEclientPERMANENT_REDIRECTTOO_MANY_REQUESTSr*   r    REQUEST_TIMEOUTINTERNAL_SERVER_ERRORBAD_GATEWAYSERVICE_UNAVAILABLEGATEWAY_TIMEOUT	RETRYABLE	Exceptionr   r   objectr   r+   r   r   <module>r:      s   
  S    I[[33  KK11  	   	KK!!KKKK%%KKKK##KK	Hi HHY HB<F B<r   