Re.A @s:dZddlZddlZddlmZmZmZmZyddlZeWne k rtddl ZYnXGddde Z Gddde Z d d Zd d Zddd dZGdddeZGdddejejZddZddZddddZddZdS)z Compatibility code to be able to use `cookielib.CookieJar` with requests. requests.utils imports from here, so be careful with imports. N) cookieliburlparse urlunparseMorselc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ dddZ ddZ ddZ ddZeddZeddZeddZdS) MockRequestaWraps 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)_r _new_headersrurlschemetype)selfrequestr7/tmp/pip-ztkk0jow-build/pip/_vendor/requests/cookies.py__init__!s  zMockRequest.__init__cCs|jS)N)r )r rrrget_type&szMockRequest.get_typecCst|jjjS)N)rrr netloc)r rrrget_host)szMockRequest.get_hostcCs |jS)N)r)r rrrget_origin_req_host,szMockRequest.get_origin_req_hostcCsl|jjjds|jjS|jjd}t|jj}t|j||j|j|j |j gS)NHost) rheadersgetr rrr pathparamsqueryfragment)r hostparsedrrr get_full_url/s zMockRequest.get_full_urlcCsdS)NTr)r rrris_unverifiable=szMockRequest.is_unverifiablecCs||jjkp||jkS)N)rrr )r namerrr has_header@szMockRequest.has_headerNcCs%|jjj||jj||S)N)rrrr )r r!defaultrrr get_headerCszMockRequest.get_headercCstddS)zMcookielib has no legitimate use for this method; add it back if you find one.z=Cookie headers should be added with add_unredirected_header()N)NotImplementedError)r keyvalrrr add_headerFszMockRequest.add_headercCs||j||jt|||q>q>Wn|S)a-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. NcSsg|]}|jqSr)r!).0rIrrr s z'cookiejar_from_dict..)rLrRrQ) cookie_dictrG overwritenames_from_jarr!rrrcookiejar_from_dicts    $rc Cst|tjs!tdnt|trKt|d|dd}nYt|tjry|j|Wqtk rx|D]}|j|qWYqXn|S)zAdd 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. z!You can only merge into CookieJarrGrF) rOrrp ValueErrorrrrqAttributeErrorrR)rGcookies cookie_in_jarrrr merge_cookiess  r)r1r collectionscompatrrrrr{ ImportErrordummy_threadingobjectrr3r?rCrJ RuntimeErrorrKrpMutableMappingrLrQrPrrrrrrs&  "  H   #