ó
    Þ j�H  ã                  ó$  • S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSK	J
r
JrJr  SSKJr  SSKJrJr  SSKJr  \
(       a  SS	K	Jr  SS
KJr  SSKJr  SSKJr  \R4                  " \5      r\R:                  " S5      rSrSS jr  " S S5      r!g)z7
The httplib2 algorithms ported for use with requests.
é    )ÚannotationsN)Úparsedate_tz)ÚTYPE_CHECKINGÚ
CollectionÚMapping)ÚCaseInsensitiveDict)Ú	DictCacheÚSeparateBodyBaseCache)Ú
Serializer)ÚLiteral)ÚPreparedRequest)ÚHTTPResponse)Ú	BaseCachez9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)é-  é4  c                ó‚   • [         R                  U 5      nUc   eUR                  5       nUS   US   US   US   US   4$ )z{Parses a URI using the regex given in Appendix B of RFC 3986.

(scheme, authority, path, query, fragment) = parse_uri(uri)
é   é   é   é   é   )ÚURIÚmatchÚgroups)Úurir   r   s      Ú]/var/www/html/gaurav/venv/lib/python3.13/site-packages/pip/_vendor/cachecontrol/controller.pyÚ	parse_urir   %   sM   € ô
 �I‰I�c‹N€EØÑÐÐØ�\‰\‹^€FØ�1‰I�v˜a‘y &¨¡)¨V°A©Y¸¸q¹	ÐBÐBó    c                  óî   • \ rS rSrSr    S       SS jjr\SS j5       r\SS j5       rSS jr	SS jr
SS	 jrSS
 jr  S           SS jjr  S         SS jjr      SS jrSrg)ÚCacheControlleré0   z4An interface to see if request should cached or not.Nc                óˆ   • Uc
  [        5       OUU l        X l        U=(       d
    [        5       U l        U=(       d    SU l        g )N)éÈ   éË   i,  r   r   )r	   ÚcacheÚcache_etagsr   Ú
serializerÚcacheable_status_codes)Úselfr%   r&   r'   Ústatus_codess        r   Ú__init__ÚCacheController.__init__3   s5   € ð %*¡M”Y”[°uˆŒ
Ø&ÔØ$×4¬
«ˆŒØ&2×&OÐ6OˆÕ#r   c                ó  • [        U5      u  p#pEnU(       a  U(       d  [        SU-  5      eUR                  5       nUR                  5       nU(       d  SnU=(       a    SR                  XE/5      =(       d    UnUS-   U-   U-   nU$ )z4Normalize the URL to create a safe key for the cachez(Only absolute URIs are allowed. uri = %sÚ/Ú?z://)r   Ú	ExceptionÚlowerÚjoin)	Úclsr   ÚschemeÚ	authorityÚpathÚqueryÚfragmentÚrequest_uriÚ
defrag_uris	            r   Ú_urlnormÚCacheController._urlnorm?   s~   € ô 6?¸s³^Ñ2ˆ˜D¨ÞžYÜÐFÈÑLÓMÐMà—‘“ˆØ—O‘OÓ%ˆ	æØˆDð ×7 §¡¨$¨Ó 7×?¸4ˆØ˜e‘^ iÑ/°+Ñ=ˆ
àÐr   c                ó$   • U R                  U5      $ )N)r;   )r3   r   s     r   Ú	cache_urlÚCacheController.cache_urlS   s   € à�|‰|˜CÓ Ð r   c                óÌ  • [         S4[         S4[         S4SSSSSSSS[         S4S.nUR                  SUR                  SS5      5      n0 nUR                  S5       H}  nUR                  5       (       d  M  UR                  S	S
5      nUS   R                  5       n X'   u  p‰U(       a  U	(       d  S XG'   U(       d  Ma   U" US
   R                  5       5      XG'   M     U$ ! [         a    [
        R                  SU5         M¦  f = f! [         a$    U	(       a  [
        R                  SU5         MÔ   M×  [         a&    [
        R                  SUUR                  5         GM  f = f)NTF)NF)úmax-agez	max-staleú	min-freshúno-cacheúno-storezno-transformzonly-if-cachedzmust-revalidateÚpublicÚprivatezproxy-revalidatezs-maxagezcache-controlzCache-ControlÚ Ú,Ú=r   r   z,Ignoring unknown cache-control directive: %sz-Missing value for cache-control directive: %sz8Invalid value for cache-control directive %s, must be %s)
ÚintÚgetÚsplitÚstripÚKeyErrorÚloggerÚdebugÚ
IndexErrorÚ
ValueErrorÚ__name__)
r)   ÚheadersÚknown_directivesÚ
cc_headersÚretvalÚcc_directiveÚpartsÚ	directiveÚtypÚrequireds
             r   Úparse_cache_controlÚ#CacheController.parse_cache_controlW   sg  € ô ˜T�{Ü˜u˜Ü˜t˜Ø%Ø%Ø)Ø+Ø,Ø#Ø$Ø -Ü˜d˜ñ
Ðð  —[‘[ °'·+±+¸oÈrÓ2RÓSˆ
à(*ˆà&×,Ñ,¨SÖ1ˆLØ×%Ñ%×'Ñ'Ùà ×&Ñ& s¨AÓ.ˆEØ˜a™Ÿ™Ó(ˆIðØ 0Ñ ;‘�ö
 žhØ$(�Ñ!ßˆsðÙ(+¨E°!©H¯N©NÓ,<Ó(=�FÓ%ñ# 2ð> ˆøô- ó Ü—‘ÐKÈYÔWÚðûô "ó ÞÜŸ™ØNØ%÷ò  ô
 "ó Ü—L‘LØUØ!ØŸ™÷ð ðús*   ÂC Â?DÃ  DÄDÄ'E#Ä4*E#Å"E#c                ó”  • SUR                   ;   a  gUR                  nUc   eU R                  R                  U5      nUc  [        R                  S5        g[        U R                  [        5      (       a  U R                  R                  U5      nOSnU R                  R                  XU5      nUc  [        R                  S5        U$ )z?
Load a cached response, or return None if it's not available.
ÚRangeNzNo cache entry availablez1Cache entry deserialization failed, entry ignored)rT   Úurlr%   rK   rO   rP   Ú
isinstancer
   Úget_bodyr'   ÚloadsÚwarning)r)   Úrequestr>   Ú
cache_dataÚ	body_fileÚresults         r   Ú_load_from_cacheÚ CacheController._load_from_cache�   s¨   € ð �g—o‘oÓ%Øà—K‘Kˆ	ØÑ$Ð$Ð$Ø—Z‘Z—^‘^ IÓ.ˆ
ØÑÜ�L‰LÐ3Ô4Øä�d—j‘jÔ"7×8Ñ8ØŸ
™
×+Ñ+¨IÓ6‰IàˆIà—‘×&Ñ& w¸IÓFˆØ‰>Ü�N‰NÐNÔOØˆr   c                ó0  • UR                   c   eU R                  UR                   5      n[        R                  SU5        U R	                  UR
                  5      nSU;   a  [        R                  S5        gSU;   a  US   S:X  a  [        R                  S5        gU R                  U5      nU(       d  g[        UR                  5      [        ;   a  S	n[        R                  U5        U$ [        UR
                  5      nU(       a  S
U;  aL  SU;  a0  [        R                  S5        U R                  R                  U5        [        R                  S5        g[        R                  " 5       n[        US
   5      nUc   e[        R                   " USS 5      n	[#        SXy-
  5      n
[        R                  SU
5        U R	                  U5      nSnUR%                  S5      nUb  Un[        R                  SU5        OUSU;   aO  [        US   5      nUb>  [        R                   " USS 5      U	-
  n[#        SU5      n[        R                  SU5        UR%                  S5      nUb  Un[        R                  SU5        UR%                  S5      nUb  U
U-  n
[        R                  SU
5        XÊ:”  a-  [        R                  S5        [        R                  SXÊ5        U$ SU;  a0  [        R                  S5        U R                  R                  U5        g)zM
Return a cached response if it exists in the cache, otherwise
return False.
NzLooking up "%s" in the cacherC   z-Request header has "no-cache", cache bypassedFrA   r   z1Request header has "max_age" as 0, cache bypassedzQReturning cached permanent redirect response (ignoring date and etag information)ÚdateÚetagz(Purging cached response: no date or etagz!Ignoring cached response: no dater   zCurrent age based on date: %iz#Freshness lifetime from max-age: %iÚexpiresz#Freshness lifetime from expires: %iz+Freshness lifetime from request max-age: %irB   z'Adjusted current age from min-fresh: %iz2The response is "fresh", returning cached responsez%i > %iz4The cached response is "stale" with no etag, purging)ra   r>   rO   rP   r]   rT   rj   rJ   ÚstatusÚPERMANENT_REDIRECT_STATUSESr   r%   ÚdeleteÚtimer   ÚcalendarÚtimegmÚmaxrK   )r)   rf   r>   ÚccÚrespÚmsgrT   ÚnowÚ
time_tuplerm   Úcurrent_ageÚresp_ccÚfreshness_lifetimeÚmax_agero   Úexpire_timeÚ	min_freshs                    r   Úcached_requestÚCacheController.cached_request§   sÄ  € ð
 �{‰{Ñ&Ð&Ð&Ø—N‘N 7§;¡;Ó/ˆ	Ü�‰Ð3°YÔ?Ø×%Ñ% g§o¡oÓ6ˆð ˜ÓÜ�L‰LÐHÔIØà˜‹?˜r )™}°Ó1Ü�L‰LÐLÔMØð ×$Ñ$ WÓ-ˆÞØô ˆt�{‰{ÓÔ:Ó:ð7ð ô �L‰L˜ÔØˆKä,?ÀÇÁÓ,MˆÞ˜&¨Ó/Ø˜WÓ$ô —‘ÐGÔHØ—
‘
×!Ñ! )Ô,Ü�L‰LÐ<Ô=Øä�iŠi‹kˆÜ! '¨&¡/Ó2ˆ
ØÑ%Ð%Ð%Ü�Š˜z¨"¨1˜~Ó.ˆÜ˜!˜S™ZÓ(ˆÜ�‰Ð4°kÔBð ×*Ñ*¨7Ó3ˆð Ðð —+‘+˜iÓ(ˆØÑØ!(ÐÜ�L‰LÐ>Ð@RÕSð ˜'Ó!Ü" 7¨9Ñ#5Ó6ˆGØÑ"Ü&Ÿošo¨g°b°q¨kÓ:¸TÑA�Ü%(¨¨KÓ%8Ð"Ü—‘ÐBÐDVÔWð —&‘&˜Ó#ˆØÑØ!(ÐÜ�L‰LØ=Ð?Qôð —F‘F˜;Ó'ˆ	ØÑ à˜9Ñ$ˆKÜ�L‰LÐBÀKÔPð Ó+Ü�L‰LÐMÔNÜ�L‰L˜Ð$6ÔDØˆKð ˜Ó Ü�L‰LÐOÔPØ�J‰J×Ñ˜iÔ(ð r   c                óœ   • U R                  U5      n0 nU(       a1  [        UR                  5      nSU;   a  US   US'   SU;   a  US   US'   U$ )Nrn   ÚETagzIf-None-Matchzlast-modifiedzLast-ModifiedzIf-Modified-Since)rj   r   rT   )r)   rf   rx   Únew_headersrT   s        r   Úconditional_headersÚ#CacheController.conditional_headers  s\   € Ø×$Ñ$ WÓ-ˆØˆæÜ0CÀDÇLÁLÓ0QˆGà˜Ó Ø/6°v©�˜OÑ,à 'Ó)Ø3:¸?Ñ3K�Ð/Ñ0àÐr   c                óV  • [        U R                  [        5      (       aU  U R                  R                  UU R                  R                  X#S5      US9  Ub  U R                  R                  X5        ggU R                  R                  UU R                  R                  X#U5      US9  g)z
Store the data in the cache.
r   )ro   N)rb   r%   r
   Úsetr'   ÚdumpsÚset_body)r)   r>   rf   ÚresponseÚbodyÚexpires_times         r   Ú
_cache_setÚCacheController._cache_set$  s—   € ô �d—j‘jÔ"7×8Ñ8ð �J‰J�N‰NØØ—‘×%Ñ% g¸Ó=Ø$ð ñ ð ÑØ—
‘
×#Ñ# IÕ4ð  ð �J‰J�N‰NØØ—‘×%Ñ% g¸Ó>Ø$ð ò r   c                óÐ  • U=(       d    U R                   nUR                  U;  a"  [        R                  SUR                  U5        g[	        UR
                  5      nSU;   a-  [        US   5      nUc   e[        R                  " USS 5      nOSnUb:  SU;   a4  US   R                  5       (       a  [        US   5      [        U5      :w  a  gU R                  UR
                  5      n	U R                  U5      n
UR                  c   eU R                  UR                  5      n[        R                  SU5        SnS	U
;   a  S
n[        R                  S5        S	U	;   a  S
n[        R                  S5        U(       aP  U R                  R!                  U5      (       a0  [        R                  S5        U R                  R#                  U5        U(       a  gSUR!                  SS5      ;   a  [        R                  S5        gU R$                  (       a™  SU;   a“  SnUR!                  S5      (       a-  [        US   5      nUb  [        R                  " USS 5      U-
  n['        US5      n[        R                  SU S35        [        R                  S5        U R)                  X±X#U5        g[        UR                  5      [*        ;   a)  [        R                  S5        U R)                  X±US5        gSU;   aï  [        US   5      nUc   e[        R                  " USS 5      nU
R!                  S5      nUb3  US:”  a-  [        R                  S5        UnU R)                  UUUUU5        gSU;   au  US   (       aj  [        US   5      nUb  [        R                  " USS 5      U-
  nOSn[        R                  SR-                  U5      5        U R)                  UUUUU5        gggg)zK
Algorithm for caching requests.

This assumes a requests Response object.
zStatus code %s not in %sNrm   r   r   úcontent-lengthz&Updating cache with response from "%s"FrD   TzResponse header has "no-store"zRequest header has "no-store"z0Purging existing cache entry to honor "no-store"Ú*ÚvaryrG   zResponse header has "Vary: *"rn   ro   i u zetag object cached for z secondszCaching due to etagzCaching permanent redirectr   rA   z'Caching b/c date exists and max-age > 0z4Caching b/c of expires header. expires in {} seconds)r(   rp   rO   rP   r   rT   r   rt   ru   ÚisdigitrJ   Úlenr]   ra   r>   r%   rK   rr   r&   rv   r�   rq   Úformat)r)   rf   r�   rŽ   r*   r(   Úresponse_headersr{   rm   Úcc_reqrw   r>   Úno_storer�   ro   r   s                   r   Úcache_responseÚCacheController.cache_responseB  s¡  € ð ".×!L°×1LÑ1LÐØ�?‰?Ð"8Ó8Ü�L‰LØ*¨H¯O©OÐ=Sôð ä5HØ×Ñó6
Ðð Ð%Ó%Ü%Ð&6°vÑ&>Ó?ˆJØÑ)Ð)Ð)Ü—?’? :¨b¨q >Ó2‰DàˆDð ÑØ Ð$4Ó4Ø Ð!1Ñ2×:Ñ:×<Ñ<ÜÐ$Ð%5Ñ6Ó7¼3¸t»9ÓDàà×)Ñ)¨'¯/©/Ó:ˆØ×%Ñ%Ð&6Ó7ˆà�{‰{Ñ&Ð&Ð&Ø—N‘N 7§;¡;Ó/ˆ	Ü�‰Ð=¸yÔIð ˆØ˜ÓØˆHÜ�L‰LÐ9Ô:Ø˜ÓØˆHÜ�L‰LÐ8Ô9Þ˜Ÿ
™
Ÿ™ y×1Ñ1Ü�L‰LÐKÔLØ�J‰J×Ñ˜iÔ(ÞØð Ð"×&Ñ& v¨rÓ2Ó2Ü�L‰LÐ8Ô9Øð ×× Ð*:Ó :ØˆLØ×#Ñ# I×.Ñ.Ü&Ð'7¸	Ñ'BÓC�ØÑ&Ü#+§?¢?°7¸2¸A°;Ó#?À$Ñ#F�Lä˜|¨ZÓ8ˆLä�L‰LÐ2°<°.ÀÐIÔJÜ�L‰LÐ.Ô/Ø�O‰O˜I°ÀÕMô �—‘Ó!Ô%@Ó@Ü�L‰LÐ5Ô6Ø�O‰O˜I°¸#Õ>ð
 Ð'Ó'Ü%Ð&6°vÑ&>Ó?ˆJØÑ)Ð)Ð)Ü—?’? :¨b¨q >Ó2ˆDà—f‘f˜YÓ'ˆGØÑ" w°£{Ü—‘ÐFÔGØ&�Ø—‘ØØØØØ õð Ð.Ó.Ø# I×.Ü*Ð+;¸IÑ+FÓG�GØÑ*Ü'/§¢°w¸rÀ°{Ó'CÀdÑ'J™à'+˜ä—L‘LØN×UÑUØ(óôð
 —O‘OØ!ØØ ØØ$õð /ð /ð' (r   c                óŒ  • UR                   c   eU R                  UR                   5      nU R                  U5      nU(       d  U$ S/nUR                  R	                  UR                  R                  5        VVs0 sH  u  pgUR                  5       U;  d  M  Xg_M     snn5        SUl        U R                  X1U5        U$ s  snnf )zÉ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.
r“   r#   )	ra   r>   rj   rT   ÚupdateÚitemsr1   rp   r�   )r)   rf   r�   r>   Úcached_responseÚexcluded_headersÚkÚvs           r   Úupdate_cached_responseÚ&CacheController.update_cached_responseË  sÃ   € ð �{‰{Ñ&Ð&Ð&Ø—N‘N 7§;¡;Ó/ˆ	Ø×/Ñ/°Ó8ˆæàˆOð -Ð-Ðà×Ñ×&Ñ&ð %×,Ñ,×2Ñ2Ô4ôá4‘D�AØ—7‘7“9Ð$4Ñ4ó �’Ù4òô	
ð "%ˆÔð 	�‰˜	¨OÔ<àÐùós   Á:C 
ÂC 
)r%   r&   r(   r'   )NTNN)r%   zBaseCache | Noner&   Úboolr'   zSerializer | Noner*   úCollection[int] | None)r   ÚstrÚreturnr©   )rT   zMapping[str, str]rª   zdict[str, int | None])rf   r   rª   zHTTPResponse | None)rf   r   rª   zHTTPResponse | Literal[False])rf   r   rª   zdict[str, str])NN)r>   r©   rf   r   r�   r   rŽ   úbytes | Noner�   z
int | Nonerª   ÚNone)
rf   r   r�   r   rŽ   r«   r*   r¨   rª   r¬   )rf   r   r�   r   rª   r   )rS   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r+   Úclassmethodr;   r>   r]   rj   r‚   r‡   r�   rœ   r¥   Ú__static_attributes__© r   r   r    r    0   s+  † Ù>ð #'Ø Ø(,Ø/3ð
Pàð
Pð ð
Pð &ð	
Pð
 -õ
Pð óó ðð& ó!ó ð!ô4ôlô4lô\ð( "Ø#'ðàðð !ðð ð	ð
 ðð !ðð 
õðD "Ø/3ðGà ðGð ðGð ð	Gð
 -ðGð 
õGðR(Ø&ð(Ø2>ð(à	÷(r   r    )r   r©   rª   ztuple[str, str, str, str, str])"r°   Ú
__future__r   rt   ÚloggingÚrers   Úemail.utilsr   Útypingr   r   r   Úpip._vendor.requests.structuresr   Úpip._vendor.cachecontrol.cacher	   r
   Ú"pip._vendor.cachecontrol.serializer   r   Úpip._vendor.requestsr   Úpip._vendor.urllib3r   r   Ú	getLoggerrS   rO   Úcompiler   rq   r   r    r³   r   r   Ú<module>rÀ      ss   ðñ
õ #ã Û Û 	Û Ý $ß 5Ñ 5å ?ç KÝ 9æÝå4Ý0å8à	×	Ò	˜8Ó	$€à‡j‚jÐMÓN€à(Ð ôC÷Cò Cr   