+
    ,jL5                    (   ^ RI Ht ^ RIt^ RIt^ RIHt ^ RIHtHtH	t	H
t
HtHt ^ RIH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HtHt ^ RIHt ]'       d   ^ RI H!t!  ! R R4      t"] ! R R4      4       t# ! R R4      t$R R lt%R# )    )annotationsN)	dataclass)TYPE_CHECKINGAnyIterableListOptionalUnion)Channel)	MatchSpec)Client)CacheAction)PackageName)PlatformPlatformLiteral)	PyGatewayPyMatchSpecPySourceConfig)RepoDataRecordRepoDataSourcec                  >    ] tR t^tRtR R ltR R ltR R ltRtR	# )
_RepoDataSourceAdapterzAdapter that wraps a user's RepoDataSource and converts FFI types.

This adapter receives raw PyPlatform and PyPackageName from Rust,
converts them to the proper Python wrapper types (Platform, PackageName),
and calls the user's implementation.
c                    V ^8  d   QhRRRR/# )   sourcer   returnNone )formats   "9lib/python3.14/site-packages/rattler/repo_data/gateway.py__annotate__#_RepoDataSourceAdapter.__annotate__   s      ~ $     c                	    Wn         R # )N_source)selfr   s   &&r!   __init___RepoDataSourceAdapter.__init__   s    r$   c               $    V ^8  d   QhRRRRRR/# )r   py_platformr   py_namer   zList[RepoDataRecord]r   )r    s   "r!   r"   r#       s'     H Hs HS HMa Hr$   c                   "   \         P                  ! V4      p\        P                  ! V4      pV P                  P                  W44      G Rj  xL
 #  L5i)5Convert FFI types and delegate to the wrapped source.N)r   _from_py_platformr   _from_py_package_namer'   fetch_package_records)r(   r,   r-   platformnames   &&&  r!   r2   ,_RepoDataSourceAdapter.fetch_package_records    sD      --k:009 \\77GGGGs   AAAAc                    V ^8  d   QhRRRR/# )r   r,   r   r   z	List[str]r   )r    s   "r!   r"   r#   )   s     4 4 4 4r$   c                d    \         P                  ! V4      pV P                  P                  V4      # )r/   )r   r0   r'   package_names)r(   r,   r3   s   && r!   r8   $_RepoDataSourceAdapter.package_names)   s'    --k:||))(33r$   r&   N)	__name__
__module____qualname____firstlineno____doc__r)   r2   r8   __static_attributes__r   r$   r!   r   r      s    H4 4r$   r   c                      ] tR t^/t$ RtRtR]R&    RtR]R&    RtR]R&    Rt	R]R	&    R
t
R]R&    R R ltR R ltRtR# )SourceConfigzw
Describes properties about a channel.

This can be used to configure the Gateway to handle channels in a certain
way.
Tboolzstd_enabledbz2_enabledsharded_enabledNzOptional[bool]jlap_enabledzcache-or-fetchr   cache_actionc                   V ^8  d   QhRR/# )r   r   r   r   )r    s   "r!   r"   SourceConfig.__annotate__M   s      t r$   c                	`    V P                   e    \        P                  ! R\        ^R7       R # R # )NzYThe 'jlap_enabled' option is deprecated and has no effect. JLAP support has been removed.)
stacklevel)rF   warningswarnDeprecationWarningr(   s   &r!   __post_init__SourceConfig.__post_init__M   s(    (MMk" )r$   c                   V ^8  d   QhRR/# )r   r   r   r   )r    s   "r!   r"   rI   U   s     
 
. 
r$   c                p    \        V P                  V P                  V P                  V P                  R7      # )z
Converts this object into a type that can be used by the Rust code.

Examples
--------
```python
>>> SourceConfig()._into_py() # doctest: +ELLIPSIS
<builtins.PySourceConfig object at 0x...>
>>>
```
)rC   rD   rE   rG   )r   rC   rD   rE   rG   rO   s   &r!   _into_pySourceConfig._into_pyU   s5     **(( 00**	
 	
r$   r   )r:   r;   r<   r=   r>   rC   __annotations__rD   rE   rF   rG   rP   rT   r?   r   r$   r!   rA   rA   /   s[     L$9K8 OT 5#'L.'K 0L+0
 
r$   rA   c                  b    ] tR t^itRtRR R lltRR R lltR R ltRR	 R
 lltR R lt	Rt
R# )Gatewaya  
The gateway manages all the quircks and complex bits of efficiently acquiring
repodata. It implements all the necessary logic to fetch the repodata from a
remote server, cache it locally and convert it into python objects.

The gateway can also easily be used concurrently, as it is designed to be
thread-safe. When two threads are querying the same channel at the same time,
their requests are coalesced into a single request. This is done to reduce the
number of requests made to the remote server and reduce the overall memory usage.

The gateway caches the repodata internally, so if the same channel is queried
multiple times the records will only be fetched once. However, the conversion
of the records to a python object is done every time the query method is called.
Therefor, instead of requesting records directly, its more efficient to pass the
gateway itself to methods that accepts it.
Nc               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# )r   	cache_dirzOptional[os.PathLike[str]]default_configzOptional[SourceConfig]per_channel_configz!Optional[dict[str, SourceConfig]]max_concurrent_requestsintclientzOptional[Client]show_progressrB   r   r   r   )r    s   "r!   r"   Gateway.__annotate__{   sP     '
 '
-'
 /'
 >	'

 "%'
 !'
 '
 
'
r$   c                   T;'       g    \        4       p\        TVP                  4       T;'       g    / P                  4        UUu/ uF  w  rxWxP                  4       bK  	  uppTVe   VP                  MRVR7      V n        R# u uppi )a8  
Arguments:
    cache_dir: The directory where the repodata should be cached. If not specified the
               default cache directory is used.
    default_config: The default configuration for channels.
    per_channel_config: Source configuration on a per-URL basis. This URL is used as a
                        prefix, so any channel that starts with the URL uses the configuration.
                        The configuration with the longest matching prefix is used.
    max_concurrent_requests: The maximum number of concurrent requests that can be made.
    client: An authenticated client to use for acquiring repodata. If not specified a default
            client will be used.
    show_progress: Whether to show progress bars when fetching repodata.

Examples
--------
```python
>>> Gateway()
Gateway()
>>>
```
N)rZ   r[   r\   r]   r_   r`   )rA   r   rT   items_client_gateway)	r(   rZ   r[   r\   r]   r_   r`   channelconfigs	   &&&&&&&  r!   r)   Gateway.__init__{   sz    < (99<>!)224SeSkSkikRrRrRtuRtw): :Rtu$;%+%76>>T'
  vs   Bc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   sources-Iterable[Union[Channel, str, RepoDataSource]]	platforms$Iterable[Platform | PlatformLiteral]specsz'Iterable[MatchSpec | PackageName | str]	recursiverB   r   zList[List[RepoDataRecord]]r   )r    s   "r!   r"   ra      sC     =j =j>=j 8=j 7	=j
 =j 
$=jr$   c                  "   V P                   P                  \        V4      V Uu. uF:  p\        V\        4      '       d   VP
                  M\	        V4      P
                  NK<  	  upV Uu. uF;  p\        V\        4      '       d   VP                  M\        \        V4      RR4      NK=  	  upVR7      G Rj  xL
 pV UU	u. uF(  q U	u. uF  p	\        P                  ! V	4      NK  	  up	NK*  	  up	p# u upi u upi  LEu up	i u up	pi 5i)a  Queries the gateway for repodata from channels and custom sources.

If `recursive` is `True` the gateway will recursively fetch the dependencies of the
encountered records. If `recursive` is `False` only the records with the package names
specified in `specs` are returned.

The `specs` can either be a `MatchSpec`, `PackageName` or a string. If a string or a
`PackageName` is provided it will be converted into a MatchSpec that matches any record
with the given name. If a `MatchSpec` is provided all records that match the name
specified in the spec will be returned, but only the dependencies of the records
that match the entire spec are recursively fetched.

The gateway caches records from channels internally, so if the same channel is queried
multiple times the records will only be fetched once. However, the conversion of the
records to a python object is done every time the query method is called.

Note: Custom RepoDataSource implementations are **not cached** by the gateway. If caching
is needed for custom sources, it must be implemented within the source itself.

Arguments:
    sources: The sources to query. Can be channels (by name, URL, or Channel object)
             or custom RepoDataSource implementations.
    platforms: The platforms to query.
    specs: The specs to query.
    recursive: Whether recursively fetch dependencies or not.

Returns:
    A list of lists of `RepoDataRecord`s. The outer list contains the results for each
    source in the same order they are provided in the `sources` argument.

Examples
--------
```python
>>> import asyncio
>>> gateway = Gateway()
>>> records = asyncio.run(gateway.query(["conda-forge"], ["linux-aarch64"], ["python"]))
>>> assert len(records) == 1
>>>
```
T)rj   rl   rn   ro   N)re   query_convert_sources
isinstancer   _innerr   _match_specr   strr   _from_py_record)
r(   rj   rl   rn   ro   r3   spec
py_recordsrecordsrecords
   &&&&&     r!   rq   Gateway.query   s    ^  ==..$W- !* )H $.h#A#AxPXGYG`G`` ) "!D %/tY$?$?  [QTUYQZ\`bfEgg!   / 
 

 _ii^hSZgNgF//7gN^hii
 OisN   $DA C5
&D,AC:-D9C?:	DDD*D1DDDc               $    V ^8  d   QhRRRRRR/# )r   rj   rk   rl   rm   r   zList[PackageName]r   )r    s   "r!   r"   ra      s-     $f $f>$f 8$f 
	$fr$   c           
     T  "   V P                   P                  \        V4      V Uu. uF:  p\        V\        4      '       d   VP
                  M\	        V4      P
                  NK<  	  upR7      G Rj  xL
 pV Uu. uF  p\        P                  ! V4      NK  	  up# u upi  L/u upi 5i)a  Queries all the names of packages in channels or custom sources.

Arguments:
    sources: The sources to query. Can be channels (by name, URL, or Channel object)
             or custom RepoDataSource implementations.
    platforms: The platforms to query.

Returns:
    A list of package names that are present in the given subdirectories.

Examples
--------
```python
>>> import asyncio
>>> gateway = Gateway()
>>> records = asyncio.run(gateway.names(["conda-forge"], ["linux-64"]))
>>> PackageName("python") in records
True
>>>
```
)rj   rl   N)re   namesrr   rs   r   rt   r   r1   )r(   rj   rl   r3   py_package_namespackage_names   &&&   r!   r   Gateway.names   s     6 "&!4!4$W- !* )H $.h#A#AxPXGYG`G`` ) "5 "
 
 UeeTdL11,?Tdee
 fs/   $B(A B
&B(1B!2B(:B#	B(#B(c               (    V ^8  d   QhRRRRRRRR/# )	r   rf   zChannel | strsubdirsz.Optional[Iterable[Platform | PlatformLiteral]]
clear_diskrB   r   r   r   )r    s   "r!   r"   ra   	  s3     "
 "
"
 @"
 	"

 
"
r$   c           
     J   V P                   P                  \        V\        4      '       d   VP                  M\        V4      P                  VeH   V Uu0 uF:  p\        V\
        4      '       d   VP                  M\        V4      P                  kK<  	  upMRV4       R# u upi )a  
Clears the cache for the given channel.

Any subsequent query will re-fetch any required data from the source.

Arguments:
    channel: The channel to clear the cache for.
    subdirs: A selection of subdirectories to clear, if `None` is specified
             all subdirectories of the channel are cleared.
    clear_disk: If `True`, also clears the on-disk cache. By default only the
                in-memory cache is cleared.

Examples
--------
```python
>>> gateway = Gateway()
>>> gateway.clear_repodata_cache("conda-forge", ["linux-64"])
>>> gateway.clear_repodata_cache("robostack")
>>> gateway.clear_repodata_cache("conda-forge", clear_disk=True)
>>>
```
N)re   clear_repodata_cachers   r   _channelr   rt   )r(   rf   r   r   subdirs   &&&& r!   r   Gateway.clear_repodata_cache	  s    8 	** *7G < <G''BRB[B[" gnnfm\bj::V]]@P@W@WWfmn	
ns   A B 
c                   V ^8  d   QhRR/# )r   r   rv   r   )r    s   "r!   r"   ra   -  s     * *# *r$   c                2    \        V 4      P                   R2# )zg
Returns a representation of the Gateway.

Examples
--------
```python
>>> Gateway()
Gateway()
>>>
```
z())typer:   rO   s   &r!   __repr__Gateway.__repr__-  s     t*%%&b))r$   )re   )NNNd   NF)T)NF)r:   r;   r<   r=   r>   r)   rq   r   r   r   r?   r   r$   r!   rX   rX   i   s+    "'
R=j~$fL"
H* *r$   rX   c                    V ^8  d   QhRRRR/# )r   rj   zIterable[Any]r   z	List[Any]r   )r    s   "r!   r"   r"   <  s      m 	 r$   c                   ^ RI Hp . pV  F  p\        V\        4      '       d'   VP	                  \        V4      P                  4       K?  \        V\
        4      '       d   VP	                  VP                  4       Kr  \        W14      '       d   VP	                  \        V4      4       K  \        R\        V4      P                   R24      h	  V# )aT  Convert an iterable of sources to a list suitable for the Rust gateway.

Channels are converted to their internal PyChannel representation.
Custom RepoDataSource implementations are wrapped in an adapter that
converts between FFI types and Python wrapper types.

Raises:
    TypeError: If a source doesn't implement the required interface.
r   zKExpected Channel, str, or object implementing RepoDataSource protocol, got z8. See rattler.RepoDataSource for the required interface.)rattler.repo_data.sourcer   rs   rv   appendr   r   r   	TypeErrorr   r:   )rj   r   	convertedr   s   &   r!   rr   rr   <  s     8Ifc""WV_556((V__-//3F;<F|,,- .IJ    r$   )&
__future__r   osrL   dataclassesr   typingr   r   r   r   r	   r
   rattler.channel.channelr   rattler.match_spec.match_specr   rattler.networking.clientr   "rattler.networking.fetch_repo_datar   rattler.package.package_namer   rattler.platform.platformr   r   rattler.rattlerr   r   r   rattler.repo_data.recordr   r   r   r   rA   rX   rr   r   r$   r!   <module>r      sn    " 	  ! F F + 3 , : 4 ? B B 374 44 6
 6
 6
rP* P*fr$   