Viewing File: /opt/alt/python35/lib/python3.5/site-packages/urllib3/__pycache__/filepost.cpython-35.opt-1.pyc
R/oV ã @ 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 d „ Z d
d „ Z d d „ Z d d d „ Z d S)é )Úabsolute_importN)Úuuid4)ÚBytesIOé )Úsix)Úb)ÚRequestFieldzutf-8é c C s
t ƒ j S)zM
Our embarassingly-simple replacement for mimetools.choose_boundary.
)r Úhex© r r ú/filepost.pyÚchoose_boundary s r
c c sg t | t ƒ r! t j | ƒ } n t | ƒ } x3 | D]+ } t | t ƒ rQ | Vq4 t j | Œ Vq4 Wd S)z†
Iterate over fields.
Supports list of (k, v) tuples and dicts, and lists of
:class:`~urllib3.fields.RequestField`.
N)Ú
isinstanceÚdictr Ú iteritemsÚiterr Zfrom_tuples)ÚfieldsÚiÚfieldr r r Úiter_field_objects s
r c C s: t | t ƒ r) d d „ t j | ƒ Dƒ Sd d „ | Dƒ S)a-
.. 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 Vq d S)Nr )Ú.0ÚkÚvr r r ú <genexpr>6 s ziter_fields.<locals>.<genexpr>c s s! | ] \ } } | | f Vq d S)Nr )r r r r r r r 8 s )r r r r )r r r r Úiter_fields) s r c C s t ƒ } | d k r t ƒ } xª t | ƒ D]œ } | j t d | ƒ ƒ t | ƒ j | j ƒ ƒ | j } t | t ƒ r… t
| ƒ } t | t j ƒ r t | ƒ j | ƒ n
| j | ƒ | j d ƒ q+ W| j t d | ƒ ƒ t
d | ƒ } | j
ƒ | f S)aJ
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`.
Nz--%s
s
z--%s--
z multipart/form-data; boundary=%s)r r
r Úwriter ÚwriterZrender_headersÚdatar ÚintÚstrr Z text_typeÚgetvalue)r ÚboundaryZbodyr r Zcontent_typer r r Úencode_multipart_formdata; s
r"