
    $TXg/
                        d Z ddlmZ ddlZddlmZ ddlmZ ddlZddl	m
Z
 ddlmZ d	d
lmZ d	dlmZ erddlmZ  ej&                  e      Z	 	 d	 	 	 	 	 	 	 ddZedd       Zy)zNotices network fetch logic.    )annotationsN)ThreadPoolExecutor)TYPE_CHECKING   )get_session)get_spinner   )cached_response)ChannelNoticeResponse)Sequencec                    t        |      }t        d      5  t        t        dd |j	                  d |       D                    cddd       S # 1 sw Y   yxY w)a  
    Provided a list of channel notification url/name tuples, return a sequence of
    ChannelNoticeResponse objects.

    Args:
        url_and_names: channel url and the channel name
        silent: turn off "loading animation" (defaults to False)
        max_workers: increase worker number in thread executor (defaults to 10)
    Returns:
        Sequence[ChannelNoticeResponse]
    )max_workerszRetrieving noticesNc              3      K   | ]  }|  y wN ).0chn_infos     3lib/python3.12/site-packages/conda/notices/fetch.py	<genexpr>z'get_notice_responses.<locals>.<genexpr>.   s      % %s   c                    t        |  S r   )get_channel_notice_response)argss    r   <lambda>z&get_notice_responses.<locals>.<lambda>1   s
    %@$%G    )r   r   tuplefiltermap)url_and_namessilentr   executors       r   get_notice_responsesr!      sQ      "k:H	)	*$,LLG%

 
+	*	*s   -AAc           	     R   t        |       }	 |j                  | dd      }	 |j                  d	k  rt        | ||j                         
      S t
        j                  d|j                   d|         y# t        j                  j                  $ r t
        j                  d| d|         Y yt        j                  j                  $ r(}t
        j                  d| d| d|         Y d}~yd}~ww xY w# t        $ r) t
        j                  d|         t        | |d
      cY S w xY w)z
    Return a channel response object. We use this to wrap the response with
    additional channel information to use. If the response was invalid we suppress/log
    and error message.
    F   )allow_redirectstimeoutzRequest timed out for channel: z url: NzRequest error <z> for channel: i,  )	json_dataz	Received z when trying to GET zUnable to parse JSON data for )r   getrequests
exceptionsTimeoutloggerinfoRequestExceptionerrorstatus_coder   json
ValueError)urlnamesessionrespexcs        r   r   r   8   s    #G	{{  
@c!(ddiikJJKK)D$4$4#55I#OP && 5dV6#GH// se?4&seLM  @4SE:;$S$$??@s4   A3 *C4 %C4 38C1-C1	C,,C14/D&%D&)F
   )r   zSequence[tuple[str, str]]r   boolr   intreturnzSequence[ChannelNoticeResponse])r2   strr3   r;   r:   zChannelNoticeResponse | None)__doc__
__future__r   loggingconcurrent.futuresr   typingr   r(   gateways.connection.sessionr   	reportersr   cacher
   typesr   collections.abcr   	getLogger__name__r+   r!   r   r   r   r   <module>rH      s    # "  1    5 # " ((			8	$
 
,

 
 %	
@ @ @r   