ó •abc@sQdZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z yddl Z Wne k r—ddlZ nXdefd„ƒYZdefd „ƒYZd „Zd „Zddd „Zd efd„ƒYZdejejfd„ƒYZd„Zd„Zd„Zded„Zd„Z dS(s­ requests.cookies ~~~~~~~~~~~~~~~~ Compatibility code to be able to use `cookielib.CookieJar` with requests. requests.utils imports from here, so be careful with imports. iÿÿÿÿNi(tto_native_string(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((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pyt__init__&s  cCs|jS(N(R (R ((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pytget_type+scCst|jjƒjS(N(RRRtnetloc(R ((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pytget_host.scCs |jƒS(N(R(R ((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pytget_origin_req_host1scCsx|jjjdƒs|jjSt|jjdddƒ}t|jjƒ}t|j||j|j |j |j gƒS(NtHosttencodingsutf-8( RtheaderstgetRRRRR tpathtparamstquerytfragment(R thosttparsed((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pyt get_full_url4s cCstS(N(tTrue(R ((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pytis_unverifiableBscCs||jjkp||jkS(N(RRR(R tname((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pyt has_headerEscCs%|jjj||jj||ƒƒS(N(RRRR(R Rtdefault((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pyt get_headerHscCstdƒ‚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((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pyt add_headerKscCs||j|(RR'RQtresulttbadargsterr((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pyROµs0   cCs!d}|dr_y$ttjƒt|dƒƒ}Wq‘tk r[td|dƒ‚q‘Xn2|dr‘d}tjtj|d|ƒƒ}ntd|ddt |dƒdt d|dd|d |j d |d d dd i|d d6dt dt |dƒd|j d|dpdƒ S(sBConvert a Morsel object into a Cookie containing the one k/v pair.smax-agesmax-age: %s must be integerR„s%a, %d-%b-%Y %H:%M:%S GMTR†R‡R…RBRRRRˆthttponlyR‰RŠRƒR'R€iN( R/tintttimet ValueErrorR‘tcalendarttimegmtstrptimeROR’R`R$R'(tmorselR„t time_template((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pyRNØs0 $       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/RJRRPRO(t cookie_dictREt overwriteRGtnames_from_jarR((s@/usr/lib/python2.7/site-packages/pip/_vendor/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 CookieJarRER ( RMRRoR™RR¢R`RqtAttributeErrorRP(REtcookiest cookie_in_jar((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pyt merge_cookies s  (!R.RpR˜Ršt collectionst_internal_utilsRtcompatRRRRRzt ImportErrortdummy_threadingtobjectRR1R=RAR/RHt RuntimeErrorRIRotMutableMappingRJRRORNRR¢R¦(((s@/usr/lib/python2.7/site-packages/pip/_vendor/requests/cookies.pyt s,    " H  ú  #