
    si                       S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSK	J
r
Jr  SSKJr  SS	KJr  S
SKJr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Jr  S
SKJrJr  \r\r\R@                  " \!5      r"   S       SS jjr#SS jr$S r%    SS jr&    SS jr'  S       SS jjr(S S jr)S!S jr*g)"zCore conda notices logic.    )annotationsNwraps)TYPE_CHECKING   )"NOTICES_DECORATOR_DISPLAY_INTERVAL
NOTICES_FN)context)get_channel_objs   )cachefetchviews)ChannelNoticeResultSet)Sequence)Context)ChannelMultiChannel)ChannelNoticeChannelNoticeResponsec                R   [        [        [        5      5      n[        R                  " X2S9n[        U5      n[        U5      n[        R                  " 5       nUR                  5         SnSn	U(       d!  [        R                  " Xu5      n[        U5      n	[        XPUS9n[        UU	US9$ )a  
Function used for retrieving notices. This is called by the "notices" decorator as well
as the sub-command "notices"

Args:
    limit: Limit the number of notices to show (defaults to None).
    always_show_viewed: Whether all notices should be shown, not only the unread ones
                        (defaults to True).
    silent: Whether to use a spinner when fetching and caching notices.
)silentNr   )limitexclude)channel_noticesviewed_channel_noticestotal_number_channel_notices)get_channel_name_and_urlsr   r
   r   get_notice_responsesflatten_notice_responseslenr   get_notices_cache_filetouchget_viewed_channel_notice_idsfilter_noticesr   )
r   always_show_viewedr   channel_name_urlschannel_notice_responsesr   r   
cache_fileviewed_noticesr   s
             2lib/python3.13/site-packages/conda/notices/core.pyretrieve_noticesr,       s     22B72KL$99  //GHO#&#7 --/J N<<
 "%^!4$nO "'5%A     c                ,   [         R                  " U R                  5        [        R                  " 5       n[        R
                  " XR                  5        [         R                  " U R                  [        U R                  5      U R                  5        g)z&Prints the channel notices to std out.N)
r   print_noticesr   r   r"   mark_channel_notices_as_viewedprint_more_notices_messager   r!   r   )channel_notice_setr)   s     r+   display_noticesr3   O   sj    	*::; --/J	((5W5WX	$$77../11r-   c                0   ^  [        T 5      U 4S j5       nU$ )a  
Wrapper for "execute" entry points for subcommands.

If channel notices need to be fetched, we do that first and then
run the command normally. We then display these notices at the very
end of the command output so that the user is more likely to see them.

This ordering was specifically done to address the following bug report:
    - https://github.com/conda/conda/issues/11847

Args:
    func: Function to be decorated
c                   > [        [        5      (       aD  S n [        5       (       a  [        [        R                  SSS9nUb   T" U 0 UD6n[        U5        U$ T" U 0 UD6$ ! [
         a+  n[        R                  S[        U5       35         S nANQS nAff = f! [         a(     [        R                  " 5         e ! [
         a     e f = ff = f)NFT)r   r&   r   zUnable to open cache file: )is_channel_notices_enabledr
    is_channel_notices_cache_expiredr,   number_channel_noticesOSErrorloggererrorstrr3   	Exceptionr   clear_cache)argskwargsr2   excreturn_valuefuncs        r+   wrappernotices.<locals>.wrapperm   s    %g..!%
G355)9%<<+0#*& "-#'#8#8L#$67'' T$V$$)  G :3s8*EFFG ! ))+  # 	sG   (A" B "
B,!BB
C%B;:C;
CCCCr   )rC   rD   s   ` r+   noticesrF   ^   s#     4[% %B Nr-   c                    / nU  Hb  nUR                   =(       d    UR                  nUR                   H0  nUR                  S5      nUR	                  U S[
         3U45        M2     Md     U$ )zv
Return a sequence of Channel URL and name tuples.

This function handles both Channel and MultiChannel object types.
/)namelocation	base_urlsrstripappendr	   )channelschannel_name_and_urlschannelrI   urlfull_urls         r+   r   r      sk     ||/w//$$Czz#H!((XJa
|*Dd)KL %  ! r-   c                &    [        S U  5       5      $ )Nc              3  t   #    U  H.  nUR                   (       d  M  UR                     H  nUv   M	     M0     g 7fN)rF   ).0rP   notices      r+   	<genexpr>+flatten_notice_responses.<locals>.<genexpr>   s8      /G?? 	 ooF 	 & 	/s   88tuple)r(   s    r+   r    r       s      /  r-   c                P   ^ T(       a  [        U4S jU  5       5      n Ub  U SU n U $ )zMPerform filtering actions for the provided sequence of ChannelNotice objects.c              3  L   >#    U  H  nUR                   T;  d  M  Uv   M     g 7frU   )id)rV   channel_noticer   s     r+   rX   !filter_notices.<locals>.<genexpr>   s(       
"1  / N"1s   $	$NrZ   )r   r   r   s     `r+   r%   r%      s9       
"1 
 
 )&51r-   c                    U R                   S:  =(       a)    U R                  (       + =(       a    U R                  (       + $ )z
Determines whether channel notices are enabled and therefore displayed when
invoking the `notices` command decorator.

This only happens when:
 - offline is False
 - number_channel_notices is greater than 0

Args:
    ctx: The conda context object
r   )r8   offlinejson)ctxs    r+   r6   r6      s+     %%)N#++oNchh,Nr-   c                     [         R                  " 5       n U R                  5       n[        R                  " 5       nX!R                  -
  nU[
        :  $ )z
Checks to see if the notices cache file we use to keep track of
displayed notices is expired. This involves checking the mtime
attribute of the file. Anything older than what is specified as
the NOTICES_DECORATOR_DISPLAY_INTERVAL is considered expired.
)r   r"   stattimest_mtimer   )r)   cache_file_statnowseconds_since_checkeds       r+   r7   r7      sD     --/J oo'O
))+C":":: $FFFr-   )NTF)r   
int | Noner&   boolr   rm   returnr   )r2   r   rn   None)rN   z Sequence[Channel | MultiChannel]rn   z$list[tuple[ChannelUrl, ChannelName]])r(   zSequence[ChannelNoticeResponse]rn   Sequence[ChannelNotice])NN)r   rp   r   rl   r   zset[str] | Nonern   rp   )rd   r   rn   rm   )rn   rm   )+__doc__
__future__r   loggingrg   	functoolsr   typingr   base.constantsr   r	   base.contextr
   models.channelr    r   r   r   typesr   collections.abcr   r   r   r   r   r   r<   ChannelName
ChannelUrl	getLogger__name__r:   r,   r3   rF   r   r    r%   r6   r7    r-   r+   <module>r      s      "      K " - ! ! )(&6; 
			8	$ #,,, , 	,^1h!.!)!(= #,  	&OGr-   