Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pyc

σ
“tΖ_c@@sΖddlmZddlZddlZddlZddlmZdd„Zd„Z	idd	6d
d6d
d6Z
e
jd„eddƒDƒƒd„Z
d„ZeZdefd„ƒYZdS(i(tabsolute_importNi(tsixsapplication/octet-streamcC@s!|rtj|ƒdp|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(tfilenametdefault((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pytguess_content_type	s	c@sαtˆtjƒr$ˆjdƒ‰nt‡fd†dDƒƒs‚d|ˆf}y|jdƒWnttfk
rzq‚X|Sntjrˆjdƒ‰nt	j
jˆdƒ‰d|ˆf‰tjr݈jdƒ‰nˆS(sθ
    Helper function to format and quote a single header parameter using the
    strategy defined in RFC 2231.

    Particularly useful for header parameters which might contain
    non-ASCII values, like file names. This follows 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 ``bytes`` or `str``.
    :ret:
        An RFC-2231-formatted unicode string.
    sutf-8c3@s|]}|ˆkVqdS(N((t.0tch(tvalue(sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pys	<genexpr>)ss"\
u%s="%s"tasciis%s*=%s(t
isinstanceRtbinary_typetdecodetanytencodetUnicodeEncodeErrortUnicodeDecodeErrortPY2temailtutilstencode_rfc2231(tnameR	tresult((R	sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pytformat_header_param_rfc2231s 		u%22u"u\\u\cC@s7i|]-}|dkrdj|ƒtj|ƒ“qS(iu%{:02X}(i(tformatRtunichr(Rtcc((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pys
<dictcomp>Js	ic@s_‡fd†}tjdjgˆjƒD]}tj|ƒ^q(ƒƒ}|j||ƒ}|S(Nc@sˆ|jdƒS(Ni(tgroup(tmatch(tneedles_and_replacements(sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pytreplacerRst|(tretcompiletjointkeystescapetsub(R	RRtneedletpatternR((RsK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pyt_replace_multipleQs
4cC@sAt|tjƒr$|jdƒ}nt|tƒ}d||fS(s±
    Helper function to format and quote a single header parameter using the
    HTML5 strategy.

    Particularly useful for header parameters which might contain
    non-ASCII values, like file names. This follows the `HTML5 Working Draft
    Section 4.10.22.7`_ and matches the behavior of curl and modern browsers.

    .. _HTML5 Working Draft Section 4.10.22.7:
        https://w3c.github.io/html/sec-forms.html#multipart-form-data

    :param name:
        The name of the parameter, a string expected to be ASCII only.
    :param value:
        The value of the parameter, provided as ``bytes`` or `str``.
    :ret:
        A unicode string, stripped of troublesome characters.
    sutf-8u%s="%s"(RRRR
R)t_HTML5_REPLACEMENTS(RR	((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pytformat_header_param_html5^stRequestFieldcB@s_eZdZdded„Zeed„ƒZd„Zd„Z	d„Z
dddd„ZRS(s
    A data container for request body parameters.

    :param name:
        The name of this request field. Must be unicode.
    :param data:
        The data/value body.
    :param filename:
        An optional filename of the request field. Must be unicode.
    :param headers:
        An optional dict-like object of headers to initially use for the field.
    :param header_formatter:
        An optional callable that is used to encode and format the headers. By
        default, this is :func:`format_header_param_html5`.
    cC@sI||_||_||_i|_|r<t|ƒ|_n||_dS(N(t_namet	_filenametdatatheaderstdicttheader_formatter(tselfRR/RR0R2((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pyt__init__Žs				cC@st|tƒrNt|ƒdkr3|\}}}q`|\}}t|ƒ}nd}d}|}|||d|d|ƒ}|jd|ƒ|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.
        iRR2tcontent_typeN(RttupletlenRtNonetmake_multipart(tclst	fieldnameR	R2RR/R5t
request_param((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pytfrom_tuplesžscC@s|j||ƒS(sI
        Overridable helper function to format a single header parameter. By
        default, this calls ``self.header_formatter``.

        :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.
        (R2(R3RR	((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pyt_render_partΒscC@svg}|}t|tƒr*|jƒ}nx<|D]4\}}|dk	r1|j|j||ƒƒq1q1Wdj|ƒ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) tuples or a :class:`dict` of (k, v) to format
            as `k1="v1"; k2="v2"; ...`.
        u; N(RR1titemsR8tappendR>R#(R3theader_partstpartstiterableRR	((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pyt
_render_partsΟs cC@sΕg}dddg}xD|D]<}|jj|tƒr|jd||j|fƒqqWxL|jjƒD];\}}||krl|r§|jd||fƒq§qlqlW|jdƒdj|ƒS(s=
        Renders the headers for this request field.
        sContent-DispositionsContent-TypesContent-Locationu%s: %su
(R0tgettFalseR@R?R#(R3tlinest	sort_keystsort_keytheader_nametheader_value((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pytrender_headersεs
%!
c
C@st|p	d|jd<|jdcdjd|jd|jfd|jffƒgƒ7<||jd<||jd<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.

        u	form-datasContent-Dispositionu; uunameufilenamesContent-TypesContent-LocationN(R0R#RDR-R.(R3tcontent_dispositionR5tcontent_location((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pyR9ψs'
N(t__name__t
__module__t__doc__R8R+R4tclassmethodR=R>RDRLR9(((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pyR,}s
#	
		i (t
__future__Rtemail.utilsRRR!tpackagesRRRR*tupdatetrangeR)R+tformat_header_paramtobjectR,(((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/urllib3/fields.pyt<module>s"	)
	
	
Back to Directory File Manager