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/models.pyo

�
�2{Yc@s;dZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
mZdd	lmZdd
lmZddlmZddlmZdd
lmZmZmZmZmZmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6ddl7m8Z8e8j9e8j:e8j;e8j<fZ=dZ>dZ?dZ@deAfd��YZBdeAfd��YZCdeCfd��YZDdeBeCfd��YZEdeAfd��YZFdS( s`
requests.models
~~~~~~~~~~~~~~~

This module contains the primary objects that power Requests.
i����N(tBytesIOtUnsupportedOperationi(t
default_hooks(tCaseInsensitiveDict(t
HTTPBasicAuth(tcookiejar_from_dicttget_cookie_header(tRequestField(tencode_multipart_formdata(t	parse_url(tDecodeError(t	HTTPErrortRequestExceptiont
MissingSchemat
InvalidURLtChunkedEncodingErrortContentDecodingError(
tguess_filenametget_auth_from_urltrequote_uritstream_decode_response_unicodetto_key_val_listtparse_header_linkstiter_slicestguess_json_utft	super_lentto_native_string(
t	cookielibt
urlunparseturlsplitt	urlencodetstrtbytestStringIOtis_py2tchardettjsontbuiltin_strt
basestringtIncompleteRead(tcodesii
iitRequestEncodingMixincBs5eZed��Zed��Zed��ZRS(cCssg}t|j�}|j}|s-d}n|j|�|j}|rf|jd�|j|�ndj|�S(sBuild the path URL to use.t/t?t(Rturltpathtappendtquerytjoin(tselfR-tpR.R0((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pytpath_url1s		
	
cCst|ttf�r|St|d�r,|St|d�rg}x�t|�D]�\}}t|t�syt|d�r�|g}nxl|D]d}|dk	r�|jt|t�r�|jd�n|t|t�r�|jd�n|f�q�q�WqNWt	|dt
�S|SdS(s�Encode parameters in a piece of data.

        Will successfully encode parameters when passed as a dict or a list of
        2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
        if parameters are supplied as a dict.
        treadt__iter__sutf-8tdoseqN(t
isinstanceRR thasattrRR&tNoneR/tencodeRtTrue(tdatatresulttktvstv((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt_encode_paramsFs 	
!3c
Csr|std��nt|t�r3td��ng}t|pEi�}t|pWi�}x�|D]�\}}t|t�s�t|d�r�|g}nx�|D]�}|dk	r�t|t�s�t|�}n|jt|t�r�|j	d�n|t|t�r|j
d�n|f�q�q�WqdWx'|D]\}}d}d}	t|ttf�r�t
|�dkr�|\}
}q�t
|�dkr�|\}
}}q�|\}
}}}	nt|�p�|}
|}t|t�r�t|�}nt|t�rt|�}ntd|d|j�d	|
d
|	�}|jd|�|j|�q3Wt|�\}
}|
|fS(
sBuild the body for a multipart/form-data request.

        Will successfully encode files when passed as a dict or a list of
        2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
        if parameters are supplied as a dict.

        sFiles must be provided.sData must not be a string.R6sutf-8iitnameR=tfilenametheaderstcontent_typeN(t
ValueErrorR8R&RR9R:R RR/tdecodeR;ttupletlisttlenRR!RRR5tmake_multipartR(tfilesR=t
new_fieldstfieldstfieldtvalRAR?tfttfhtfntfptrftbodyRF((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt
_encode_filesasL	
!3(t__name__t
__module__tpropertyR4tstaticmethodRBRX(((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR)0stRequestHooksMixincBseZd�Zd�ZRS(cCs||jkr"td|��nt|tj�rK|j|j|�n0t|d�r{|j|jd�|D��ndS(sProperly register a hook.s1Unsupported event specified, with event name "%s"R6css'|]}t|tj�r|VqdS(N(R8tcollectionstCallable(t.0th((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pys	<genexpr>�sN(thooksRGR8R^R_R/R9textend(R2teventthook((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt
register_hook�scCs5y|j|j|�tSWntk
r0tSXdS(siDeregister a previously registered hook.
        Returns True if the hook existed, False if not.
        N(RbtremoveR<RGtFalse(R2RdRe((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pytderegister_hook�s

(RYRZRfRi(((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR]�s	tRequestc
BsDeZdZdddddddddd�	Zd�Zd�ZRS(sA user-created :class:`Request <Request>` object.

    Used to prepare a :class:`PreparedRequest <PreparedRequest>`, which is sent to the server.

    :param method: HTTP method to use.
    :param url: URL to send.
    :param headers: dictionary of headers to send.
    :param files: dictionary of {filename: fileobject} files to multipart upload.
    :param data: the body to attach the request. If a dictionary is provided, form-encoding will take place.
    :param params: dictionary of URL parameters to append to the URL.
    :param auth: Auth handler or (user, pass) tuple.
    :param cookies: dictionary or CookieJar of cookies to attach to this request.
    :param hooks: dictionary of callback hooks, for internal usage.

    Usage::

      >>> import requests
      >>> req = requests.Request('GET', 'http://httpbin.org/get')
      >>> req.prepare()
      <PreparedRequest [GET]>

    c
Cs	|dkrgn|}|dkr*gn|}|dkrBin|}|dkrZin|}|	dkrrin|	}	t�|_x6t|	j��D]"\}
}|jd|
d|�q�W||_||_||_||_	||_
||_||_||_
dS(NRdRe(R:RRbRJtitemsRftmethodR-RERMR=tparamstauthtcookies(R2RlR-RERMR=RmRnRoRbR?RA((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt__init__�s 							cCsd|jS(Ns<Request [%s]>(Rl(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt__repr__�scCsht�}|jd|jd|jd|jd|jd|jd|jd|jd|j	d	|j
�	|S(
sXConstructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.RlR-RERMR=RmRnRoRb(tPreparedRequesttprepareRlR-RERMR=RmRnRoRb(R2R3((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRs�s										
N(RYRZt__doc__R:RpRqRs(((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRj�s	Rrc
Bs�eZdZd�Zdddddddddd�	Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
d�Z
d�Zd
�ZRS(s�The fully mutable :class:`PreparedRequest <PreparedRequest>` object,
    containing the exact bytes that will be sent to the server.

    Generated from either a :class:`Request <Request>` object or manually.

    Usage::

      >>> import requests
      >>> req = requests.Request('GET', 'http://httpbin.org/get')
      >>> r = req.prepare()
      <PreparedRequest [GET]>

      >>> s = requests.Session()
      >>> s.send(r)
      <Response [200]>

    cCs=d|_d|_d|_d|_d|_t�|_dS(N(R:RlR-REt_cookiesRWRRb(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRps					c

Csh|j|�|j||�|j|�|j|�|j||�|j||�|j|	�dS(s6Prepares the entire request with the given parameters.N(tprepare_methodtprepare_urltprepare_headerstprepare_cookiestprepare_bodytprepare_autht
prepare_hooks(
R2RlR-RERMR=RmRnRoRb((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRs!s


cCsd|jS(Ns<PreparedRequest [%s]>(Rl(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRq1scCsat�}|j|_|j|_|jj�|_|jj�|_|j|_|j|_|S(N(RrRlR-REtcopyRuRWRb(R2R3((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR}4s	cCs1||_|jdk	r-|jj�|_ndS(sPrepares the given HTTP method.N(RlR:tupper(R2Rl((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRv>s	c
Csnyt|�}Wn-tk
r/t|�}ntk
r?nXd|kro|j�jd�ro||_dSt|�\}}}}}}}	|s�tdj	|���n|s�t
d|��ny|jd�jd�}Wnt
k
rt
d��nX|pd	}
|
r"|
d
7}
n|
|7}
|rI|
dt|�7}
n|sXd}ntrt|t�r|jd�}nt|
t�r�|
jd�}
nt|t�r�|jd�}nt|t�r�|jd�}nt|	t�r|	jd�}	qn|j|�}|r=|r4d||f}q=|}ntt||
|d||	g��}||_dS(
sPrepares the given HTTP URL.t:thttpNsDInvalid URL {0!r}: No schema supplied. Perhaps you meant http://{0}?s Invalid URL %r: No host suppliedtidnasutf-8sURL has an invalid label.R,t@R*s%s&%s(tunicodet	NameErrorRtUnicodeDecodeErrortlowert
startswithR-R	R
tformatRR;RHtUnicodeErrorR"R8RBRRR:(R2R-RmtschemeRnthosttportR.R0tfragmenttnetloct
enc_params((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRwDsZ

"	!	


		$cCs8|r(td�|j�D��|_nt�|_dS(s Prepares the given HTTP headers.css'|]\}}t|�|fVqdS(N(R(R`RCtvalue((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pys	<genexpr>�sN(RRkRE(R2RE((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRx�s"cCs}d
}d
}d
}tt|d�t|ttttf�g�}yt|�}Wn t	t
tfk
rud
}nX|r�|}|r�td��n|d
k	r�t
|�|jd<qpd|jd<n�|r�|j||�\}}nT|r>|j|�}t|t�s,t|t
�s,t|d�r5d
}q>d}n|j|�|rpd|jkrp||jd	<n||_d
S(s"Prepares the given HTTP body data.R6s1Streamed bodies and files are mutually exclusive.sContent-LengthtchunkedsTransfer-EncodingR5s!application/x-www-form-urlencodedscontent-typesContent-TypeN(R:tallR9R8R&RJRItdictRt	TypeErrortAttributeErrorRtNotImplementedErrorR%RERXRBRtprepare_content_lengthRW(R2R=RMRWRFtlengtht	is_stream((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRz�s8"
-		
cCs�t|d�rZt|d�rZ|jdd�t|j��|jd<|jdd�nV|dk	r�t|�}|r�t|�|jd<q�n|jd	kr�d|jd<ndS(
NtseekttelliisContent-LengthtGETtHEADt0(R�R�(R9R�R%R�RER:RRl(R2RWtl((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR��sR,cCs�|dkr6t|j�}t|�r-|nd}n|r�t|t�rlt|�dkrlt|�}n||�}|jj	|j�|j
|j�ndS(s"Prepares the given HTTP auth data.iN(R:RR-tanyR8RIRKRt__dict__tupdateR�RW(R2RnR-turl_authtr((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR{�s!cCs_t|tj�r||_nt|�|_t|j|�}|dk	r[||jd<ndS(s$Prepares the given HTTP cookie data.tCookieN(R8Rt	CookieJarRuRRR:RE(R2Rot
cookie_header((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRy�scCs)x"|D]}|j|||�qWdS(sPrepares the given hooks.N(Rf(R2RbRd((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR|�s
N(RYRZRtRpR:RsRqR}RvRwRxRzR�R{RyR|(((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRr�s			
		B		3		tResponsec
BseZdZddddddddd	d
g
Zd�Zd�Zd
�Zd�Zd�Zd�Z	d�Z
ed��Zed��Z
ed��Zded�Zedd�Zed��Zed��Zd�Zed��Zd�Zd�ZRS(shThe :class:`Response <Response>` object, which contains a
    server's response to an HTTP request.
    t_contenttstatus_codeRER-thistorytencodingtreasonRotelapsedtrequestcCs�tt|�j�t|_t|_d|_t�|_	d|_
d|_d|_g|_
d|_ti�|_tjd�|_dS(Ni(tsuperR�RpRhR�t_content_consumedR:R�RREtrawR-R�R�R�RRotdatetimet	timedeltaR�(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRps								cs0�js�jnt�fd��jD��S(Nc3s'|]}|t�|d�fVqdS(N(tgetattrR:(R`tattr(R2(sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pys	<genexpr>6s(R�tcontentR�t	__attrs__(R2((R2sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt__getstate__/s
	
cCsQx*|j�D]\}}t|||�q
Wt|dt�t|dd�dS(NR�R�(RktsetattrR<R:(R2tstateRCR�((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt__setstate__:scCsd|jS(Ns<Response [%s]>(R�(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyRqBscCs|jS(s,Returns true if :attr:`status_code` is 'OK'.(tok(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt__bool__EscCs|jS(s,Returns true if :attr:`status_code` is 'OK'.(R�(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt__nonzero__IscCs
|jd�S(s,Allows you to use a response as an iterator.i�(titer_content(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR6MscCs'y|j�Wntk
r"tSXtS(N(traise_for_statusRRhR<(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR�Qs

cCsd|jko|jtkS(s�True if this Response is a well-formed HTTP redirect that could have
        been processed automatically (by :meth:`Session.resolve_redirects`).
        tlocation(RER�tREDIRECT_STATI(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pytis_redirectYscCstj|j�dS(s6The apparent encoding, provided by the chardet libraryR�(R#tdetectR�(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pytapparent_encoding`sics^��fd�}t�j��}|�}�jr<|n|}|rZt|��}n|S(s�Iterates over the response data.  When stream=True is set on the
        request, this avoids reading the content at once into memory for
        large responses.  The chunk size is the number of bytes it should
        read into memory.  This is not necessarily the length of each item
        returned as decoding can take place.

        If decode_unicode is True, content will be decoded using the best
        available encoding based on the response.
        c3s�ypy,x%�jj�dt�D]}|VqWWn=tk
rP}t|��ntk
rn}t|��nXWn?tk
r�x/tr��jj��}|s�Pn|Vq�WnXt�_	dS(Ntdecode_content(
R�tstreamR<R'RR
RR�R5R�(tchunkte(t
chunk_sizeR2(sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pytgenerateos

	
(RR�R�R(R2R�tdecode_unicodeR�t
reused_chunkst
stream_chunkstchunks((R�R2sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR�es
	ccs�d}x�|jd|d|�D]�}|dk	r>||}n|j�}|r�|dr�|r�|dd|dkr�|j�}nd}x|D]}|Vq�WqW|dk	r�|VndS(s�Iterates over the response data, one line at a time.  When
        stream=True is set on the request, this avoids reading the
        content at once into memory for large responses.
        R�R�i����N(R:R�t
splitlinestpop(R2R�R�tpendingR�tlinestline((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt
iter_lines�s
.

cCs�|jtkr�y^|jr*td��n|jdkrEd|_n't�j|jt	��pft�|_Wq�t
k
r�d|_q�Xnt|_|jS(s"Content of the response, in bytes.s2The content for this response was already consumediN(R�RhR�tRuntimeErrorR�R:R R1R�tCONTENT_CHUNK_SIZER�R<(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR��s	+
	cCs�d}|j}|js"td�S|jdkr=|j}nyt|j|dd�}Wn,ttfk
r�t|jdd�}nX|S(s�Content of the response, in unicode.

        If Response.encoding is None, encoding will be guessed using
        ``chardet``.

        The encoding of the response content is determined based solely on HTTP
        headers, following RFC 2616 to the letter. If you can take advantage of
        non-HTTP knowledge to make a better guess at the encoding, you should
        set ``r.encoding`` appropriately before accessing this property.
        R,terrorstreplaceN(R:R�R�RR�tLookupErrorR�(R2R�R�((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyttext�s		
cKs�|jrtt|j�dkrtt|j�}|dk	rty tj|jj|�|�SWqqtk
rmqqXqtntj|j	|�S(s�Returns the json-encoded content of a response, if any.

        :param \*\*kwargs: Optional arguments that ``json.loads`` takes.
        iN(
R�RKR�RR:R$tloadsRHR�R�(R2tkwargsR�((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR$�s 

cCsj|jjd�}i}|rft|�}x9|D].}|jd�pR|jd�}|||<q1Wn|S(s8Returns the parsed header links of the response, if any.tlinktrelR-(REtgetR(R2theaderR�tlinksR�tkey((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR��s
cCs�d}d|jko dknr>d|j|jf}n8d|jkoXdknrvd|j|jf}n|r�t|d|��ndS(	s2Raises stored :class:`HTTPError`, if one occurred.R,i�i�s%s Client Error: %siXs%s Server Error: %stresponseN(R�R�R(R2thttp_error_msg((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR�scCs
|jj�S(s�Releases the connection back to the pool. Once this method has been
        called the underlying ``raw`` object must not be accessed again.

        *Note: Should not normally need to be called explicitly.*
        (R�trelease_conn(R2((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pytclosesN(RYRZRtR�RpR�R�RqR�R�R6R[R�R�R�RhR�tITER_CHUNK_SIZER:R�R�R�R$R�R�R�(((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyR��s:		(						*&		i((GRtR^R�tioRRRbRt
structuresRRnRRoRRtpackages.urllib3.fieldsRtpackages.urllib3.filepostRtpackages.urllib3.utilR	tpackages.urllib3.exceptionsR
t
exceptionsRRR
RRRtutilsRRRRRRRRRRtcompatRRRRRR R!R"R#R$R%R&R'tstatus_codesR(tmovedtfoundtotherttemporary_movedR�tDEFAULT_REDIRECT_LIMITR�R�tobjectR)R]RjRrR�(((sL/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/models.pyt<module>s6.FXmJ�

Zerion Mini Shell 1.0