>uTc@s$dZddlZddlZddlmZmZmZmZyddlZeWne k rsddl ZnXde fdYZ de fdYZ d Zd Zddd Zd efd YZdejejfdYZdZdZdedZdZdS(s Compatibility code to be able to use `cookielib.CookieJar` with requests. requests.utils imports from here, so be careful with imports. iNi(t cookielibturlparset urlunparsetMorselt MockRequestcBseZdZdZdZdZdZdZdZdZ ddZ d Z d Z d Zed Zed ZedZRS(sWraps 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|jjj|_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|jjjS(N(RRRtnetloc(R ((s4/usr/lib/python2.7/site-packages/requests/cookies.pytget_host)scCs |jS(N(R(R ((s4/usr/lib/python2.7/site-packages/requests/cookies.pytget_origin_req_host,scCsl|jjjds|jjS|jjd}t|jj}t|j||j|j|j |j gS(NtHost( RtheaderstgetRRRRtpathtparamstquerytfragment(R thosttparsed((s4/usr/lib/python2.7/site-packages/requests/cookies.pyt get_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_headerCscCstddS(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|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_find5s cCsd}xt|D]|}|j|kr|dksC|j|kr|dks^|j|kr|dk r}td|n|j}qqqqW|r|Std|||fdS(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.pyRICs cCs |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.pyRHs.                cKstddd|d|dddddd d td dd td ddddidd6dt }t|t|}|rd}t|t|n|j|t|d|ds&  "  H   #