Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips
System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : fdshops ( 1003)
PHP Version : 8.2.21
Disable Function : NONE
Directory :  /lib/python2.7/site-packages/requests_toolbelt/downloadutils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python2.7/site-packages/requests_toolbelt/downloadutils/stream.pyc
�
ӵ Yc@s�dZddlZddlZddlZddlmZdZej	deef�Z
dZd�Zd	�Z
ded
�ZdS(s-Utilities for dealing with streamed requests.i����Ni(t
exceptionss"[^"\\]*(?:\\.[^"\\]*)*"s*;\s*(%s|[^\s;=]+)\s*(?:=\s*(%s|[^;]+))?\s*icCsPxItj|�D]8}|j�\}}|dkrtjj|�dSqWdS(Ntfilenamei(t_OPTION_HEADER_PIECE_REtfinditertgroupstostpathtsplittNone(tcontent_dispositiontmatchtktv((sJ/usr/lib/python2.7/site-packages/requests_toolbelt/downloadutils/stream.pyt
_get_filenames
cCs�|otjj|�}|r.|r.|}nWt|jjdd��}|satjd��n|rtjj||�}n|}|S(s�
    Given a response and a path, return a file path for a download.

    If a ``path`` parameter is a directory, this function will parse the
    ``Content-Disposition`` header on the response to determine the name of the
    file as reported by the server, and return a file path in the specified
    directory.

    If ``path`` is empty or None, this function will return a path relative
    to the process' current working directory.

    If path is a full file path, return it.

    :param response: A Response object from requests
    :type response: requests.models.Response
    :param str path: Directory or file path.
    :returns: full file path to download as
    :rtype: str
    :raises: :class:`requests_toolbelt.exceptions.StreamingError`
    scontent-dispositionts'No filename given to stream response to(	RRtisdirR
theaderstgettexctStreamingErrortjoin(tresponseRtpath_is_dirtfilepathtresponse_filename((sJ/usr/lib/python2.7/site-packages/requests_toolbelt/downloadutils/stream.pytget_download_file_paths
	cCs�t}d}d}|rWtt|dd�tj�rWt}|}t|dd�}nFt||�}tj	j
|�r�tjd|��nt
|d�}x'|jd|�D]}|j|�q�W|s�|j�n|S(s7Stream a response body to the specified file.

    Either use the ``path`` provided or use the name provided in the
    ``Content-Disposition`` header.

    .. warning::

        If you pass this function an open file-like object as the ``path``
        parameter, the function will not close that file for you.

    .. warning::

        This function will not automatically close the response object
        passed in as the ``response`` parameter.

    If a ``path`` parameter is a directory, this function will parse the
    ``Content-Disposition`` header on the response to determine the name of the
    file as reported by the server, and return a file path in the specified
    directory. If no ``path`` parameter is supplied, this function will default
    to the process' current working directory.

    .. code-block:: python

        import requests
        from requests_toolbelt import exceptions
        from requests_toolbelt.downloadutils import stream

        r = requests.get(url, stream=True)
        try:
            filename = stream.stream_response_to_file(r)
        except exceptions.StreamingError as e:
            # The toolbelt could not find the filename in the
            # Content-Disposition
            print(e.message)

    You can also specify the filename as a string. This will be passed to
    the built-in :func:`open` and we will read the content into the file.

    .. code-block:: python

        import requests
        from requests_toolbelt.downloadutils import stream

        r = requests.get(url, stream=True)
        filename = stream.stream_response_to_file(r, path='myfile')

    If the calculated download file path already exists, this function will
    raise a StreamingError.

    Instead, if you want to manage the file object yourself, you need to
    provide either a :class:`io.BytesIO` object or a file opened with the
    `'b'` flag. See the two examples below for more details.

    .. code-block:: python

        import requests
        from requests_toolbelt.downloadutils import stream

        with open('myfile', 'wb') as fd:
            r = requests.get(url, stream=True)
            filename = stream.stream_response_to_file(r, path=fd)

        print('{0} saved to {1}'.format(url, filename))

    .. code-block:: python

        import io
        import requests
        from requests_toolbelt.downloadutils import stream

        b = io.BytesIO()
        r = requests.get(url, stream=True)
        filename = stream.stream_response_to_file(r, path=b)
        assert filename is None

    :param response: A Response object from requests
    :type response: requests.models.Response
    :param path: *(optional)*, Either a string with the path to the location
        to save the response content, or a file-like object expecting bytes.
    :type path: :class:`str`, or object with a :meth:`write`
    :param int chunksize: (optional), Size of chunk to attempt to stream
        (default 512B).
    :returns: The name of the file, if one can be determined, else None
    :rtype: str
    :raises: :class:`requests_toolbelt.exceptions.StreamingError`
    twritetnamesFile already exists: %stwbt
chunk_sizeN(tFalseRt
isinstancetgetattrtcollectionstCallabletTrueRRRtexistsRRtopentiter_contentRtclose(RRt	chunksizet
pre_openedtfdRtchunk((sJ/usr/lib/python2.7/site-packages/requests_toolbelt/downloadutils/stream.pytstream_response_to_fileGs W$
(t__doc__R!tos.pathRtreRRRt_QUOTED_STRING_REtcompileRt_DEFAULT_CHUNKSIZER
RRR,(((sJ/usr/lib/python2.7/site-packages/requests_toolbelt/downloadutils/stream.pyt<module>s
			+

Spamworldpro Mini