ok

Mini Shell

Direktori : /proc/self/root/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/
Upload File :
Current File : //proc/self/root/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyc

�
Bu�_c@sHdZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZyddlZWne
k
r�ddlZnXdefd��YZdefd	��YZd
�Zd�Zeed�Zd
efd��YZdejefd��YZd�Zd�Zd�Zeed�Zd�ZdS(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
urlunparsetMorseltMutableMappingtMockRequestcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	dd�Zd	�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((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt__init__%s		cCs|jS(N(R(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytget_type*scCst|jj�jS(N(RRR	tnetloc(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytget_host-scCs
|j�S(N(R(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytget_origin_req_host0scCsx|jjjd�s|jjSt|jjddd�}t|jj�}t|j||j|j	|j
|jg�S(NtHosttencodingsutf-8(RtheaderstgetR	RRRR
tpathtparamstquerytfragment(Rthosttparsed((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytget_full_url3s
cCstS(N(tTrue(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytis_unverifiableAscCs||jjkp||jkS(N(RRR(Rtname((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt
has_headerDscCs%|jjj||jj||��S(N(RRRR(RR tdefault((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt
get_headerGscCstd��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((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt
add_headerJscCs||j|<dS(N(R(RR tvalue((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytadd_unredirected_headerNscCs|jS(N(R(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytget_new_headersQscCs
|j�S(N(R(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytunverifiableTscCs
|j�S(N(R(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytorigin_req_hostXscCs
|j�S(N(R(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyR\sN(t__name__t
__module__t__doc__RRRRRRR!tNoneR#R'R)R*tpropertyR+R,R(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRs
										tMockResponsecBs)eZdZd�Zd�Zd�ZRS(s�Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.

    ...what? Basically, expose the parsed HTTP headers from the server response
    the way `cookielib` expects to see them.
    cCs
||_dS(s�Make a MockResponse for `cookielib` to read.

        :param headers: a httplib.HTTPMessage or analogous carrying the headers
        N(t_headers(RR((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRhscCs|jS(N(R3(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytinfooscCs|jj|�dS(N(R3t
getheaders(RR ((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyR5rs(R-R.R/RR4R5(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyR2as		cCsNt|d�o|jsdSt|�}t|jj�}|j||�dS(s�Extract the cookies from the response into a CookieJar.

    :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)
    :param request: our own requests.Request object
    :param response: urllib3.HTTPResponse object
    t_original_responseN(thasattrR6RR2tmsgtextract_cookies(tjarR
tresponsetreqtres((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytextract_cookies_to_jarvs	cCs,t|�}|j|�|j�jd�S(sj
    Produce an appropriate Cookie header string to be sent with `request`, or None.

    :rtype: str
    tCookie(Rtadd_cookie_headerR*R(R:R
tr((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytget_cookie_header�s
cCs�g}x�|D]|}|j|kr(q
n|dk	rI||jkrIq
n|dk	rj||jkrjq
n|j|j|j|jf�q
Wx*|D]"\}}}|j|||�q�WdS(skUnsets a cookie by name, by default over all domains and paths.

    Wraps CookieJar.clear(), is O(n).
    N(R R0tdomainRtappendtclear(t	cookiejarR RCRt
clearablestcookie((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytremove_cookie_by_name�s
#tCookieConflictErrorcBseZdZRS(s�There are two cookies that meet the criteria specified in the cookie jar.
    Use .get and .set and include domain and path args in order to be more specific.
    (R-R.R/(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRJ�stRequestsCookieJarcBseZdZdddd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zddd�Zd
�Zd�Zd�Zd�Zd�Zd�Zddd�Zddd�Zd�Zd�Zd�Zd�ZRS(s�Compatibility class; is a cookielib.CookieJar, but exposes a dict
    interface.

    This is the CookieJar we create by default for requests and sessions that
    don't specify one, since some clients may expect response.cookies and
    session.cookies to support dict operations.

    Requests does not use the dict interface internally; it's just for
    compatibility with external client code. All requests code should work
    out of the box with externally provided instances of ``CookieJar``, e.g.
    ``LWPCookieJar`` and ``FileCookieJar``.

    Unlike a regular CookieJar, this class is pickleable.

    .. warning:: dictionary operations that are normally O(1) may be O(n).
    cCs0y|j|||�SWntk
r+|SXdS(s�Dict-like get() that also supports optional domain and path args in
        order to resolve naming collisions from using one cookie jar over
        multiple domains.

        .. warning:: operation is O(n), not O(1).
        N(t_find_no_duplicatestKeyError(RR R"RCR((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyR�s
cKs||dkr;t||d|jd�d|jd��dSt|t�rYt|�}nt|||�}|j|�|S(s�Dict-like set() that also supports optional domain and path args in
        order to resolve naming collisions from using one cookie jar over
        multiple domains.
        RCRN(R0RIRt
isinstanceRtmorsel_to_cookiet
create_cookiet
set_cookie(RR R(tkwargstc((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytset�s+
ccs#xt|�D]}|jVq
WdS(s�Dict-like iterkeys() that returns an iterator of names of cookies
        from the jar.

        .. seealso:: itervalues() and iteritems().
        N(titerR (RRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytiterkeys�scCst|j��S(s�Dict-like keys() that returns a list of names of cookies from the
        jar.

        .. seealso:: values() and items().
        (tlistRV(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytkeys�sccs#xt|�D]}|jVq
WdS(s�Dict-like itervalues() that returns an iterator of values of cookies
        from the jar.

        .. seealso:: iterkeys() and iteritems().
        N(RUR((RRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt
itervalues�scCst|j��S(s�Dict-like values() that returns a list of values of cookies from the
        jar.

        .. seealso:: keys() and items().
        (RWRY(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytvalues�sccs,x%t|�D]}|j|jfVq
WdS(s�Dict-like iteritems() that returns an iterator of name-value tuples
        from the jar.

        .. seealso:: iterkeys() and itervalues().
        N(RUR R((RRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt	iteritems�scCst|j��S(s�Dict-like items() that returns a list of name-value tuples from the
        jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a
        vanilla python dict of key value pairs.

        .. seealso:: keys() and values().
        (RWR[(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytitemsscCsCg}x6t|�D](}|j|kr|j|j�qqW|S(s2Utility method to list all the domains in the jar.(RURCRD(RtdomainsRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytlist_domainss
cCsCg}x6t|�D](}|j|kr|j|j�qqW|S(s0Utility method to list all the paths in the jar.(RURRD(RtpathsRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt
list_pathss
cCsSg}xFt|�D]8}|jdk	r;|j|kr;tS|j|j�qWtS(svReturns True if there are multiple domains in the jar.
        Returns False otherwise.

        :rtype: bool
        N(RURCR0RRDtFalse(RR]RH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytmultiple_domainsscCsji}x]t|�D]O}|dks4|j|kr|dksO|j|kr|j||j<qqW|S(s�Takes as an argument an optional domain and path and returns a plain
        old Python dict of name-value pairs of cookies that meet the
        requirements.

        :rtype: dict
        N(RUR0RCRR(R (RRCRt
dictionaryRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pytget_dict+scCs3ytt|�j|�SWntk
r.tSXdS(N(tsuperRKt__contains__RJR(RR ((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRf;s
cCs
|j|�S(s�Dict-like __getitem__() for compatibility with client code. Throws
        exception if there are more than one cookie with name. In that case,
        use the more explicit get() method instead.

        .. warning:: operation is O(n), not O(1).
        (RL(RR ((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt__getitem__AscCs|j||�dS(s�Dict-like __setitem__ for compatibility with client code. Throws
        exception if there is already a cookie of that name in the jar. In that
        case, use the more explicit set() method instead.
        N(RT(RR R(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt__setitem__JscCst||�dS(slDeletes a cookie given a name. Wraps ``cookielib.CookieJar``'s
        ``remove_cookie_by_name()``.
        N(RI(RR ((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt__delitem__QscOsmt|jd�rQ|jjd�rQ|jjd�rQ|jjdd�|_ntt|�j|||�S(Nt
startswitht"s\"t(R7R(RjtendswithtreplaceReRKRQ(RRHtargsRR((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRQWs6cCsVt|tj�r<x=|D]}|jtj|��qWntt|�j|�dS(sAUpdates this jar with cookies from another CookieJar or dict-likeN(RNRt	CookieJarRQtcopyReRKtupdate(RtotherRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRr\s
cCs�xft|�D]X}|j|kr
|dks=|j|kre|dksX|j|krb|jSqeq
q
Wtd|||f��dS(s�Requests uses this method internally to get cookie values.

        If there are conflicting cookies, _find arbitrarily chooses one.
        See _find_no_duplicates if you want an exception thrown if there are
        conflicting cookies.

        :param name: a string containing name of cookie
        :param domain: (optional) string containing domain of cookie
        :param path: (optional) string containing path of cookie
        :return: cookie.value
        sname=%r, domain=%r, path=%rN(RUR R0RCRR(RM(RR RCRRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt_finddscCs�d}x�t|�D]|}|j|kr|dksC|j|kr�|dks^|j|kr�|dk	r}td|��n|j}q�q�qqW|r�|Std|||f��dS(s�Both ``__get_item__`` and ``get`` call this function: it's never
        used elsewhere in Requests.

        :param name: a string containing name of cookie
        :param domain: (optional) string containing domain of cookie
        :param path: (optional) string containing path of cookie
        :raises KeyError: if cookie is not found
        :raises CookieConflictError: if there are multiple cookies
            that match name and optionally domain and path
        :return: cookie.value
        s(There are multiple cookies with name, %rsname=%r, domain=%r, path=%rN(R0RUR RCRRJR(RM(RR RCRttoReturnRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRLxscCs |jj�}|jd�|S(s4Unlike a normal CookieJar, this class is pickleable.t
_cookies_lock(t__dict__Rqtpop(Rtstate((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt__getstate__�s
cCs5|jj|�d|jkr1tj�|_ndS(s4Unlike a normal CookieJar, this class is pickleable.RvN(RwRrt	threadingtRLockRv(RRy((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt__setstate__�scCs-t�}|j|j��|j|�|S(s(Return a copy of this RequestsCookieJar.(RKt
set_policyt
get_policyRr(Rtnew_cj((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRq�s	
cCs|jS(s&Return the CookiePolicy instance used.(t_policy(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyR�sN(R-R.R/R0RRTRVRXRYRZR[R\R^R`RbRdRfRgRhRiRQRrRtRLRzR}RqR(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRK�s2														
										cCsm|dkrdSt|d�r)|j�Stj|�}|j�x$|D]}|jtj|��qIW|S(NRq(R0R7RqRERQ(R:tnew_jarRH((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt_copy_cookie_jar�s


cKsi
dd6|d6|d6dd6dd6dd	6td
6dd6td6dd
6dd6idd6d6td6}t|�t|�}|r�d}t|t|���n|j|�t|d�|d<t|d�|d<|djd�|d<t|d	�|d<t	j
|�S(s�Make a cookie from underspecified parameters.

    By default, the pair of `name` and `value` will be set for the domain ''
    and sent on every request (this is sometimes called a "supercookie").
    itversionR R(tportRlRCt/Rtsecuretexpirestdiscardtcommenttcomment_urltHttpOnlytresttrfc2109s4create_cookie() got unexpected keyword arguments: %stport_specifiedtdomain_specifiedt.tdomain_initial_dottpath_specifiedN(R0RaRRTt	TypeErrorRWRrtboolRjRR?(R R(RRtresulttbadargsterr((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRP�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	|jd
|d
ddd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�RCR RR�R�thttponlyR�R�R�R(R�iN(
R0tintttimet
ValueErrorR�tcalendarttimegmtstrptimeRPR�RaR%R((tmorselR�t
time_template((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyRO�s0
$



	
	cCs�|dkrt�}n|dk	r�g|D]}|j^q+}x@|D]5}|s_||krG|jt|||��qGqGWn|S(sCReturns 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.
    :rtype: CookieJar
    N(R0RKR RQRP(tcookie_dictRFt	overwriteRHtnames_from_jarR ((sM/opt/alt/python36/lib/python3.6/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.
    :rtype: CookieJar
    s!You can only merge into CookieJarRFR�(
RNRRpR�tdictR�RaRrtAttributeErrorRQ(RFtcookiest
cookie_in_jar((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt
merge_cookiess

( R/RqR�R�t_internal_utilsRtcompatRRRRRR{tImportErrortdummy_threadingtobjectRR2R>RBR0RItRuntimeErrorRJRpRKR�RPRORR�R�(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/requests/cookies.pyt<module>
s*(
H		�		$	

Zerion Mini Shell 1.0