404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.119.119.119: ~ $
3

�P\��@s�dZddlZddlZddlmZddlmZdd�ZGdd	�d	e	�Z
Gd
d�de	�Zdd
�ZGdd�de
�ZGdd�de
�ZdS)z�

requests_toolbelt.multipart.decoder
===================================

This holds all the implementation details of the MultipartDecoder

�N�)�encode_with)�CaseInsensitiveDictcCs*|j|�}|d|�||t|�d�fS)N)�find�len)�contentZboundZpoint�r�/usr/lib/python3.6/decoder.py�_split_on_finds
r
c@seZdZdS)� ImproperBodyPartContentExceptionN)�__name__�
__module__�__qualname__rrrr	rsrc@seZdZdS)� NonMultipartContentTypeExceptionN)rr
rrrrr	rsrcsBtjd}|dkr|j��}tjj�j|�j�}�fdd�|D�S)Nr�c3s&|]\}}t|��t|��fVqdS)N)r)�.0�k�v)�encodingrr	�	<genexpr>$sz!_header_parser.<locals>.<genexpr>)�sys�version_info�decode�email�parserZHeaderParserZparsestr�items)�stringr�major�headersr)rr	�_header_parsers


rc@s$eZdZdZdd�Zedd��ZdS)�BodyParta�

    The ``BodyPart`` object is a ``Response``-like interface to an individual
    subpart of a multipart response. It is expected that these will
    generally be created by objects of the ``MultipartDecoder`` class.

    Like ``Response``, there is a ``CaseInsensitiveDict`` object named headers,
    ``content`` to access bytes, ``text`` to access unicode, and ``encoding``
    to access the unicode codec.

    cCsP||_i}d|kr:t|d�\}|_|dkrBt|j�|�}ntd��t|�|_dS)Ns

�z$content does not contain CR-LF-CR-LF)rr
rr�lstriprrr)�selfrrr�firstrrr	�__init__6szBodyPart.__init__cCs|jj|j�S)z'Content of the ``BodyPart`` in unicode.)rrr)r#rrr	�textDsz
BodyPart.textN)rr
r�__doc__r%�propertyr&rrrr	r )sr c@sDeZdZdZddd�Zdd�Zedd��Zd	d
�Ze	ddd��Z
d
S)�MultipartDecoderai

    The ``MultipartDecoder`` object parses the multipart payload of
    a bytestring into a tuple of ``Response``-like ``BodyPart`` objects.

    The basic usage is::

        import requests
        from requests_toolbelt import MultipartDecoder

        response = request.get(url)
        decoder = MultipartDecoder.from_response(response)
        for part in decoder.parts:
            print(part.headers['content-type'])

    If the multipart content is not from a response, basic usage is::

        from requests_toolbelt import MultipartDecoder

        decoder = MultipartDecoder(content, content_type)
        for part in decoder.parts:
            print(part.headers['content-type'])

    For both these usages, there is an optional ``encoding`` parameter. This is
    a string, which is the name of the unicode codec to use (default is
    ``'utf-8'``).

    �utf-8cCs*||_||_t�|_|j�|j|�dS)N)�content_typer�tuple�parts�_find_boundary�_parse_body)r#rr+rrrr	r%gs
zMultipartDecoder.__init__cCs�tdd�|jjd�D��}|d}|jd�dj�dkrFtdj|���xB|dd�D]2}t|d	�\}}|j�d
krTt|jd�|j	�|_
qTWdS)Ncss|]}|j�VqdS)N)�strip)r�xrrr	rrsz2MultipartDecoder._find_boundary.<locals>.<genexpr>�;r�/Z	multipartz*Unexpected mimetype in content-type: '{0}'r�=�boundary�")r,r+�split�lowerr�formatr
rr0rr5)r#Zct_infoZmimetype�item�attr�valuerrr	r.qs
zMultipartDecoder._find_boundarycCs,t|�}||d|�kr$||d�S|SdS)N)r)�partZboundary_markerZbm_lenrrr	�_fix_first_part�sz MultipartDecoder._fix_first_partcsXdjd�jf����fdd��dd��|jdjd�f��}t��fdd	�|D���_dS)
Nr!s--cstj|��}t|�j�S)N)r)r>r r)r=Zfixed)r5r#rr	�	body_part�sz/MultipartDecoder._parse_body.<locals>.body_partcSs(|dko&|dko&|dd�dko&|dkS)Nr!s
�s--
s--r)r=rrr	�	test_part�sz/MultipartDecoder._parse_body.<locals>.test_parts
c3s|]}�|�r�|�VqdS)Nr)rr1)r?rArr	r�sz/MultipartDecoder._parse_body.<locals>.<genexpr>)�joinr5r7r,r-)r#rr-r)r?r5r#rAr	r/�s
zMultipartDecoder._parse_bodycCs |j}|jjdd�}||||�S)Nzcontent-type)rr�get)�clsZresponserrr+rrr	�
from_response�szMultipartDecoder.from_responseN)r*)r*)rr
rr'r%r.�staticmethodr>r/�classmethodrErrrr	r)Js

r))r'rZemail.parserr�encoderrZrequests.structuresrr
�	Exceptionrrr�objectr r)rrrr	�<module>	s!

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 859 B 0644
__init__.cpython-36.pyc File 859 B 0644
decoder.cpython-36.opt-1.pyc File 5.54 KB 0644
decoder.cpython-36.pyc File 5.54 KB 0644
encoder.cpython-36.opt-1.pyc File 20.38 KB 0644
encoder.cpython-36.pyc File 20.38 KB 0644