ó
    úÞ j  ã                   óL   • S r SSKrSr/ SQrS r\S4S jr\S4S jr\S4S jrg)	zTee function implementations.é    Ni   )ÚteeÚtee_to_fileÚtee_to_bytearrayc              #   óf   #   • U R                   R                  UUS9 H  nU" U5        Uv •  M     g 7f)N)ÚamtÚdecode_content)ÚrawÚstream)ÚresponseÚcallbackÚ	chunksizer   Úchunks        Ú]/var/www/html/gaurav/venv/lib/python3.13/site-packages/requests_toolbelt/downloadutils/tee.pyÚ_teer   	   s6   é € Ø—‘×$Ñ$¨Ø4Bð %ó Dˆá�ŒØŒòDùs   ‚/1c                 ó¤   • S[        USS5      ;   d*  [        U[        R                  5      (       d  [	        S5      e[        XR                  X#5      $ )aÂ  Stream the response both to the generator and a file.

This will stream the response body while writing the bytes to
``fileobject``.

Example usage:

.. code-block:: python

    resp = requests.get(url, stream=True)
    with open('save_file', 'wb') as save_file:
        for chunk in tee(resp, save_file):
            # do stuff with chunk

.. code-block:: python

    import io

    resp = requests.get(url, stream=True)
    fileobject = io.BytesIO()

    for chunk in tee(resp, fileobject):
        # do stuff with chunk

:param response: Response from requests.
:type response: requests.Response
:param fileobject: Writable file-like object.
:type fileobject: file, io.BytesIO
:param int chunksize: (optional), Size of chunk to attempt to stream.
:param bool decode_content: (optional), If True, this will decode the
    compressed content of the response.
:raises: TypeError if the fileobject wasn't opened with the right mode
    or isn't a BytesIO object.
ÚbÚmodeÚ zƒtee() will write bytes directly to this fileobject, it must be opened with the "b" flag if it is a file or inherit from io.BytesIO.)ÚgetattrÚ
isinstanceÚioÚBytesIOÚ	TypeErrorr   Úwrite)r   Ú
fileobjectr   r   s       r   r   r      sN   € ðP ”7˜: v¨rÓ2Ó2Ü�z¤2§:¡:×.Ñ.Üð 7ó 8ð 	8ô �×*Ñ*¨IÓFÐFó    c              #   ó†   #   • [        US5       n[        XX#5       H  nUv •  M	     SSS5        g! , (       d  f       g= f7f)aœ  Stream the response both to the generator and a file.

This will open a file named ``filename`` and stream the response body
while writing the bytes to the opened file object.

Example usage:

.. code-block:: python

    resp = requests.get(url, stream=True)
    for chunk in tee_to_file(resp, 'save_file'):
        # do stuff with chunk

:param response: Response from requests.
:type response: requests.Response
:param str filename: Name of file in which we write the response content.
:param int chunksize: (optional), Size of chunk to attempt to stream.
:param bool decode_content: (optional), If True, this will decode the
    compressed content of the response.
ÚwbN)Úopenr   )r   Úfilenamer   r   Úfdr   s         r   r   r   A   s5   é € ô, 
ˆh˜Ô	 Ü˜ yÖAˆEØŒKñ B÷ 
×	Ö	üs   ‚A�0§	A°
>ºAc                 ón   • [        U[        5      (       d  [        S5      e[        XR                  X#5      $ )a0  Stream the response both to the generator and a bytearray.

This will stream the response provided to the function, add them to the
provided :class:`bytearray` and yield them to the user.

.. note::

    This uses the :meth:`bytearray.extend` by default instead of passing
    the bytearray into the ``readinto`` method.

Example usage:

.. code-block:: python

    b = bytearray()
    resp = requests.get(url, stream=True)
    for chunk in tee_to_bytearray(resp, b):
        # do stuff with chunk

:param response: Response from requests.
:type response: requests.Response
:param bytearray bytearr: Array to add the streamed bytes to.
:param int chunksize: (optional), Size of chunk to attempt to stream.
:param bool decode_content: (optional), If True, this will decode the
    compressed content of the response.
z4tee_to_bytearray() expects bytearr to be a bytearray)r   Ú	bytearrayr   r   Úextend)r   Úbytearrr   r   s       r   r   r   \   s4   € ô8 �gœy×)Ñ)Üð $ó %ð 	%ä�Ÿ.™.¨)ÓDÐDr   )Ú__doc__r   Ú_DEFAULT_CHUNKSIZEÚ__all__r   r   r   r   © r   r   Ú<module>r*      sG   ðÙ #Û 	àÐ â
4€òð );Øô.Gðb /AØ#ôð6 3EØ$(õEr   