Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/requests/ |
| [Home] [System Details] [Kill Me] |
�
>u�Tc@s$dZddlZddlZddlmZmZmZmZyddlZeWne k
rsddl
ZnXdefd��YZdefd��YZ
d �Zd
�Zddd�Zdefd
��YZdejejfd��YZd�Zd�Zded�Zd�ZdS(s�
Compatibility code to be able to use `cookielib.CookieJar` with requests.
requests.utils imports from here, so be careful with imports.
i����Ni(t cookielibturlparset
urlunparsetMorseltMockRequestcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z dd�Zd �Zd
�Z
d�Zed��Zed
��Zed��ZRS(s�Wraps a
`requests.Request` to mimic a `urllib2.Request`.
The code in `cookielib.CookieJar` expects this interface in order to
correctly
manage cookie policies, i.e., determine whether a cookie can be set,
given the
domains of the request and the cookie.
The original request object is read-only. The client is responsible for
collecting
the new headers via `get_new_headers()` and interpreting them
appropriately. You
probably want `get_cookie_header`, defined below.
cCs.||_i|_t|jj�j|_dS(N(t_rt_new_headersRturltschemettype(tselftrequest((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt__init__!s cCs|jS(N(R (R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytget_type&scCst|jj�jS(N(RRRtnetloc(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytget_host)scCs
|j�S(N(R(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytget_origin_req_host,scCsl|jjjd�s|jjS|jjd}t|jj�}t|j||j|j|j |j
g�S(NtHost(RtheaderstgetRRRRtpathtparamstquerytfragment(R
thosttparsed((s4/usr/lib/python2.7/site-packages/requests/cookies.pytget_full_url/s
cCstS(N(tTrue(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytis_unverifiable=scCs||jjkp||jkS(N(RRR(R
tname((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt
has_header@scCs%|jjj||jj||��S(N(RRRR(R
Rtdefault((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt
get_headerCscCstd��dS(sMcookielib has no legitimate use for
this method; add it back if you find one.s=Cookie headers should be added
with add_unredirected_header()N(tNotImplementedError(R
tkeytval((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt
add_headerFscCs||j|<dS(N(R(R
Rtvalue((s4/usr/lib/python2.7/site-packages/requests/cookies.pytadd_unredirected_headerJscCs|jS(N(R(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytget_new_headersMscCs
|j�S(N(R(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytunverifiablePscCs
|j�S(N(R(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytorigin_req_hostTscCs
|j�S(N(R(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRXsN(t__name__t
__module__t__doc__RR
RRRRRtNoneR
R$R&R'tpropertyR(R)R(((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRs
tMockResponsecBs)eZdZd�Zd�Zd�ZRS(s�Wraps
a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.
...what? Basically, expose the parsed HTTP headers from the server
response
the way `cookielib` expects to see them.
cCs
||_dS(s�Make a MockResponse for `cookielib` to read.
:param headers: a httplib.HTTPMessage or analogous carrying the
headers
N(t_headers(R
R((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRdscCs|jS(N(R0(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytinfokscCs|jj|�dS(N(R0t
getheaders(R
R((s4/usr/lib/python2.7/site-packages/requests/cookies.pyR2ns(R*R+R,RR1R2(((s4/usr/lib/python2.7/site-packages/requests/cookies.pyR/]s cCsNt|d�o|jsdSt|�}t|jj�}|j||�dS(s�Extract
the cookies from the response into a CookieJar.
:param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)
:param request: our own requests.Request object
:param response: urllib3.HTTPResponse object
t_original_responseN(thasattrR3RR/tmsgtextract_cookies(tjarRtresponsetreqtres((s4/usr/lib/python2.7/site-packages/requests/cookies.pytextract_cookies_to_jarrs cCs,t|�}|j|�|j�jd�S(sOProduce
an appropriate Cookie header string to be sent with `request`, or
None.tCookie(Rtadd_cookie_headerR'R(R7Rtr((s4/usr/lib/python2.7/site-packages/requests/cookies.pytget_cookie_header�s
cCs�g}x{|D]s}|j|kr
|dks=||jkr�|dksX||jkr}|j|j|j|jf�q}q�q
q
Wx*|D]"\}}}|j|||�q�WdS(skUnsets
a cookie by name, by default over all domains and paths.
Wraps CookieJar.clear(), is O(n).
N(RR-tdomainRtappendtclear(t cookiejarRR@Rt
clearablestcookie((s4/usr/lib/python2.7/site-packages/requests/cookies.pytremove_cookie_by_name�s
,tCookieConflictErrorcBseZdZRS(s�There
are two cookies that meet the criteria specified in the cookie jar.
Use .get and .set and include domain and path args in order to be more
specific.(R*R+R,(((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRG�stRequestsCookieJarcBs�eZdZdddd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d�Zd �Zd
�Z
d�Zddd�Zd
�Zd�Zd�Zd�Zd�Zddd�Zddd�Zd�Zd�Zd�ZRS(s�Compatibility
class; is a cookielib.CookieJar, but exposes a dict
interface.
This is the CookieJar we create by default for requests and sessions
that
don't specify one, since some clients may expect response.cookies
and
session.cookies to support dict operations.
Requests does not use the dict interface internally; it's just for
compatibility with external client code. All requests code should work
out of the box with externally provided instances of ``CookieJar``,
e.g.
``LWPCookieJar`` and ``FileCookieJar``.
Unlike a regular CookieJar, this class is pickleable.
.. warning:: dictionary operations that are normally O(1) may be O(n).
cCs0y|j|||�SWntk
r+|SXdS(s�Dict-like get() that also supports optional domain and
path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.
.. warning:: operation is O(n), not
O(1).N(t_find_no_duplicatestKeyError(R
RRR@R((s4/usr/lib/python2.7/site-packages/requests/cookies.pyR�s
cKs||dkr;t||d|jd�d|jd��dSt|t�rYt|�}nt|||�}|j|�|S(s�Dict-like
set() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.R@RN(R-RFRt
isinstanceRtmorsel_to_cookiet
create_cookiet
set_cookie(R
RR%tkwargstc((s4/usr/lib/python2.7/site-packages/requests/cookies.pytset�s+
ccs#xt|�D]}|jVq
WdS(syDict-like
iterkeys() that returns an iterator of names of cookies
from the jar. See itervalues() and iteritems().N(titerR(R
RE((s4/usr/lib/python2.7/site-packages/requests/cookies.pytiterkeys�scCst|j��S(shDict-like
keys() that returns a list of names of cookies from the
jar. See values() and items().(tlistRS(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytkeys�sccs#xt|�D]}|jVq
WdS(szDict-like
itervalues() that returns an iterator of values of cookies
from the jar. See iterkeys() and iteritems().N(RRR%(R
RE((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt
itervalues�scCst|j��S(siDict-like values() that returns a
list of values of cookies from the
jar. See keys() and items().(RTRV(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytvalues�sccs,x%t|�D]}|j|jfVq
WdS(szDict-like
iteritems() that returns an iterator of name-value tuples
from the jar. See iterkeys() and itervalues().N(RRRR%(R
RE((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt iteritems�scCst|j��S(s�Dict-like
items() that returns a list of name-value tuples from the
jar. See keys() and values(). Allows client-code to call
``dict(RequestsCookieJar)`` and get a vanilla python dict of key
value
pairs.(RTRX(R
((s4/usr/lib/python2.7/site-packages/requests/cookies.pytitems�scCsCg}x6t|�D](}|j|kr|j|j�qqW|S(s2Utility
method to list all the domains in the jar.(RRR@RA(R
tdomainsRE((s4/usr/lib/python2.7/site-packages/requests/cookies.pytlist_domains�s
cCsCg}x6t|�D](}|j|kr|j|j�qqW|S(s0Utility
method to list all the paths in the jar.(RRRRA(R
tpathsRE((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt
list_paths�s
cCsSg}xFt|�D]8}|jdk r;|j|kr;tS|j|j�qWtS(sWReturns
True if there are multiple domains in the jar.
Returns False otherwise.N(RRR@R-RRAtFalse(R
RZRE((s4/usr/lib/python2.7/site-packages/requests/cookies.pytmultiple_domains�scCsji}x]t|�D]O}|dks4|j|kr|dksO|j|kr|j||j<qqW|S(s�Takes
as an argument an optional domain and path and returns a plain
old Python dict of name-value pairs of cookies that meet the
requirements.N(RRR-R@RR%R(R
R@Rt
dictionaryRE((s4/usr/lib/python2.7/site-packages/requests/cookies.pytget_dicts'cCs
|j|�S(s�Dict-like
__getitem__() for compatibility with client code. Throws
exception if there are more than one cookie with name. In that
case,
use the more explicit get() method instead.
.. warning:: operation is O(n), not O(1).(RI(R
R((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt__getitem__scCs|j||�dS(s�Dict-like
__setitem__ for compatibility with client code. Throws
exception if there is already a cookie of that name in the jar. In
that
case, use the more explicit set() method instead.N(RQ(R
RR%((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt__setitem__scCst||�dS(scDeletes
a cookie given a name. Wraps ``cookielib.CookieJar``'s
``remove_cookie_by_name()``.N(RF(R
R((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt__delitem__#scOsmt|jd�rQ|jjd�rQ|jjd�rQ|jjdd�|_ntt|�j|||�S(Nt
startswitht"s\"t(R4R%RetendswithtreplacetsuperRHRN(R
REtargsRO((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRN(s6cCsMt|tj�r3x4|D]}|j|�qWntt|�j|�dS(sAUpdates
this jar with cookies from another CookieJar or
dict-likeN(RKRt CookieJarRNRjRHtupdate(R
totherRE((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRm-s
cCs�xft|�D]X}|j|kr
|dks=|j|kre|dksX|j|krb|jSqeq
q
Wtd|||f��dS(s>Requests
uses this method internally to get cookie values. Takes as
args name and optional domain and path. Returns a cookie.value. If
there are conflicting cookies, _find arbitrarily chooses one. See
_find_no_duplicates if you want an exception thrown if there are
conflicting cookies.sname=%r, domain=%r,
path=%rN(RRRR-R@RR%RJ(R
RR@RRE((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt_find5scCs�d}x�t|�D]|}|j|kr|dksC|j|kr�|dks^|j|kr�|dk r}td|��n|j}q�q�qqW|r�|Std|||f��dS(sRBoth
``__get_item__`` and ``get`` call this function: it's never
used elsewhere in Requests. Takes as args name and optional domain
and
path. Returns a cookie.value. Throws KeyError if cookie is not
found
and CookieConflictError if there are multiple cookies that match
name
and optionally domain and path.s(There are multiple cookies with
name, %rsname=%r, domain=%r, path=%rN(R-RRRR@RRGR%RJ(R
RR@RttoReturnRE((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRICscCs
|jj�}|jd�|S(s4Unlike a normal CookieJar, this class is
pickleable.t
_cookies_lock(t__dict__tcopytpop(R
tstate((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt__getstate__Vs
cCs5|jj|�d|jkr1tj�|_ndS(s4Unlike
a normal CookieJar, this class is
pickleable.RqN(RrRmt threadingtRLockRq(R
Ru((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt__setstate__]scCst�}|j|�|S(s(Return
a copy of this RequestsCookieJar.(RHRm(R
tnew_cj((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRscs
N(R*R+R,R-RRQRSRURVRWRXRYR[R]R_RaRbRcRdRNRmRoRIRvRyRs(((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRH�s.
cKstddd|d|dddddd d
tdddtd
ddddidd6dt�
}t|�t|�}|r�d}t|t|���n|j|�t|d�|d<t|d�|d<|dj d�|d<t|d�|d<t
j|�S(s�Make a cookie from underspecified parameters.
By default, the pair of `name` and `value` will be set for the domain
''
and sent on every request (this is sometimes called a
"supercookie").
tversioniRR%tportR@RgRt/tsecuretexpirestdiscardtcommenttcomment_urltresttHttpOnlytrfc2109s4create_cookie()
got unexpected keyword arguments:
%stport_specifiedtdomain_specifiedt.tdomain_initial_dottpath_specifiedN(tdictR-R^RRQt TypeErrorRTRmtboolReRR<(RR%ROtresulttbadargsterr((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRMjs0
cCs�d}|dr'tj�|d}n9|dr`d}tjtj|d|��tj}ntd|ddt|d�dtd|dd|d|jd |d d
ddi|dd
6dtdt|d�d|j d|dp�d�
S(sBConvert a Morsel
object into a Cookie containing the one k/v pair.smax-ageRs%a, %d-%b-%Y
%H:%M:%S GMTR�R�R�R@RRR|R�thttponlyR�R�R~R%R{iN(
R-ttimetmktimetstrptimettimezoneRMR�R^R"R%(tmorselRt
time_template((s4/usr/lib/python2.7/site-packages/requests/cookies.pyRL�s*
#
cCs�|dkrt�}n|dk r�g|D]}|j^q+}x@|D]5}|s_||krG|jt|||��qGqGWn|S(s-Returns
a CookieJar from a key/value dictionary.
:param cookie_dict: Dict of key/values to insert into CookieJar.
:param cookiejar: (optional) A cookiejar to add the cookies to.
:param overwrite: (optional) If False, will not replace cookies
already in the jar with new ones.
N(R-RHRRNRM(tcookie_dictRCt overwriteREtnames_from_jarR((s4/usr/lib/python2.7/site-packages/requests/cookies.pytcookiejar_from_dict�s
$cCs�t|tj�s!td��nt|t�rKt|d|dt�}nXt|tj�r�y|j|�Wq�tk
r�x|D]}|j |�q�Wq�Xn|S(s�Add cookies to cookiejar and
returns a merged CookieJar.
:param cookiejar: CookieJar object to add the cookies to.
:param cookies: Dictionary or CookieJar object to be added.
s!You can only merge into CookieJarRCR�(
RKRRlt
ValueErrorR�R�R^RmtAttributeErrorRN(RCtcookiest
cookie_in_jar((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt
merge_cookies�s
(R,R�tcollectionstcompatRRRRRwtImportErrortdummy_threadingtobjectRR/R;R?R-RFtRuntimeErrorRGRltMutableMappingRHRMRLRR�R�(((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt<module>s&"
H � #