Hacked By AnonymousFox

Current Path : /lib/python2.7/site-packages/pip/_vendor/cachecontrol/
Upload File :
Current File : //lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pyc

�
��abc@s�dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZej
e�Zejd�Zd	�Zd
efd��YZdS(s7
The httplib2 algorithms ported for use with requests.
i����N(tparsedate_tz(tCaseInsensitiveDicti(t	DictCache(t
Serializers9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?cCs<tj|�j�}|d|d|d|d|dfS(s�Parses a URI using the regex given in Appendix B of RFC 3986.

        (scheme, authority, path, query, fragment) = parse_uri(uri)
    iiiii(tURItmatchtgroups(turiR((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pyt	parse_uristCacheControllercBsneZdZd	ed	d�Zed��Zed��Zd�Z	d�Z
d�Zd	d�Zd�Z
RS(
s9An interface to see if request should cached or not.
    cCs1|pt�|_||_|p't�|_dS(N(Rtcachetcache_etagsRt
serializer(tselfR
RR((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pyt__init__!s	c	Cs�t|�\}}}}}|s)|r<td|��n|j�}|j�}|scd}n|r~dj||g�p�|}|d||}|S(s4Normalize the URL to create a safe key for the caches(Only absolute URIs are allowed. uri = %st/t?s://(Rt	Exceptiontlowertjoin(	tclsRtschemet	authoritytpathtquerytfragmenttrequest_urit
defrag_uri((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pyt_urlnorm&s	!cCs
|j|�S(N(R(RR((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pyt	cache_url:sc
Cs�i}d}d|kr!d}n||kr�||jd�}g|D]R}d|jd�krGtg|jdd�D]}|j�j�^qx�^qG}g|D]3}d|jd�kr�|j�j�df^q�}	t||	�}n|S(sz
        Parse the cache control headers returning a dictionary with values
        for the different directives.
        s
cache-controls
Cache-Controlt,i����t=i(tsplittfindttupletstripRtdict(
R
theaderstretvalt	cc_headertpartstparttxtparts_with_argstnamet
parts_wo_args((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pytparse_cache_control>s	\=cCs^|j|j�}tjd|�|j|j�}d|krQtjd�tSd|kr~|ddkr~tjd�tS|jj|�}|dkr�tjd�tS|j
j||�}|s�tjd�tS|j
d	kr�d
}tj|�|St|j�}|s!d|kr^d|krMtjd
�|jj|�ntjd�tStj�}tjt|d��}	td||	�}
tjd|
�|j|�}d}d|kr�|dj�r�t|d�}tjd|�n`d|krZt|d�}
|
dk	rZtj|
�|	}td|�}tjd|�qZnd|kr�y$t|d�}tjd|�Wq�tk
r�d}q�Xnd|kr�yt|d�}Wntk
r�d}nX|
|7}
tjd|
�n||
kr.tjd�tjd||
�|Sd|krZtjd�|jj|�ntS(se
        Return a cached response if it exists in the cache, otherwise
        return False.
        sLooking up "%s" in the cachesno-caches-Request header has "no-cache", cache bypassedsmax-ageis1Request header has "max_age" as 0, cache bypassedsNo cache entry availables1Cache entry deserialization failed, entry ignoredi-sVReturning cached "301 Moved Permanently" response (ignoring date and etag information)tdatetetags(Purging cached response: no date or etags!Ignoring cached response: no datesCurrent age based on date: %is#Freshness lifetime from max-age: %itexpiress#Freshness lifetime from expires: %is+Freshness lifetime from request max-age: %is	min-freshs'Adjusted current age from min-fresh: %is2The response is "fresh", returning cached responses%i > %is4The cached response is "stale" with no etag, purgingN(RturltloggertdebugR.R%tFalseR
tgettNoneRtloadstwarningtstatusRtdeletettimetcalendarttimegmRtmaxtisdigittintt
ValueError(R
trequestRtcct
cache_datatresptmsgR%tnowR/tcurrent_agetresp_cctfreshness_lifetimeR1texpire_timet	min_fresh((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pytcached_requestVs�







	
	
	




	

cCs�|j|j�}|jj||jj|��}i}|r�t|j�}d|krk|d|d<nd|kr�|d|d<q�n|S(NR0tETags
If-None-Matchs
last-modifieds
Last-ModifiedsIf-Modified-Since(RR2RR8R
R6RR%(R
RCRRFtnew_headersR%((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pytconditional_headers�s!c
Cs�ddddg}|j|kr;tjd|j|�dSt|j�}|dk	r�d|kr�|dj�r�t|d�t|�kr�dS|j	|j�}|j	|�}|j
|j�}tjd|�t}	|j
d	�rt}	tjd
�n|j
d	�r%t}	tjd�n|	r]|jj
|�r]tjd�|jj|�n|jr�d
|kr�tjd�|jj||jj||d|��n|jdkr�tjd�|jj||jj||��n�d|kr�|rm|j
d�rm|dj�r�t|d�dkr�tjd�|jj||jj||d|��q�q�d|kr�|dr�tjd�|jj||jj||d|��q�q�ndS(sc
        Algorithm for caching requests.

        This assumes a requests Response object.
        i�i�i,i-sStatus code %s not in %sNscontent-lengths&Updating cache with response from "%s"sno-storesResponse header has "no-store"sRequest header has "no-store"s0Purging existing cache entry to honor "no-store"R0sCaching due to etagtbodysCaching permanant redirectR/smax-ageis'Caching b/c date exists and max-age > 0R1sCaching b/c of expires header(R:R3R4RR%R7R@RAtlenR.RR2R5R6tTrueR
R;RtsetRtdumps(
R
RCtresponseRRtcacheable_status_codestresponse_headerstcc_reqRDRtno_store((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pytcache_response�sd

	
	&
	"

	cs�|j|j�}|jj||jj|��}|s=|Sdg�|jjt�fd�|jj	�D���d|_
|jj||jj||��|S(s�On a 304 we will get a new set of headers that we want to
        update our cached value with, assuming we have one.

        This should only ever be called when we've sent an ETag and
        gotten a 304 as the response.
        scontent-lengthc3s3|])\}}|j��kr||fVqdS(N(R(t.0tktv(texcluded_headers(sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pys	<genexpr>Ts	i�(
RR2RR8R
R6R%tupdateR$titemsR:RURV(R
RCRWRtcached_response((R`sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pytupdate_cached_response6s	
		&		N(t__name__t
__module__t__doc__R7RTRtclassmethodRRR.RNRQR\Rd(((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pyR	s		y	W(RgtloggingtreR=R<temail.utilsRtpip._vendor.requests.structuresRR
Rt	serializeRt	getLoggerReR3tcompileRRtobjectR	(((sG/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.pyt<module>s		

Hacked By AnonymousFox1.0, Coded By AnonymousFox