HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/requests_toolbelt/downloadutils/tee.pyc
ó
Óµ Yc@sadZddlZdZdddgZd„Zedd„Zedd	„Zedd
„ZdS(sTee function implementations.iÿÿÿÿNitteettee_to_filettee_to_bytearrayccs9x2|jjd|d|ƒD]}||ƒ|VqWdS(Ntamttdecode_content(trawtstream(tresponsetcallbackt	chunksizeRtchunk((sG/usr/lib/python2.7/site-packages/requests_toolbelt/downloadutils/tee.pyt_tee	s

cCsOdt|ddƒkp't|tjƒs9tdƒ‚nt||j||ƒS(s"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.
    tbtmodetsƒ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.(tgetattrt
isinstancetiotBytesIOt	TypeErrorRtwrite(Rt
fileobjectR	R((sG/usr/lib/python2.7/site-packages/requests_toolbelt/downloadutils/tee.pyRs(c	csAt|dƒ,}x"t||||ƒD]}|Vq(WWdQXdS(sÔ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.
    twbN(topenR(RtfilenameR	RtfdR
((sG/usr/lib/python2.7/site-packages/requests_toolbelt/downloadutils/tee.pyRAscCs4t|tƒstdƒ‚nt||j||ƒS(sxStream 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.
    s4tee_to_bytearray() expects bytearr to be a bytearray(Rt	bytearrayRRtextend(RtbytearrR	R((sG/usr/lib/python2.7/site-packages/requests_toolbelt/downloadutils/tee.pyR\s(	t__doc__Rt_DEFAULT_CHUNKSIZEt__all__RtNoneRRR(((sG/usr/lib/python2.7/site-packages/requests_toolbelt/downloadutils/tee.pyt<module>s	0