ķ
^ęWc           @@  sĒ   d  d l  m Z d  d l Z d  d l m Z d  d l m Z d d l m Z d d l	 m
 Z
 d d l m Z e j d	  d
 Z d   Z d   Z d   Z d d  Z d S(   i    (   t   absolute_importN(   t   uuid4(   t   BytesIOi   (   t   six(   t   b(   t   RequestFields   utf-8i   c           C@  s
   t    j S(   sM   
    Our embarassingly-simple replacement for mimetools.choose_boundary.
    (   R   t   hex(    (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/filepost.pyt   choose_boundary   s    c         c@  sg   t  |  t  r! t j |   } n t |   } x3 | D]+ } t  | t  rQ | Vq4 t j |   Vq4 Wd S(   s   
    Iterate over fields.

    Supports list of (k, v) tuples and dicts, and lists of
    :class:`~urllib3.fields.RequestField`.

    N(   t
   isinstancet   dictR   t	   iteritemst   iterR   t   from_tuples(   t   fieldst   it   field(    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/filepost.pyt   iter_field_objects   s    c         C@  s4   t  |  t  r& d   t j |   D Sd   |  D S(   s-  
    .. deprecated:: 1.6

    Iterate over fields.

    The addition of :class:`~urllib3.fields.RequestField` makes this function
    obsolete. Instead, use :func:`iter_field_objects`, which returns
    :class:`~urllib3.fields.RequestField` objects.

    Supports list of (k, v) tuples and dicts.
    c         s@  s!   |  ] \ } } | | f Vq d  S(   N(    (   t   .0t   kt   v(    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/filepost.pys	   <genexpr>6   s    c         s@  s!   |  ] \ } } | | f Vq d  S(   N(    (   R   R   R   (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/filepost.pys	   <genexpr>8   s    (   R   R	   R   R
   (   R   (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/filepost.pyt   iter_fields)   s    c         C@  s  t    } | d k r! t   } n  x­ t |   D] } | j t d |   t |  j | j    | j } t	 | t
  r t |  } n  t	 | t j  rŗ t |  j |  n | j |  | j d  q. W| j t d |   t d |  } | j   | f S(   sJ  
    Encode a dictionary of ``fields`` using the multipart/form-data MIME format.

    :param fields:
        Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).

    :param boundary:
        If not specified, then a random boundary will be generated using
        :func:`mimetools.choose_boundary`.
    s   --%s
s   
s   --%s--
s    multipart/form-data; boundary=%sN(   R   t   NoneR   R   t   writeR   t   writert   render_headerst   dataR   t   intt   strR   t	   text_typet   getvalue(   R   t   boundaryt   bodyR   R   t   content_type(    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/filepost.pyt   encode_multipart_formdata;   s     		(   t
   __future__R    t   codecst   uuidR   t   ioR   t   packagesR   t   packages.sixR   R   R   t   lookupR   R   R   R   R   R!   (    (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/filepost.pyt   <module>   s   			