Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/requests_toolbelt/ |
| [Home] [System Details] [Kill Me] |
�
ӵ
Yc@sxdZddlmZmZddlZddlZy4ddlmZddlmZddlm Z WnAe
k
r�ddlmZddlmZddlm Z nXy$ddlm
Z
ddlmZWnUe
k
r'y$ddlm
Z
ddlmZWq(e
k
r#dZ
dZq(XnXejd kr@dZn8ydd
lmZWn!e
k
rwdd
lmZnXejdkr�dZn8yddlmZWn!e
k
r�ddlmZnXejdkZerddlZddlmZmZn,ddlZddl
mZddl!mZy
e"Z"Wne#k
rWe$e%fZ"nXdefd��YZ&dZ'dS( s�Private module
full of compatibility hacks.
Primarily this is for downstream redistributions of requests that unvendor
urllib3 without providing a shim.
.. warning::
This module is private. If you use it, and something breaks, you were
warned
i����(tMappingtMutableMappingN(tfields(tfilepost(tpoolmanager(tHTTPConnection(t
connectioni(ttimeouti(t appengineii(t urlencodeturljoin(R (R
tHTTPHeaderDictcBs
eZdZdd�Zd�Zd�Zd�Zd�Zd�Z d�Z
esiej
Z
ejZne�Zd�Zd �Zed
�Zd�Zd�Zd
�Zd�ZeZeZeZd�Zd�Zd�Zd�Zd�Zd�Z
e!d��Z"RS(sp
:param headers:
An iterable of field-value pairs. Must not contain multiple field
names
when compared case-insensitively.
:param kwargs:
Additional field-value pairs to pass in to ``dict.update``.
A ``dict`` like container for storing HTTP Headers.
Field names are stored and compared case-insensitively in compliance
with
RFC 7230. Iteration provides the first case-sensitive key seen for each
case-insensitive pair.
Using ``__setitem__`` syntax overwrites fields that compare equal
case-insensitively in order to maintain ``dict``'s api. For fields
that
compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add``
in a loop.
If multiple fields that are equal case-insensitively are passed to the
constructor or ``.update``, the behavior is undefined and some will be
lost.
>>> headers = HTTPHeaderDict()
>>> headers.add('Set-Cookie', 'foo=bar')
>>> headers.add('set-cookie', 'baz=quxx')
>>> headers['content-length'] = '7'
>>> headers['SET-cookie']
'foo=bar, baz=quxx'
>>> headers['Content-Length']
'7'
cKsqtt|�j�i|_|dk rWt|t�rG|j|�qW|j|�n|rm|j|�ndS(N(tsuperRt__init__t
_containertNonet
isinstancet
_copy_fromtextend(tselftheaderstkwargs((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyR
gs cCs*||f|j|j�<|j|j�S(N(Rtlower(Rtkeytval((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt__setitem__rscCs$|j|j�}dj|d�S(Ns,
i(RRtjoin(RRR((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt__getitem__vscCs|j|j�=dS(N(RR(RR((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt__delitem__zscCs|j�|jkS(N(RR(RR((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt__contains__}scCs�t|t�r$t|d�r$tSt|t|��sNt|�|�}ntd�|j�D��td�|j�D��kS(Ntkeyscss'|]\}}|j�|fVqdS(N(R(t.0tktv((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pys <genexpr>�scss'|]\}}|j�|fVqdS(N(R(RR
R!((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pys <genexpr>�s(RRthasattrtFalsettypetdictt
itermerged(Rtother((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt__eq__�s
cCs|j|�S(N(R((RR'((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt__ne__�scCs
t|j�S(N(tlenR(R((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt__len__�sccs'x
|jj�D]}|dVqWdS(Ni(Rtvalues(Rtvals((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt__iter__�scCsGy||}Wn'tk
r7||jkr3�n|SX||=|SdS(s�D.pop(k[,d]) -> v, remove
specified key and return its value.
If key is not found, d is returned if given, otherwise KeyError is
raised.
N(tKeyErrort_HTTPHeaderDict__marker(RRtdefaulttvalue((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pytpop�s
cCs#y||=Wntk
rnXdS(N(R/(RR((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pytdiscard�s
cCs}|j�}||f}|jj||�}||k ryt|t�rX|j|�qy|d|d|g|j|<ndS(s�Adds
a (name, value) pair, doesn't overwrite the value if it already
exists.
>>> headers = HTTPHeaderDict(foo='bar')
>>> headers.add('Foo', 'baz')
>>> headers['foo']
'bar, baz'
iiN(RRt
setdefaultRtlisttappend(RRRt key_lowertnew_valsR-((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pytadd�s cOs]t|�dkr0tdjt|����nt|�dkrL|dnd}t|t�r�x�|j�D]\}}|j||�qnWn�t|t�r�x�|D]}|j|||�q�Wndt|d�rxR|j �D]}|j|||�q�Wn'x$|D]\}}|j||�qWx*|j
�D]\}}|j||�q9WdS(s�Generic import function for any type
of header-like object.
Adapted version of MutableMapping.update in order to insert items
with self.add instead of self.__setitem__
is8extend() takes at most 1 positional arguments ({}
given)iRN((R*t TypeErrortformatRRt iteritemsR:RR"Rtitems(RtargsRR'RRR2((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyR�s" "
cCsRy|j|j�}Wntk
r+gSXt|t�rF|dgS|dSdS(smReturns a list of all the values
for the named field. Returns an
empty list if the key doesn't
exist.iN(RRR/Rttuple(RRR-((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pytgetlist�s
cCs#dt|�jt|j��fS(Ns%s(%s)(R$t__name__R%R&(R((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt__repr__�scCs\xU|D]M}|j|�}t|t�r:t|�}n|g||j|j�<qWdS(N(RARR6RR(RR'RR((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyR�s
cCs
t|��}|j|�|S(N(R$R(Rtclone((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pytcopys
ccsLxE|D]=}|j|j�}x!|dD]}|d|fVq+WqWdS(s8Iterate
over all header lines, including duplicate
ones.iiN(RR(RRR-R((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyR=s
ccsDx=|D]5}|j|j�}|ddj|d�fVqWdS(s:Iterate
over all headers, merging duplicate ones together.is,
iN(RRR(RRR((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyR&
s
cCst|j��S(N(R6R=(R((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyR>scCs�g}x�|jD]z}|jd�rY|d\}}||d|j�f|d<qn|jdd�\}}|j||j�f�qW||�S(s4Read
headers from a Python 2 httplib message object.t s i����s
t:i(RFs (Rt
startswithtrstriptsplitR7tstrip(tclstmessageRtlineRR2((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pytfrom_httplibsN(#RBt
__module__t__doc__RR
RRRRR(R)tPY3Rtiterkeyst
itervaluestobjectR0R+R.R3R4R:RRAt
getheaderstgetallmatchingheaderstigetRCRRER=R&R>tclassmethodRO(((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyREs:
t
basestringRRRRRtqueueR t
gaecontribR
(ii(s
basestrings
connectionsfieldssfilepostspoolmanagerstimeoutRsqueues urlencodes
gaecontribsurljoin((RQtcollectionsRRtsystrequeststrequests.packages.urllib3RRRtImportErrorturllib3t$requests.packages.urllib3.connectionRRturllib3.connectionRt __build__Rtrequests.packages.urllib3.utilturllib3.utilR\t!requests.packages.urllib3.contribRturllib3.contribtversion_infoRRR[turllib.parseR R
tQueueturllibturlparseRZt NameErrortstrtbytesRt__all__(((s=/usr/lib/python2.7/site-packages/requests_toolbelt/_compat.pyt<module>
sp
�