ok

Mini Shell

Direktori : /opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/
Upload File :
Current File : //opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyc

�
�2{Yc@s�dZddlZddlmZddlmZddlmZddlmZm	Z	m
Z
mZmZddl
mZmZmZmZdd	lmZmZmZdd
lmZmZddlmZmZmZddlmZmZm Z m!Z!dd
l"m#Z#ddl$m%Z%ddlm&Z&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddlm-Z-e	d�Z.e	d�Z/de0fd��YZ1de1fd��YZ2d�Z3dS(s�
requests.session
~~~~~~~~~~~~~~~~

This module provides a Session object to manage and persist settings across
requests (cookies, auth, proxies).

i����N(tMapping(tdatetimei(t_basic_auth_str(t	cookielibtOrderedDictturljointurlparsetbuiltin_str(tcookiejar_from_dicttextract_cookies_to_jartRequestsCookieJart
merge_cookies(tRequesttPreparedRequesttDEFAULT_REDIRECT_LIMIT(t
default_hookst
dispatch_hook(tto_key_val_listtdefault_headerstto_native_string(tTooManyRedirectst
InvalidSchematChunkedEncodingErrortContentDecodingError(tCaseInsensitiveDict(tHTTPAdapter(trequote_uritget_environ_proxiestget_netrc_authtshould_bypass_proxiestget_auth_from_url(tcodes(tREDIRECT_STATIcCs�|dkr|S|dkr |St|t�o;t|t�sB|S|t|��}|jt|��x0|j�D]"\}}|dkrt||=qtqtWtd�|j�D��}|S(s�
    Determines appropriate setting for a given request, taking into account the
    explicit setting on that request, and the setting in the session. If a
    setting is a dictionary, they will be merged together using `dict_class`
    css-|]#\}}|dk	r||fVqdS(N(tNone(t.0tktv((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pys	<genexpr>CsN(R!t
isinstanceRRtupdatetitemstdict(trequest_settingtsession_settingt
dict_classtmerged_settingR#R$((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyt
merge_setting'scCsZ|dks!|jd�gkr%|S|dksF|jd�gkrJ|St|||�S(s�
    Properly merges both requests and session hooks.

    This is necessary because when request_hooks == {'response': []}, the
    merge breaks Session hooks entirely.
    tresponseN(R!tgetR-(t
request_hookst
session_hooksR+((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pytmerge_hooksHs
!!tSessionRedirectMixincBs2eZededdd�Zd�Zd�ZRS(ccs�d}x�|jr�|j�}	y|jWn-tttfk
rX|jjdt�nX||j	kr~t
d|j	��n|j�|jd}
|j
}|
jd�r�t|j�}d|j|
f}
nt|
�}
|
j�}
t|
�jst|jt|
��}
nt|
�}
t|
�|	_|jtjkrV|dkrVd}n|jtjkr}|dkr}d}n|jtjkr�|d	kr�d}n||	_
|jtjtjfkr�d
|	jkr�|	jd
=nd|	_n|	j}y|d=Wnt k
rnXt!|	j"|	|j�|	j"j#|j$�|	j%|	j"�|j&|	|�}|j'|	|�|	}|j(|d|d
|d|d|d|dt�}t!|j$|	|j�|d7}|Vq	WdS(s6Receives a Response. Returns a generator of Responses.itdecode_contentsExceeded %s redirects.tlocations//s%s:%stHEADtGETtPOSTsContent-LengthtCookietstreamttimeouttverifytcerttproxiestallow_redirectsiN()tis_redirecttcopytcontentRRtRuntimeErrortrawtreadtFalset
max_redirectsRtclosetheaderstmethodt
startswithRturltschemetgeturltnetlocRRRtstatus_codeRt	see_othertfoundtmovedt	temporarytresumeR!tbodytKeyErrorR	t_cookiesR&tcookiestprepare_cookiestrebuild_proxiestrebuild_authtsend(tselftresptreqR:R;R<R=R>titprepared_requestRLRJtparsed_rurltparsedRI((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pytresolve_redirectsYsn

					
	
	
cCs�|j}|j}d|kr[t|jj�}t|�}|j|jkr[|d=q[n|jrpt|�nd}|dk	r�|j|�ndS(s�
        When being redirected we may want to strip authentication from the
        request to avoid leaking credentials. This method intelligently removes
        and reapplies authentication where possible to avoid credential loss.
        t
AuthorizationN(	RIRLRtrequestthostnamet	trust_envRR!tprepare_auth(R^RbR.RIRLtoriginal_parsedtredirect_parsedtnew_auth((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyR\�s		
cCs|j}|j}t|�j}|dk	r9|j�ni}|jr�t|�r�t|�}|j	|�}|r�|j
|||�q�nd|kr�|d=nyt||�\}	}
Wntk
r�d\}	}
nX|	r|
rt
|	|
�|d<n|S(s�
        This method re-evaluates the proxy configuration by considering the
        environment variables. If we are redirected to a URL covered by
        NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
        proxy keys for this URL (in case they were stripped by a previous
        redirect).

        This method also replaces the Proxy-Authorization header where
        necessary.
        sProxy-AuthorizationN(NN(RIRLRRMR!RARiRRR/t
setdefaultRRWR(R^RbR>RIRLRMtnew_proxiestenviron_proxiestproxytusernametpassword((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyR[�s$		

N(t__name__t
__module__RFR!tTrueReR\R[(((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyR3Xsa	tSessioncBseZdZddddddddd	d
ddd
dgZd�Zd�Zd�Zd�Zd!d!d!d!d!d!d!e	d!d!d!d!d!d�
Z
d�Zd�Zd�Z
d!d�Zd!d�Zd!d�Zd�Zd�Zd�Zd�Zd�Zd�Zd �ZRS("s�A Requests session.

    Provides cookie persistence, connection-pooling, and configuration.

    Basic Usage::

      >>> import requests
      >>> s = requests.Session()
      >>> s.get('http://httpbin.org/get')
      200
    RIRYtauthR;R>thookstparamsR<R=tprefetchtadaptersR:RiRGcCs�t�|_d|_i|_t�|_i|_t|_	t
|_d|_t
|_t
|_ti�|_t�|_|jdt��|jdt��dS(Nshttps://shttp://(RRIR!RxR>RRyRzRFR:RvR<R=RRGRiRRYRR|tmountR(R^((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyt__init__s								cCs|S(N((R^((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyt	__enter__?scGs|j�dS(N(RH(R^targs((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyt__exit__BscCs!|jpi}t|tj�s0t|�}nttt�|j�|�}|j}|jr�|r�|jr�t	|j
�}nt�}|jd|j
j�d|j
d|jd|jdt|j|jdt�dt|j|j�dt||j�d	|d
t|j|j��	|S(sbConstructs a :class:`PreparedRequest <PreparedRequest>` for
        transmission and returns it. The :class:`PreparedRequest` has settings
        merged from the :class:`Request <Request>` instance and those of the
        :class:`Session`.

        :param request: :class:`Request` instance to prepare with this
            session's settings.
        RJRLtfilestdataRIR+RzRxRYRy(RYR%Rt	CookieJarRRR
RxRiRRLR
tprepareRJtupperR�R�R-RIRRzR2Ry(R^RgRYtmerged_cookiesRxtp((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pytprepare_requestEs(							cCs�t|�}td|j�d|d|d|d|p9id|pEid|d|d	|�	}|j|�}|pui}|jrt|�p�i}x*|j�D]\}}|j||�q�W|r�|tk	r�t	j
jd
�}n|r|tk	rt	j
jd�}qnt||j
�}t|
|j�}
t||j�}t||j�}i|
d6|	d
6|d6|d6|d6|
d6}|j||�}|S(s4Constructs a :class:`Request <Request>`, prepares it and sends it.
        Returns :class:`Response <Response>` object.

        :param method: method for the new :class:`Request` object.
        :param url: URL for the new :class:`Request` object.
        :param params: (optional) Dictionary or bytes to be sent in the query
            string for the :class:`Request`.
        :param data: (optional) Dictionary or bytes to send in the body of the
            :class:`Request`.
        :param headers: (optional) Dictionary of HTTP Headers to send with the
            :class:`Request`.
        :param cookies: (optional) Dict or CookieJar object to send with the
            :class:`Request`.
        :param files: (optional) Dictionary of 'filename': file-like-objects
            for multipart encoding upload.
        :param auth: (optional) Auth tuple or callable to enable
            Basic/Digest/Custom HTTP Auth.
        :param timeout: (optional) Float describing the timeout of the
            request in seconds.
        :param allow_redirects: (optional) Boolean. Set to True by default.
        :param proxies: (optional) Dictionary mapping protocol to the URL of
            the proxy.
        :param stream: (optional) whether to immediately download the response
            content. Defaults to ``False``.
        :param verify: (optional) if ``True``, the SSL cert will be verified.
            A CA_BUNDLE path can also be provided.
        :param cert: (optional) if String, path to ssl client cert file (.pem).
            If Tuple, ('cert', 'key') pair.
        RJRLRIR�R�RzRxRYRytREQUESTS_CA_BUNDLEtCURL_CA_BUNDLER:R;R<R=R>R?(RRR�R�RiRR'RnRFtostenvironR/R-R>R:R<R=R](R^RJRLRzR�RIRYR�RxR;R?R>RyR:R<R=R`tpreptenv_proxiesR#R$tsend_kwargsR_((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyRglsD,		
cKs#|jdt�|jd||�S(s�Sends a GET request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        R?R7(RnRvRg(R^RLtkwargs((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyR/�scKs#|jdt�|jd||�S(s�Sends a OPTIONS request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        R?tOPTIONS(RnRvRg(R^RLR�((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pytoptions�scKs#|jdt�|jd||�S(s�Sends a HEAD request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        R?R6(RnRFRg(R^RLR�((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pythead�scKs|jd|d||�S(s8Sends a POST request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        R8R�(Rg(R^RLR�R�((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pytpost�scKs|jd|d||�S(s7Sends a PUT request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        tPUTR�(Rg(R^RLR�R�((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pytput�scKs|jd|d||�S(s9Sends a PATCH request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        tPATCHR�(Rg(R^RLR�R�((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pytpatch�scKs|jd||�S(s�Sends a DELETE request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        tDELETE(Rg(R^RLR�((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pytdeletesc
Ks|jd|j�|jd|j�|jd|j�|jd|j�t|t�sjtd��n|jdt	�}|j
d�}|j
d�}|j
d�}|j
d�}|j
d�}|j}	|jd|j
�}
tj�}|
j||�}tj�||_td	|	||�}|jrdx-|jD]}
t|j|
j|
j�q>Wnt|j||j�|j||d|d|d|d|d|�}|r�g|D]}
|
^q�ng}|r�|jd
|�|j�}||_n|s
|jn|S(sSend a given PreparedRequest.R:R<R=R>s#You can only send PreparedRequests.R?R;RLR.i(RnR:R<R=R>R%R
t
ValueErrortpopRvR/Rytget_adapterRLRtutcnowR]telapsedRthistoryR	RYRgRDRetinsertRB(R^RgR�R?R:R;R<R=R>RytadaptertstarttrR_tgenR�((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyR]sH		 	%
cCsMx6|jj�D]%\}}|j�j|�r|SqWtd|��dS(s>Returns the appropriate connnection adapter for the given URL.s*No connection adapters were found for '%s'N(R|R'tlowerRKR(R^RLtprefixR�((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyR�XscCs(x!|jj�D]}|j�qWdS(s+Closes all adapters and as such the sessionN(R|tvaluesRH(R^R$((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyRHbscCso||j|<g|jD]$}t|�t|�kr|^q}x'|D]}|jj|�|j|<qHWdS(skRegisters a connection adapter to a prefix.

        Adapters are sorted in descending order by key length.N(R|tlenR�(R^R�R�R#tkeys_to_movetkey((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyR}gs
4
cst�fd��jD��S(Nc3s'|]}|t�|d�fVqdS(N(tgetattrR!(R"tattr(R^(sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pys	<genexpr>ss(R(t	__attrs__(R^((R^sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyt__getstate__rscCs1x*|j�D]\}}t|||�q
WdS(N(R'tsetattr(R^tstateR�tvalue((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyt__setstate__usN(RtRut__doc__R�R~RR�R�R!RvRgR/R�R�R�R�R�R�R]R�RHR}R�R�(((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyRw�sD	3			(S	
	
	



			G	
			cCst�S(s2Returns a :class:`Session` for context-management.(Rw(((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pytsessionzs(4R�R�tcollectionsRRRxRtcompatRRRRRRYRR	R
RtmodelsRR
RRyRRtutilsRRRt
exceptionsRRRRt
structuresRR|RRRRRRtstatus_codesRR R-R2tobjectR3RwR�(((sN/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/sessions.pyt<module>
s*(""(!���

Zerion Mini Shell 1.0