§
    sŠtj  ã                   óH   — d Z ddlZdZg d¢Zd„ Zedfd„Zedfd„Zedfd„ZdS )	zTee function implementations.é    Ni   )ÚteeÚtee_to_fileÚtee_to_bytearrayc              #   óf   K  — | j                              ||¬¦  «        D ]} ||¦  «         |V — Œd S )N)ÚamtÚdecode_content)ÚrawÚstream)ÚresponseÚcallbackÚ	chunksizer   Úchunks        úa/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/requests_toolbelt/downloadutils/tee.pyÚ_teer   	   sU   è è € Ø”×$Ò$¨Ø4Bð %ñ Dô Dð ð ˆàˆ�‰ŒˆØˆˆˆˆðð ó    c                 ó¨   — dt          |dd¦  «        v s)t          |t          j        ¦  «        st	          d¦  «        ‚t          | |j        ||¦  «        S )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      s`   € ðP •7˜: v¨rÑ2Ô2Ð2Ð2Ý�z¥2¤:Ñ.Ô.ð 3åð 7ñ 8ô 8ð 	8õ �˜*Ô*¨I°~ÑFÔFÐFr   c              #   ó�   K  — t          |d¦  «        5 }t          | |||¦  «        D ]}|V — Œ	 ddd¦  «         dS # 1 swxY w Y   dS )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   s¦   è è € õ, 
ˆh˜Ñ	Ô	ð  Ý˜ 2 y°.ÑAÔAð 	ð 	ˆEØˆKˆKˆKˆKð	ðð ð ñ ô ð ð ð ð ð ð ð øøøð ð ð ð ð ð s   “;»?Á?c                 óx   — t          |t          ¦  «        st          d¦  «        ‚t          | |j        ||¦  «        S )ax  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   \   sC   € õ8 �g�yÑ)Ô)ð %Ýð $ñ %ô %ð 	%å�˜'œ.¨)°^ÑDÔDÐDr   )Ú__doc__r   Ú_DEFAULT_CHUNKSIZEÚ__all__r   r   r   r   © r   r   ú<module>r*      sŸ   ðØ #Ð #Ø 	€	€	€	àÐ à
4Ð
4Ð
4€ðð ð ð );Øð.Gð .Gð .Gð .Gðb /AØ#ðð ð ð ð6 3EØ$(ðEð Eð Eð Eð Eð Er   