Files
old-nlp/venv/lib/python3.7/site-packages/urllib3/__pycache__/fields.cpython-37.pyc

161 lines
7.9 KiB
Plaintext
Raw Normal View History

2019-10-20 13:16:49 +02:00
B
U%<25>]i!<00>@s<>ddlmZddlZddlZddlZddlmZddd<07>Zdd <09>Z d
d d d <0C>Z
e
<EFBFBD> d d<0E>e dd<0F>D<00><01>dd<11>Z dd<13>ZeZGdd<15>de<10>ZdS)<17>)<01>absolute_importN<74>)<01>six<69>application/octet-streamcCs|rt<00>|<00>dp|S|S)z<>
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`.
r)<02> mimetypes<65>
guess_type)<02>filename<6D>default<6C>r
<00>3/tmp/pip-install-_zqls8j0/urllib3/urllib3/fields.py<70>guess_content_type s r c s<>t<00>tj<02>r<16><00>d<01><01>t<04>fdd<03>dD<00><01>sdd|<00>f}y|<02>d<06>Wnttfk
r^YnX|Stjrt<72><00>d<01><01>t j
<EFBFBD> <0B>d<01><02>d|<00>f<00>tjr<><72><00>d<01><01><00>S)a<>
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.
zutf-8c3s|]}|<01>kVqdS)Nr
)<02>.0<EFBFBD>ch)<01>valuer
r <00> <genexpr>)sz.format_header_param_rfc2231.<locals>.<genexpr>z"\
z%s="%s"<22>asciiz%s*=%s) <0C>
isinstancer<00> binary_type<70>decode<64>any<6E>encode<64>UnicodeEncodeError<6F>UnicodeDecodeError<6F>PY2<59>email<69>utils<6C>encode_rfc2231)<03>namer<00>resultr
)rr <00>format_header_param_rfc2231s  
 
 
rz%22z\\)<03>"<22>\r!cCs&i|]}|dkrd<01>|<01>t<01>|<01><01>qS))<01>z%{:02X})<03>formatr<00>unichr)r <00>ccr
r
r <00>
<dictcomp>Isr&<00> cs:<00>fdd<02>}t<00>d<03>dd<05><00><00><03>D<00><01><01>}|<03>||<00>}|S)Ncs<00>|<00>d<01>S)Nr)<01>group)<01>match)<01>needles_and_replacementsr
r <00>replacerRsz#_replace_multiple.<locals>.replacer<65>|cSsg|]}t<00>|<01><01>qSr
)<02>re<72>escape)r <00>needler
r
r <00>
<listcomp>Vsz%_replace_multiple.<locals>.<listcomp>)r-<00>compile<6C>join<69>keys<79>sub)rr*r+<00>patternrr
)r*r <00>_replace_multipleQs
  r6cCs,t|tj<02>r|<01>d<01>}t|t<05>}d||fS)a<>
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.
zutf-8z%s="%s")rrrrr6<00>_HTML5_REPLACEMENTS)rrr
r
r <00>format_header_param_html5^s 

r8c@sReZdZdZddefdd<04>Zeefdd<06><01>Zdd<08>Zd d
<EFBFBD>Z d d <0C>Z
dd d<0E>Z dS)<10> RequestFielda
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`.
NcCs0||_||_||_i|_|r&t|<04>|_||_dS)N)<06>_name<6D> _filename<6D>data<74>headers<72>dict<63>header_formatter)<06>selfrr<rr=r?r
r
r <00>__init__<5F>s
zRequestField.__init__cCs`t|t<01>r4t|<02>dkr"|\}}}q@|\}}t|<04>}n d}d}|}|||||d<03>}|j|d<04>|S)a<>
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.
<20>N)rr?)<01> content_type)r<00>tuple<6C>lenr <00>make_multipart)<08>cls<6C> fieldnamerr?rr<rC<00> request_paramr
r
r <00> from_tuples<65>s
  
 zRequestField.from_tuplescCs |<00>||<02>S)aI
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.
)r?)r@rrr
r
r <00> _render_part<72>s zRequestField._render_partcCsPg}|}t|t<01>r|<01><02>}x*|D]"\}}|dk r |<02>|<00>||<05><02>q Wd<02>|<02>S)aO
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"; ...`.
Nz; )rr><00>items<6D>appendrKr2)r@<00> header_parts<74>parts<74>iterablerrr
r
r <00> _render_parts<74>s 
zRequestField._render_partscCs<>g}dddg}x2|D]*}|j<00>|d<04>r|<01>d||j|f<00>qWx4|j<00><03>D]&\}}||krN|rN|<01>d||f<00>qNW|<01>d<06>d<06>|<01>S)z=
Renders the headers for this request field.
zContent-Dispositionz Content-TypezContent-LocationFz%s: %sz
)r=<00>getrMrLr2)r@<00>lines<65> sort_keys<79>sort_key<65> header_name<6D> header_valuer
r
r <00>render_headers<72>s


zRequestField.render_headersc CsX|pd|jd<|jdd<03>d|<00>d|jfd|jff<02>g<02>7<||jd<||jd<d S)
a|
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.
z form-datazContent-Dispositionz; <20>rrz Content-TypezContent-LocationN)r=r2rQr:r;)r@<00>content_dispositionrC<00>content_locationr
r
r rF<00>s
zRequestField.make_multipart)NNN) <0C>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r8rA<00> classmethodrJrKrQrXrFr
r
r
r r9}s
# r9)r)<12>
__future__r<00> email.utilsrrr-<00>packagesrr rr7<00>update<74>ranger6r8<00>format_header_param<61>objectr9r
r
r
r <00><module>s  
*