+
    :1jNo                    "   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
Ht ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHtHt ^ R
IHt ^RIHt ^RIH t H!t!H"t"H#t#H$t$ ]PJ                  ! ]&4      t']'       d!   ^ RI(H)t)H*t*H+t+ ^ RI,H-t- ^ RIH.t. ^RI
H/t/H0t0H1t1 R't2 ! R R4      t3R(]$^3R R llt4 ! R R]Pj                  4      t6 ! R R]64      t7R R lt8 ! R R]64      t9R R lt:R R  lt;R! R" lt<R# R$ lt=R% R& lt>R# ))zZ
Models for sharded repodata, and to make monolithic repodata look like sharded
repodata.
)annotationsN)defaultdict)TYPE_CHECKING)REPODATA_SHARDS_FN)context)
SubdirData)get_session)_add_http_value_to_dictconda_http_errors)Channel)cache)_is_http_error_most_400_codes_safe_urljoin_with_slash_shards_connectionsensure_hex_hashspec_to_package_name)IterableKeysViewSequence)Response)RepodataCache)RepodataDict	ShardDictShardsIndexDictc                  j    ] tR t^?tRtRR R lltR R ltR R ltR	 R
 ltR t	]
R R l4       tRtR# )
ShardFetcha,  
Wrapper class that encapsulates fetching and caching of individual shards.

Handles deferred fetching: shards can be requested via this class but will
only be actually retrieved from the network when fetch() is called.
This allows batching and coordinating shard retrieval across multiple channels.
Nc               $    V ^8  d   QhRRRRRR/# )   	shardbase	ShardBasepackagestrshard_cachezcache.ShardCache | None )formats   "<lib/python3.14/site-packages/conda/_private/shards/shards.py__annotate__ShardFetch.__annotate__H   s(        -	    c                r    Wn         W n        VP                  V4      V n        W0n        RV n        RV n        R# )z
Initialize a ShardFetch wrapper.

Args:
    shardbase: The ShardBase (Shards or ShardLike) instance
    package: The package name to fetch
    shard_cache: Optional cache to use for storage (required for Shards)
NF)r   r    	shard_urlurlr"   _shard_fetched)selfr   r    r"   s   &&&&r%   __init__ShardFetch.__init__H   s4     #&&w/&(,r(   c                   V ^8  d   QhRR/# r   returnr   r#   )r$   s   "r%   r&   r'   ]   s      y r(   c                   V P                   '       gh   \        V P                  \        4      '       d   V P	                  4       V n        M*V P                  P                  V P                  4      V n        RV n         V P
                  # )z
Fetch the shard from the network or return cached result.

For Shards, performs the actual network fetch.
For ShardLike, returns the shard immediately since it's in memory.
T)r-   
isinstancer   Shards_fetch_from_shardsr,   visit_packager    r.   s   &r%   fetchShardFetch.fetch]   sY     }}}$..&11"557"nn::4<<H DM{{r(   c                   V ^8  d   QhRR/# r2   r#   )r$   s   "r%   r&   r'   l   s     E EI Er(   c                \    V P                  V P                  .4      V P                  ,          # )z.
Fetch a single shard from a Shards instance.
)_fetch_shards_implr    r9   s   &r%   r7   ShardFetch._fetch_from_shardsl   s$     &&~6t||DDr(   c                    V ^8  d   QhRRRR/# )r   packagesIterable[str]r3   zdict[str, ShardDict]r#   )r$   s   "r%   r&   r'   r   s     . .= .=Q .r(   c                    V P                   p/ pR p\        \        V4      4      p/ pV F=  pWbP                  9   d   VP                  V,          W6&   K*  WeVP	                  V4      &   K?  	  \
        P                  P                  \        4       R7      ;_uu_ 4       pVP                  4        UUu/ uF+  w  rWc9  g   K  VP                  WBP                  W4      W3bK-  	  p	pp\
        P                  P                  V	4       F<  p
\        P                  RW,          4       W,          w  rV P                  WWcV4       K>  	  RRR4       VP                  P!                  V4       V# u uppi   + '       g   i     L3; i)z
Fetch multiple shards for a Shards instance.

Implements the core fetching logic for Shards, handling network requests,
caching, and decompression.
c                    \         P                  \         P                  3pV P                  WR 7      pVP	                  4        VP
                  p\        P                  ! WVR7      # ))timeout)r+   r    compressed_shard)r   remote_connect_timeout_secsremote_read_timeout_secsgetraise_for_statuscontentr   AnnotatedRawShard)sr+   package_to_fetchrE   responsedatas   &&&   r%   r:   ,ShardFetch._fetch_shards_impl.<locals>.fetch|   s\    3300G uuSu2H%%'##D**D r(   max_workersz. %sN)r   sortedlistvisitedr*   
concurrentfuturesThreadPoolExecutorr   itemssubmitsessionas_completedlogdebug_process_fetch_resultupdate)r.   rA   shardsresultsr:   urls_packagesr    executorr+   rX   futures   &&         r%   r>   ShardFetch._fetch_shards_implr   sP    	 $x.)G..(#)>>'#: ;Bf..w78	   22+- 3 
 
 %2$7$7$9$9LC) U~~sDsnT$9  
 %,,99'B		&'/2&**6&Q C
 	g&
 
s%   E-/
E'
>"E'
 A"E-'E--E=	c                x   V P                   f   \        R4      h\        W#4      ;_uu_ 4        VP                  4       pRRR4       \        P
                  ! \        P                  ! XP                  \        R7      4      WFP                  &   V P                   P                  V4       R#   + '       g   i     Ls; i)z(
Process a single fetched shard result.
Nz0shard_cache is required for fetching from Shardsmax_output_size)r"   
ValueErrorr
   resultmsgpackloads	zstandard
decompressrF   ZSTD_MAX_SHARD_SIZEr    insert)r.   rf   r+   r    rc   rb   fetch_results   &&&&&& r%   r`    ShardFetch._process_fetch_result   s    
 #OPPs,,!==?L - )0  --?R)
$$%
 	- -,s   B))B9	c                    V ^8  d   QhRRRR/# )r   shard_fetcheszIterable[ShardFetch]r3   Noner#   )r$   s   "r%   r&   r'      s     0 0#7 0D 0r(   c                   \        \        4      p/ pV  FH  pWP                  ,          P                  VP                  4       VW#P                  VP                  3&   KJ  	  VP                  4        Fo  w  rE\        V\        4      '       g   K  W$V^ ,          3,          pVP                  V4      pVP                  4        F  w  rW$V3,          pWn	        RVn
        K  	  Kq  	  R# )z
Batch fetch multiple ShardFetch objects, grouping by ShardBase.

This efficiently fetches shards from multiple sources by grouping
requests by their ShardBase instance and making coordinated network calls.
TN)r   rU   r   appendr    rZ   r5   r6   r>   r,   r-   )
rv   shard_packagesshard_fetches_by_pkgshard_fetchr   rA   first_fetchfetchedr    shards
   &         r%   fetch_batchShardFetch.fetch_batch   s     6A5FHJ(K001889L9LM !"7"79L9L!MN ) $2#7#7#9I)V,,2x{3KL%88B '.mmoNG"677K"LK).&+/K( '6 $:r(   )r-   r,   r    r"   r   r+   N)__name__
__module____qualname____firstlineno____doc__r/   r:   r7   r>   r`   staticmethodr   __static_attributes__r#   r(   r%   r   r   ?   s6    *E.`.& 0 0r(   r   c               (    V ^8  d   QhRRRRRRRR/# )r   r   r   extrarB   repodata_versionintr3   r#   )r$   s   "r%   r&   r&      s0       	
 r(   c              #    aa"   \        4       oVV3R lpV R,          P                  4        F  pV! V4       Rj  xL
  K  	  V R,          P                  4        F  pV! V4       Rj  xL
  K  	  V^8  dX   V P                  R4      ;p'       d?   VP                  4        F*  pVP                  4        F  pV! V4       Rj  xL
  K  	  K,  	  T Rj  xL
  R#  L Lt L L5i)z_
Return all dependency names mentioned in a shard, not including the shard's
own package name.
c              3     <"   \        V 4       V P                  R R4       F/  pVS9  g   K  SP                  V4       S! V4      pVf   K+  Vx  K1  	  R# 5i)dependsNr#   )r   rI   add)recordspecnamer   unique_specss   &  r%   _yield_record/shard_mentioned_packages.<locals>._yield_record   sN     JJy"-D<'  &+D1#J .s   %AA
ArA   Npackages.condav3)setvaluesrI   )	r   r   r   r   r   r   v3_datagroupr   s	   &&f&    @r%   shard_mentioned_packagesr      s      !UL 
#**, ((( -()002 ((( 31UYYt_"<'"<^^%E,,.(000 ) &  	)( 1sK   7C$C-C$)C*'C$1C$C C$C"C$C$ C$"C$c                     ] tR t^t$ RtR]R&   R]R&   R]R&   R]R&   ]]P                  R	 R
 l4       4       t	]R R l4       t
R R lt]P                  R R l4       t]P                  R R l4       tR R ltR R ltR R ltR R ltRtR# )r   z
Abstract base class for shard-like objects.

Defines the common interface for both sharded repodata (Shards)
and monolithic repodata presented as shards (ShardLike).
r!   r+   r   repodata_no_packageszdict[str, ShardDict | None]rV   	_base_urlc                   V ^8  d   QhRR/# r   r3   zKeysView[str]r#   )r$   s   "r%   r&   ShardBase.__annotate__  s      } r(   c                    R# )zDReturn the names of all packages available in this shard collection.Nr#   r9   s   &r%   package_namesShardBase.package_names       	r(   c                   V ^8  d   QhRR/# r   r3   r!   r#   )r$   s   "r%   r&   r   	  s     B B# Br(   c                B    \        V P                  V P                  4      # )z
Return self.url joined with base_url from repodata, or self.url if no
base_url was present. Packages are found here.

Note base_url can be a relative or an absolute url.
Uses _safe_urljoin_with_slash to handle non-HTTP schemes (s3://, etc.).
)r   r+   r   r9   s   &r%   base_urlShardBase.base_url  s     ($..AAr(   c                    V ^8  d   QhRRRR/# r   r    r!   r3   boolr#   )r$   s   "r%   r&   r     s     - -C -D -r(   c                    WP                   9   # )z9Check if a package is available in this shard collection.)r   r.   r    s   &&r%   __contains__ShardBase.__contains__  s    ,,,,r(   c                    V ^8  d   QhRRRR/# r   r    r!   r3   r#   )r$   s   "r%   r&   r     s        r(   c                    R# )z
Return shard URL for a given package. For monolithic repodata, should
not be fetched but is a unique identifier.

Raise KeyError if package is not in the index.
Nr#   r   s   &&r%   r*   ShardBase.shard_url  s     	r(   c                    V ^8  d   QhRRRR/# r   r#   )r$   s   "r%   r&   r   "  s      C D r(   c                    R# )8
Return True if the given package's shard is in memory.
Nr#   r   s   &&r%   shard_loadedShardBase.shard_loaded!  s    
 	r(   c                    V ^8  d   QhRRRR/# r   r    r!   r3   r   r#   )r$   s   "r%   r&   r   (  s      S Y r(   c                    R# )zF
Return a shard that is already loaded in memory and mark as visited.
Nr#   r   s   &&r%   r8   ShardBase.visit_package(  r   r(   c                    V ^8  d   QhRRRR/# )r   r    r!   r   r   r#   )r$   s   "r%   r&   r   .  s     & &3 &y &r(   c                "    W P                   V&   R# )z+
Store new shard data in the visited dict.
NrV   r.   r    r   s   &&&r%   visit_shardShardBase.visit_shard.  s     !&Wr(   c                   V ^8  d   QhRR/# )r   r3   r   r#   )r$   s   "r%   r&   r   4  s       r(   c                    / V P                   CR/ R/ /CpV P                  P                  4        F1  w  r#Vf   K  R F   pW,          P                  W4,          4       K"  	  K3  	  V# )zc
Return monolithic repodata including all visited shards.

Prefer iter_records() over this method.
rA   r   rA   r   )r   rV   rZ   ra   )r.   repodata_r   package_groups   &    r%   build_repodataShardBase.build_repodata4  so    "
''"
b"

 **,HA}!?'..u/CD "@ -
 r(   c                   V ^8  d   QhRR/# )r   r3   zIterable[tuple[str, dict]]r#   )r$   s   "r%   r&   r   F  s     ) )8 )r(   c              #  d  "   V P                  4       pR F+  pVP                  V/ 4      P                  4        Rj  xL
  K-  	  V P                  P	                  4        FH  pVf   K	  VP                  R/ 4      P	                  4        F  pVP                  4        Rj  xL
  K  	  KJ  	  R#  Lp L5i)zE
Yield (filename, record) tuples for all packages in visited shards.
Nr   r   )r   rI   rZ   rV   r   )r.   r   r   r   r   s   &    r%   iter_recordsShardBase.iter_recordsF  s      &&(;M||M26<<>>> <\\((*E}4,335 ;;=(( 6 + ?
 )s"   9B0B,A!B0B.B0.B0r#   N)r   r   r   r   r   __annotations__propertyabcabstractmethodr   r   r   r*   r   r8   r   r   r   r   r#   r(   r%   r   r      s     
H&&((N   B B- 	  	 &$) )r(   r   c                  v   a  ] tR tRtRtRR R lltV 3R lt]R R l4       tR R	 lt	R
 R lt
R R ltRtV ;t# )	ShardLikeiT  z:
Present a "classic" repodata.json as per-package shards.
c                    V ^8  d   QhRRRR/# )r   r   r   r+   r!   r#   )r$   s   "r%   r&   ShardLike.__annotate__Y  s     '  '  ' C ' r(   c                N   / VCR/ R/ /CV n         RVP                  R/ 4      RVP                  R/ 4      /pW n        \        R 4      pVP	                  4        F9  w  rVVP	                  4        F   w  rxVR,          p	WV	,          V,          V&   K"  	  K;  	  \        V4      V n        / V n         V P                   R,          R,          p
\        V
\        4      '       g*   \        P                  R\        V
4      4       \        4       hWn        R	#   \         d    RT n         R	# i ; i)
z6
url: must be unique for all ShardLike used together.
rA   r   c                     R / R/ /# r   r#   r#   r(   r%   <lambda>$ShardLike.__init__.<locals>.<lambda>h  s    j"6F%Kr(   r   infor   z2repodata["info"]["base_url"] was not str(), got %s N)r   rI   r+   r   rZ   dictrb   rV   r5   r!   r^   warningtype	TypeErrorr   KeyError)r.   r   r+   all_packagesrb   
group_namer   r    r   r   r   s   &&&        r%   r/   ShardLike.__init__Y  s   3
3
b3
! Z4hll+;R@
 KL!-!3!3!5J#(;;=f~4:tZ(1 $1 "6 -1L 57
	 008DHh,,HN  k!%N 	 DN	 s   -AD D$#D$c                	l   < \         SV `  4       P                  ^R7      w  rV RV P                   RV 2# )   )maxsplit )super__repr__splitr+   )r.   leftright	__class__s   &  r%   r   ShardLike.__repr__  s;    g&(...:q
!E7++r(   c                   V ^8  d   QhRR/# r   r#   )r$   s   "r%   r&   r     s     " "} "r(   c                	6    V P                   P                  4       # r   )rb   keysr9   s   &r%   r   ShardLike.package_names  s    {{!!r(   c                    V ^8  d   QhRRRR/# r   r#   )r$   s   "r%   r&   r     s     ' ' ' 'r(   c                J    V P                   V,           V P                   RV 2# )W
Return shard URL for a given package.

Raise KeyError if package is not in the index.
#)rb   r+   r   s   &&r%   r*   ShardLike.shard_url  s%     	G((1WI&&r(   c                    V ^8  d   QhRRRR/# r   r#   )r$   s   "r%   r&   r     s     & &C &D &r(   c                    WP                   9   # r   rb   r   s   &&r%   r   ShardLike.shard_loaded  s     ++%%r(   c                    V ^8  d   QhRRRR/# r   r#   )r$   s   "r%   r&   r     s      S Y r(   c                l    V P                   V,          pV P                   V,          V P                  V&   V# z?
Return a shard that is already in memory and mark as visited.
)rb   rV   r   s   && r%   r8   ShardLike.visit_package  s.     G$ $G 4Wr(   )r   r   rb   r+   rV   )r   )r   r   r   r   r   r/   r   r   r   r*   r   r8   r   __classcell__)r   s   @r%   r   r   T  s;    ' R, " "'& r(   r   c                   V ^8  d   QhRR/# r   r#   )r$   s   "r%   r&   r&     s     : :c :r(   c                h    V'       d!   VP                  R4      '       g
   VR,          p\        W4      # )z
Return shards_base_url joined with base_url and url.
Note shards_base_url can be a relative or an absolute url.
Uses _safe_urljoin_with_slash to handle non-HTTP schemes (s3://, etc.).
/)endswithr   )r+   shards_base_urls   &&r%   _shards_base_urlr    s,     77<<3#C99r(   c                      ] tR tRt$ RtR]R&   R R lt]R 4       t]R 4       t	]R	 R
 l4       t
R R ltR R ltR R ltRtR# )r6   i  zG
Handle repodata_shards.msgpack.zst and individual per-package shards.
r!   r  c                    V ^8  d   QhRRRR/# )r   shards_indexr   r+   r!   r#   )r$   s   "r%   r&   Shards.__annotate__  s     '3 '3%'3 '3r(   c                f   Wn         W n        VR,          R,          V n        \        V P                  V P                   R,          P	                  RR4      4      V n        \        V P                  4      P                  p\        V4      V n	        RVR,          R/ R/ R^/V n
        / V n        / V n        R# )	z
Args:
    shards_index: raw parsed msgpack dict. Don't change it or base_url,
    shards_base_url will be wrong.
    url: URL of repodata_shards.msgpack.zst
r   r   r  r   rA   r   r   N)r  r+   r   r  rI   r   r  r   r   r\   r   rV   _shard_url_cache)r.   r  r+   channel_base_urls   &&& r%   r/   Shards.__init__  s     )
 &f-j9 !1HHd''/334ErJ!

 #4#7#78AA"#34 L(b	%
! 5702r(   c                	6    V P                   P                  4       # r   )packages_indexr   r9   s   &r%   r   Shards.package_names  s    ""''))r(   c                	(    V P                   R ,          # r  )r  r9   s   &r%   r  Shards.packages_index  s      **r(   c                   V ^8  d   QhRR/# r   r#   )r$   s   "r%   r&   r    s     % % %r(   c                    V P                   # )zi
Return self.url joined with shards_base_url.
Note shards_base_url can be a relative or an absolute url.
)r  r9   s   &r%   r  Shards.shards_base_url  s     $$$r(   c                    V ^8  d   QhRRRR/# r   r#   )r$   s   "r%   r&   r    s        r(   c                    V P                   P                  V4      ;p'       d   V# \        V P                  V,          4      P	                  4        R2pV P
                   V 2pW@P                   V&   V# )r   z.msgpack.zst)r  rI   bytesr  hexr  )r.   r    cached
shard_namer+   s   &&   r%   r*   Shards.shard_url  ss     **..w7767Md11':;??AB,O
%%&zl3),g&
r(   c                    V ^8  d   QhRRRR/# r   r#   )r$   s   "r%   r&   r    s     ' 'C 'D 'r(   c                    WP                   9   # r   r   r   s   &&r%   r   Shards.shard_loaded  s     ,,&&r(   c                    V ^8  d   QhRRRR/# r   r#   )r$   s   "r%   r&   r    s      S Y r(   c                ,    V P                   V,          pV# r  r   r   s   && r%   r8   Shards.visit_package  s     W%r(   )r   r  r  r   r\   r  r+   rV   N)r   r   r   r   r   r   r/   r   r   r  r  r*   r   r8   r   r#   r(   r%   r6   r6     se     '3R * * + + % %' r(   r6   c                    V ^8  d   QhRRRR/# )r   r   r   r3   r   r#   )r$   s   "r%   r&   r&   	  s     F F F5 Fr(   c           	        \         P                  '       dg   VP                  P                  4       '       d   VP                  P	                  4       # \
        P                  P                  P                  V RRR7      h\        V 4      pVP                  p/ pVP                  pVP                  pV'       d   \        V4      VR&   V'       d   \        V4      VR&   \        V \        4      ;_uu_ 4        \         P                   \         P"                  3pVP%                  WVP&                  VR7      pVP)                  4        VP*                  p	RRR4       XP,                  R8X  d@   VP.                  ! R4      ;_uu_ 4        VP                  P	                  4       uuRRR4       # \
        P                  P                  P0                  V /p
R	\
        P                  P                  P2                  3R
\
        P                  P                  P4                  3R\
        P                  P                  P6                  33 F  w  r\9        WW4       K  	  VP;                  V
4       X	#   + '       g   i     EL ; i  + '       g   i     L; i)z
Fetch shards index with cache.

Update cache state.

Return shards data, either newly fetched or from cache.

In offline mode, returns cached data even if expired. If no cache exists
in offline mode, raises RepodataIsEmpty to signal unavailability.
i  N)status_coderO   zIf-None-MatchzIf-Modified-Since)headersproxiesrE   i0  r+EtagzLast-ModifiedzCache-Control)r   offlinecache_path_shardsexists
read_bytescondagatewaysr   RepodataIsEmptyr   stateetagmodr!   r
   r   rG   rH   rI   r/  rJ   rK   r-  lockURL_KEYETAG_KEYLAST_MODIFIED_KEYCACHE_CONTROL_KEYr	   ra   )r+   r   r\   r9  r.  r:  last_modifiedrE   rO   response_bytessaved_fieldsheaderkeys   &&           r%   _repodata_shardsrF  	  s    ""))++**5577 ..))99t :   #GKKEG::DIIM#&t9 '*='9#$	3 2	3	3//,,
 %[['//7 ) 
 	!!#!)) 
4 s" ZZ**557  NN++33S9L	((112NN##55	
 
%..11CCD 	 ,D 
LL K 
4	3	3( s   2AI$ I8$I5	8J	c                    V ^8  d   QhRRRR/# )r   sdr   r3   zShards | Noner#   )r$   s   "r%   r&   r&   V  s     V V: V- Vr(   c                P   V P                   pVP                  p VP                  R4      ;_uu_ 4       p\        P                  ! VP                  4       4      pVP                  P                  V4       RRR4       TP                  pTP                  R4      '       Ed   RpT P                   R\         2pTP                  P                  4       '       g   RTn        RTn        MRTP#                  4       '       g=   TP                  R4      ;_uu_ 4        TP                  P%                  4       pRRR4       Tf0    \'        Yr4      pTP)                  RR4       TP+                  T4       T'       d>   \D        P                  ! \F        PH                  ! T\J        R
7      4      p	\M        Y4      p
T
# R#   + '       g   i     ELG; i  \        \        P                  3 d     ELhi ; i  + '       g   i     L; i  \,        P.                  P0                  P2                   dH   p\5        TP6                  4      '       d   TP)                  RR4       TP9                  4         Rp?LRp?i\,        P:                  P<                   d   p\?        TP@                  R4      '       dh   \?        TP@                  PB                  R	4      '       dB   \5        TP@                  PB                  P6                  4      '       d   TP)                  RR4       TP9                  4         Rp?ELRp?ii ; i)a  
Check a SubdirData's URL for shards.

Return shards index bytes from cache or network.
Return None if not found; caller should fetch normal repodata.

TODO: If this function fails to retrieve the sharded repodata index file, it will
      mark it is as not supporting this feature in cache. This can problematic
      because sometimes server errors can happen which will lead it to wrongly
      assuming the channel doesn't support sharding. We need to rethink our
      logic for determining shard support.
r0  Nrb   r
  r   TFrO   r-  ri   )'
repo_fetch
repo_cacher<  jsonrn   readr9  ra   FileNotFoundErrorJSONDecodeErrorshould_check_formaturl_w_subdirr   r3  r4  r:  r;  staler5  rF  set_has_formatsaver6  r7  r   UnavailableInvalidChannelr   r-  refresh
exceptionsCondaHTTPErrorhasattr
_caused_byrO   rm   ro   rp   rq   r6   )rH  r:   rK  
state_filer9  cache_stateshards_datashards_index_urlerrr  rb   s   &          r%   fetch_shards_indexr`  V  sg    MME!!J__T""j JJz01E##E*	 # ""K&&x00 oo.a0B/CD++2244!K KO!!##&&(::EEG ' %./?L**8T: ,( ,3MM$$[BUV-L L;FMw #""
 t334   '& >>**DD % 1AA..x?""$$##22 % CNNJ77 7 7GG5//;;   ..x?""$$%sf   G A F13G G'<.G: 1G	<G G G$#G$'G7	:)L%#=I%% L%L%BL  L%c               (    V ^8  d   QhRRRRRRRR/# )	r   
shardlikeszSequence[ShardBase]rA   z	list[str]r"   zcache.ShardCacher3   list[ShardFetch]r#   )r$   s   "r%   r&   r&     s,     ( (#(/8(GW((r(   c           	        V  Uu. uF  p\        V\        4      '       g   K  VNK  	  pp. pV F6  pV F-  pWc9   g   K  VP                  W6VP                  V4      34       K/  	  K8  	  \        P                  R\        V4      4       V'       gO   \        P                  R4       . pV  F/  pV F&  pWc9   g   K  VP                  \        W6V4      4       K(  	  K1  	  V# TP                  V UU	u. uF  Ev rV	NK	  	  up	p4      p
. pV FM  w  r<p	V
P                  V	4      ;p'       d   VP                  W4       K2  VP                  \        W<V4      4       KO  	  V# u upi u up	pi )z
Given a list of ShardBase objects and a list of package names, fetch all URLs
from a shared local cache, and update shardlikes with those per-package shards.
Return ShardFetch objects for items not found in cache (to be fetched from network).
z%d shards to fetchzNo sharded channels found.)r5   r6   ry   r*   r^   r_   lenr   retrieve_multiplerI   r   )rb  rA   r"   	shardlikeshardedwantedpackage_namerl   r   r*   
from_cacheneeds_networkr    from_cache_shards   &&&           r%   batch_retrieve_from_cachern    sC    +5V*Y
9f8Uyy*GVF	$L(i.A.A,.OP %  II"CK0		./#I (,MM*Yk"RS !) $ ..v/Vvmq	v/VWJ M)/%	I)~~i888!!'<  I!LM	 *0 A W, 0Ws   EE-E
c                   V ^8  d   QhRR/# )r   ri  rc  r#   )r$   s   "r%   r&   r&     s     # #(8 #r(   c                0    \         P                  V 4       R# )zw
Fetch all shards in the wanted list from the network.

Coordinate batch fetching across multiple ShardBase instances.
N)r   r   )ri  s   &r%   batch_retrieve_from_networkrq    s     6"r(   c                    V ^8  d   QhRRRR/# )r   url_to_channelzdict[str, Channel]r3   zdict[str, ShardBase] | Noner#   )r$   s   "r%   r&   r&     s      ?T ?T#5 ?T:U ?Tr(   c                   V  Uu/ uF  qRbK  	  pp. p\         P                  P                  \        4       R7      ;_uu_ 4       pV  Uu/ uF  pV\	        \        V4      4      bK  	  ppVP                  4        UUu/ uF  w  rWVP                  \        V4      VbK  	  ppp/ p	\         P                  P                  V4       FE  p
W,          pV
P                  4       pV'       d   WV&   K)  VP                  V\        V4      34       KG  	  \        ;QJ d*    R VP                  4        4       F  '       d   K   RM	  RM! R VP                  4        4       4      '       d    RRR4       R# V F?  w  r\VV	VP                  \	        \        V4      4      P                  P                  4      &   KA  	  \         P                  P                  V	4       F1  p
W,          pV
P                  4       w  rV R2p\!        W4      pWV&   K3  	  RRR4       VP                  4        UUu/ uF  w  rVf   K  WbK  	  upp# u upi u upi u uppi   + '       g   i     LJ; iu uppi )as  
Args:
    url_to_channel: not modified, must already be expanded to subdirs.

Attempt to fetch the sharded index first and then fall back to retrieving a
monolithic `repodata.json` file.

Returns:
    A dict mapping channel URLs to `Shard` or `ShardLike` objects. None if
    no channels have shards. This dict preserves the key order of the input
    `url_to_channel`.
NrR   c              3  (   "   T F  qR J x  K
  	  R # 5ir   r#   ).0values   & r%   	<genexpr>!fetch_channels.<locals>.<genexpr>
  s     @*?}*?s   FTz/repodata.json)rW   rX   rY   r   r   r   rZ   r[   r`  r]   rl   ry   allr   rJ  fetch_latest_parsedr   )rs  r+   channel_datanon_sharded_channelsre   channel_urlsubdir_datarH  rX   futures_non_shardedrf   foundr   repodata_jsonr   s   &              r%   fetch_channelsr    s<    GU0UnsdnL0U				.	.') 
/ 
 
	  .
- GK$899- 	 
 $/#4#4#6
#6 OO.3[@#6 	 
 ! ((55g>F!/KMMOE,1[)$++['+:N,OP ? 3@,*=*=*?@333@,*=*=*?@@@-
 
6 3NK
 	  w{34??SS 3 !((556IJF-5K%}}M
 !M0Cm1E(-% KE
Z *6););)=S)=:3JCJ)=SSc 1V


 
Z TsU   H7I	H<'I<"I
A7II8(I!I,BI I-I<II	i   r#   )?r   
__future__r   r   concurrent.futuresrW   rL  loggingcollectionsr   typingr   rm   ro   conda.exceptionsr6  conda.gateways.repodataconda.base.constantsr   conda.base.contextr   conda.core.subdir_datar   !conda.gateways.connection.sessionr   r	   r
   conda.models.channelr   r   r   miscr   r   r   r   r   	getLoggerr   r^   collections.abcr   r   r   requestsr   r   r   r   r   rq   r   r   ABCr   r   r  r6   rF  r`  rn  rq  r  r#   r(   r%   <module>r     s   
 # 
    #       3 & - 9 )   ! <<!5@@  S0 S0p -	@\) \)~K	 K\:YY YxFZVr(V#?Tr(   