σ
^κWc           @@  sg   d  d l  m Z d  d l Z d  d l Z d d l m Z d d  Z d   Z d e	 f d	     YZ
 d S(
   i    (   t   absolute_importNi   (   t   sixs   application/octet-streamc         C@  s!   |  r t  j |   d p | S| S(   sζ   
    Guess the "Content-Type" of a file.

    :param filename:
        The filename to guess the "Content-Type" of using :mod:`mimetypes`.
    :param default:
        If no "Content-Type" can be guessed, default to `default`.
    i    (   t	   mimetypest
   guess_type(   t   filenamet   default(    (    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyt   guess_content_type   s    	c         @  s΅   t    f d   d D  s^ d |    f } y | j d  Wn t t f k
 rV q^ X| Sn  t j r t   t j  r   j d    n  t j	 j
   d    d |    f     S(   s   
    Helper function to format and quote a single header parameter.

    Particularly useful for header parameters which might contain
    non-ASCII values, like file names. This follows RFC 2231, as
    suggested by RFC 2388 Section 4.4.

    :param name:
        The name of the parameter, a string expected to be ASCII only.
    :param value:
        The value of the parameter, provided as a unicode string.
    c         3@  s   |  ] } |   k Vq d  S(   N(    (   t   .0t   ch(   t   value(    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pys	   <genexpr>#   s    s   "\
s   %s="%s"t   asciis   utf-8s   %s*=%s(   t   anyt   encodet   UnicodeEncodeErrort   UnicodeDecodeErrorR   t   PY3t
   isinstancet	   text_typet   emailt   utilst   encode_rfc2231(   t   nameR	   t   result(    (   R	   s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyt   format_header_param   s    t   RequestFieldc           B@  sY   e  Z d  Z d d d  Z e d    Z d   Z d   Z d   Z	 d d d d  Z
 RS(   sK  
    A data container for request body parameters.

    :param name:
        The name of this request field.
    :param data:
        The data/value body.
    :param filename:
        An optional filename of the request field.
    :param headers:
        An optional dict-like object of headers to initially use for the field.
    c         C@  s@   | |  _  | |  _ | |  _ i  |  _ | r< t |  |  _ n  d  S(   N(   t   _namet	   _filenamet   datat   headerst   dict(   t   selfR   R   R   R   (    (    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyt   __init__?   s    				c         C@  s   t  | t  rN t |  d k r3 | \ } } } q` | \ } } t |  } n d } d } | } |  | | d | } | j d |  | S(   s³  
        A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.

        Supports constructing :class:`~urllib3.fields.RequestField` from
        parameter of key/value strings AND key/filetuple. A filetuple is a
        (filename, data, MIME type) tuple where the MIME type is optional.
        For example::

            'foo': 'bar',
            'fakefile': ('foofile.txt', 'contents of foofile'),
            'realfile': ('barfile.txt', open('realfile').read()),
            'typedfile': ('bazfile.bin', open('bazfile').read(), 'image/jpeg'),
            'nonamefile': 'contents of nonamefile field',

        Field names and filenames must be unicode.
        i   R   t   content_typeN(   R   t   tuplet   lenR   t   Nonet   make_multipart(   t   clst	   fieldnameR	   R   R   R    t   request_param(    (    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyt   from_tuplesG   s    c         C@  s   t  | |  S(   s  
        Overridable helper function to format a single header parameter.

        :param name:
            The name of the parameter, a string expected to be ASCII only.
        :param value:
            The value of the parameter, provided as a unicode string.
        (   R   (   R   R   R	   (    (    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyt   _render_parti   s    	c         C@  sp   g  } | } t  | t  r* | j   } n  x6 | D]. \ } } | r1 | j |  j | |   q1 q1 Wd j |  S(   sO  
        Helper function to format and quote a single header.

        Useful for single headers that are composed of multiple items. E.g.,
        'Content-Disposition' fields.

        :param header_parts:
            A sequence of (k, v) typles or a :class:`dict` of (k, v) to format
            as `k1="v1"; k2="v2"; ...`.
        s   ; (   R   R   t   itemst   appendR)   t   join(   R   t   header_partst   partst   iterableR   R	   (    (    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyt   _render_partst   s     c         C@  sΕ   g  } d d d g } xD | D]< } |  j  j | t  r | j d | |  j  | f  q q WxL |  j  j   D]; \ } } | | k rl | r§ | j d | | f  q§ ql ql W| j d  d j |  S(   s=   
        Renders the headers for this request field.
        s   Content-Dispositions   Content-Types   Content-Locations   %s: %ss   
(   R   t   gett   FalseR+   R*   R,   (   R   t   linest	   sort_keyst   sort_keyt   header_namet   header_value(    (    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyt   render_headers   s    %!c      	   C@  st   | p	 d |  j  d <|  j  d c d j d |  j d |  j f d |  j f f  g  7<| |  j  d <| |  j  d <d	 S(
   s|  
        Makes this request field into a multipart request field.

        This method overrides "Content-Disposition", "Content-Type" and
        "Content-Location" headers to the request parameter.

        :param content_type:
            The 'Content-Type' of the request body.
        :param content_location:
            The 'Content-Location' of the request body.

        s	   form-datas   Content-Dispositions   ; t    R   R   s   Content-Types   Content-LocationN(   R   R,   R0   R   R   (   R   t   content_dispositionR    t   content_location(    (    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyR$      s    	'N(   t   __name__t
   __module__t   __doc__R#   R   t   classmethodR(   R)   R0   R8   R$   (    (    (    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyR   2   s   "			(   t
   __future__R    t   email.utilsR   R   t   packagesR   R   R   t   objectR   (    (    (    s}   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/fields.pyt   <module>   s   	