Ë
    T¼Sfã  ã                   óJ  — d Z ddlZddlZddlZddlZddlm	Z	 ddlm
Z
  e	j                  «       ZdZdZdZej                   j"                  ej                   j$                  ej                   j&                  ej(                  j*                  ej(                  j,                  ej(                  j.                  ej(                  j0                  ej(                  j2                  ej(                  j4                  ej(                  j6                  efZ G d„ d	e«      Z G d
„ de«      Zd„ Z y)z}Shared utilities used by both downloads and uploads.

This utilities are explicitly catered to ``requests``-like transports.
é    N)Úcommon)Ú_helpersi    é=   é<   c                   ó@   — e Zd ZdZed„ «       Zed„ «       Zed„ «       Zy)ÚRequestsMixinz¼Mix-in class implementing ``requests``-specific behavior.

    These are methods that are more general purpose, with implementations
    specific to the types defined in ``requests``.
    c                 ó   — | j                   S )z¾Access the status code from an HTTP response.

        Args:
            response (~requests.Response): The HTTP response object.

        Returns:
            int: The status code.
        )Ústatus_code©Úresponses    úoC:\Users\user\Documents\project_loop\venv\Lib\site-packages\google/resumable_media/requests/_request_helpers.pyÚ_get_status_codezRequestsMixin._get_status_code<   s   € ð ×#Ñ#Ð#ó    c                 ó   — | j                   S )a
  Access the headers from an HTTP response.

        Args:
            response (~requests.Response): The HTTP response object.

        Returns:
            ~requests.structures.CaseInsensitiveDict: The header mapping (keys
            are case-insensitive).
        )Úheadersr   s    r   Ú_get_headerszRequestsMixin._get_headersH   s   € ð ×ÑÐr   c                 ó   — | j                   S )úÏAccess the response body from an HTTP response.

        Args:
            response (~requests.Response): The HTTP response object.

        Returns:
            bytes: The body of the ``response``.
        )Úcontentr   s    r   Ú	_get_bodyzRequestsMixin._get_bodyU   s   € ð ×ÑÐr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústaticmethodr   r   r   © r   r   r   r   5   sC   „ ñð ñ	$ó ð	$ð ñ
 ó ð
 ð ñ	 ó ñ	 r   r   c                   ó   — e Zd Zed„ «       Zy)ÚRawRequestsMixinc                 ó®   — | j                   du r<dj                  | j                  j                  t        d¬«      «      | _         d| _        | j                   S )r   Fr   )Údecode_contentT)Ú_contentÚjoinÚrawÚstreamÚ_SINGLE_GET_CHUNK_SIZEÚ_content_consumedr   s    r   r   zRawRequestsMixin._get_bodyc   sQ   € ð ×Ñ Ñ%Ø #§¡Ø—‘×#Ñ#Ô$:È5Ð#ÓQó!ˆHÔð *.ˆHÔ&Ø× Ñ Ð r   N)r   r   r   r   r   r   r   r   r   r   b   s   „ Øñ!ó ñ!r   r   c                 óÞ  — d}d}t        |j                  «      |j                  z  }	 d}	  | «       }|S # t        $ r}|}Y d}~nId}~wt        j
                  $ r0} ||j                  «      t        j                  v r|}n‚ Y d}~nd}~ww xY wt        j                  ||j                  |j                  «      \  }}	|dz  }||	z  }|j                  ||«      s|‚t        j                  |	«       ŒÇ)a.  Attempts to retry a call to ``func`` until success.

    Expects ``func`` to return an HTTP response and uses ``get_status_code``
    to check if the response is retry-able.

    ``func`` is expected to raise a failure status code as a
    common.InvalidResponse, at which point this method will check the code
    against the common.RETRIABLE list of retriable status codes.

    Will retry until :meth:`~.RetryStrategy.retry_allowed` (on the current
    ``retry_strategy``) returns :data:`False`. Uses
    :func:`_helpers.calculate_retry_wait` to double the wait time (with jitter)
    after each attempt.

    Args:
        func (Callable): A callable that takes no arguments and produces
            an HTTP response which will be checked as retry-able.
        get_status_code (Callable[Any, int]): Helper to get a status code
            from a response.
        retry_strategy (~google.resumable_media.common.RetryStrategy): The
            strategy to use if the request fails and must be retried.

    Returns:
        object: The return value of ``func``.
    g        r   Né   )ÚfloatÚinitial_delayÚ
multiplierÚ_CONNECTION_ERROR_CLASSESr   ÚInvalidResponser   Ú	RETRYABLEr   Úcalculate_retry_waitÚ	max_sleepÚretry_allowedÚtimeÚsleep)
ÚfuncÚget_status_codeÚretry_strategyÚtotal_sleepÚnum_retriesÚ	base_waitÚerrorr   ÚeÚ	wait_times
             r   Úwait_and_retryr=   u   sú   € ð4 €KØ€Kä�n×2Ñ2Ó3°n×6OÑ6OÑO€Ið Øˆð	Ù“vˆHð ˆOøô )ò 	Ø�EûÜ×%Ñ%ò 	ñ ˜qŸz™zÓ*¬f×.>Ñ.>Ñ>Ø‘àô ûð	úô  (×<Ñ<Ø�~×/Ñ/°×1JÑ1Jó 
Ñˆ	�9ð 	�qÑˆØ�yÑ ˆð ×+Ñ+¨K¸ÔEØˆKä�
‰
�9Ôð9 s    «4 ´	B
½AÁB
Á&BÂB
)!r   Úhttp.clientÚhttpÚrequests.exceptionsÚrequestsÚurllib3.exceptionsÚurllib3r2   Úgoogle.resumable_mediar   r   ÚRetryStrategyÚ_DEFAULT_RETRY_STRATEGYr%   Ú_DEFAULT_CONNECT_TIMEOUTÚ_DEFAULT_READ_TIMEOUTÚclientÚBadStatusLineÚIncompleteReadÚResponseNotReadyÚ
exceptionsÚConnectionErrorÚChunkedEncodingErrorÚTimeoutÚ	PoolErrorÚProtocolErrorÚSSLErrorÚTimeoutErrorr,   Úobjectr   r   r=   r   r   r   ú<module>rV      sþ   ðñó
 Û Û ã å )Ý +à.˜&×.Ñ.Ó0Ð ØÐ ð Ð àÐ ð 	‡K�K×ÑØ‡K�K×ÑØ‡K�K× Ñ Ø×Ñ×'Ñ'Ø×Ñ×,Ñ,Ø×Ñ×ÑØ×Ñ× Ñ Ø×Ñ×$Ñ$Ø×Ñ×ÑØ×Ñ×#Ñ#ØðÐ ô* �Fô * ôZ!�}ô !ó&?r   