ó gP¾[c@s¢ddlZddlZddlmZddlmZddlZddlmZddlm Z ej dƒdZ d „Z d „Z d „Zdd „ZdS( i’’’’N(tuuid4(tBytesIO(tbi(t RequestFieldsutf-8icCs tƒjS(sM Our embarassingly-simple replacement for mimetools.choose_boundary. (Rthex(((s4/usr/lib/python2.7/dist-packages/urllib3/filepost.pytchoose_boundarysccsgt|tƒr!tj|ƒ}n t|ƒ}x3|D]+}t|tƒrQ|Vq4tj|ŒVq4WdS(s† Iterate over fields. Supports list of (k, v) tuples and dicts, and lists of :class:`~urllib3.fields.RequestField`. N(t isinstancetdicttsixt iteritemstiterRt from_tuples(tfieldstitfield((s4/usr/lib/python2.7/dist-packages/urllib3/filepost.pytiter_field_objectss  cCs4t|tƒr&d„tj|ƒDƒSd„|DƒS(s, Iterate over fields. .. deprecated :: The addition of `~urllib3.fields.RequestField` makes this function obsolete. Instead, use :func:`iter_field_objects`, which returns `~urllib3.fields.RequestField` objects, instead. Supports list of (k, v) tuples and dicts. css!|]\}}||fVqdS(N((t.0tktv((s4/usr/lib/python2.7/dist-packages/urllib3/filepost.pys =scss!|]\}}||fVqdS(N((RRR((s4/usr/lib/python2.7/dist-packages/urllib3/filepost.pys ?s(RRRR (R ((s4/usr/lib/python2.7/dist-packages/urllib3/filepost.pyt iter_fields/s cCstƒ}|dkr!tƒ}nx­t|ƒD]Ÿ}|jtd|ƒƒt|ƒj|jƒƒ|j}t |t ƒr‹t |ƒ}nt |t j ƒr³t|ƒj|ƒn |j|ƒ|jdƒq.W|jtd|ƒƒt d|ƒ}|jƒ|fS(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(RtNoneRRtwriteRtwritertrender_headerstdataRtinttstrRt text_typetgetvalue(R tboundarytbodyRRt content_type((s4/usr/lib/python2.7/dist-packages/urllib3/filepost.pytencode_multipart_formdataBs     (tcodecst mimetypestuuidRtioRRRR RtlookupRRRRRR (((s4/usr/lib/python2.7/dist-packages/urllib3/filepost.pyts