ó 9(Zc@s9dZddlZddlZddlZddlmZmZmZmZyddl Z e Wne k rddl Z nXde fd„ƒYZ de fd„ƒYZd „Zd „Zddd „Zd efd „ƒYZdejejfd„ƒYZd„Zd„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((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyt__init__"s  cCs|jS(N(R (R ((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pytget_type'scCst|jjƒjS(N(RRRtnetloc(R ((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pytget_host*scCs |jƒS(N(R(R ((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/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((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyt get_full_url0s cCstS(N(tTrue(R ((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pytis_unverifiable>scCs||jjkp||jkS(N(RRR(R tname((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyt has_headerAscCs%|jjj||jj||ƒƒS(N(RRRR(R Rtdefault((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyt get_headerDscCstdƒ‚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((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyt add_headerGscCs||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((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyt_find6s 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((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyRIDs cCs |jjƒ}|jdƒ|S(s4Unlike a normal CookieJar, this class is pickleable.t _cookies_lock(t__dict__Rmtpop(R tstate((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyt __getstate__Ws cCs5|jj|ƒd|jkr1tjƒ|_ndS(s4Unlike a normal CookieJar, this class is pickleable.RrN(RsRnt threadingtRLockRr(R Ru((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyt __setstate__^scCstƒ}|j|ƒ|S(s(Return a copy of this RequestsCookieJar.(RHRn(R tnew_cj((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyRmds  N(R*R+R,R-RRQRSRURVRWRXRYR[R]R_RaRbRcRdRNRnRpRIRvRyRm(((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyRH s.                cCsm|dkrdSt|dƒr)|jƒStj|ƒ}|jƒx$|D]}|jtj|ƒƒqIW|S(NRm(R-R4RmRBRN(R7tnew_jarRE((sD/tmp/pip-build-wDUJoH/botocore/botocore/vendored/requests/cookies.pyt_copy_cookie_jarks    cKstddd|d|dddddd d td dd td ddddidd6dtƒ }t|ƒt|ƒ}|r™d}t|t|ƒƒ‚n|j|ƒt|dƒ|ds*   "  H  Ë  #