ó >u¼Tc@s$dZddlZddlZddlmZmZmZmZyddlZeWne k rsddl ZnXde fd„ƒYZ de fd„ƒYZ d „Zd „Zddd „Zd efd „ƒ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 urlunparsetMorselt MockRequestcBs¡eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z dd„Z d „Z d „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.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_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|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 cCsºd}xŠt|ƒD]|}|j|kr|dksC|j|kr|dks^|j|krŒ|dk r}td|ƒ‚n|j}qŒqqqW|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.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.pyRHŸs.                cKstddd|d|dddddd d td dd td ddddidd6dtƒ }t|ƒt|ƒ}|r™d}t|t|ƒƒ‚n|j|ƒt|dƒ|ds&  "  H  Ë #