
    h0                    >   S r SSKJr  SSKJr  SSKJ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JrJr  SSKJr  SSKJrJr  SSKJrJr  SSK J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(  SSK)J*r*  SSK+J,r,  SSK-J.r.J/r/J0r0J1r1  SSK2J3r3  \(       a  SSK4J5r5J6r6  SSK7J8r8  SSKJ9r9  \1r:\" SS9Rw                  5       r<Sr=Sr>Sr?S1r@S+S jrAS+S jrBS+S jrCS+S jrDS+S  jrES,S! jrF\S-S" j5       rG\S.S# j5       rHS/S$ jrI\" S%S&9S0S' j5       rJ\S1S( j5       rK\S2S) j5       rLg*)3z%High-level conda plugin registration.    )annotations)	timedelta)cache)TYPE_CHECKING)context)add_parser_prefixadd_parser_verbose)PrimitiveParameter)NULL)CondaPreCommandCondaRequestHeaderCondaSettingCondaSubcommandhookimpl)Console   )APP_NAMEAPP_VERSION)CIget_channels)noop_printerrender_acceptrender_cleanrender_inforender_interactiverender_listrender_rejectrender_view)CondaToSMissingError)get_local_metadata)ENV_TOS_ROOTSITE_TOS_ROOTSYSTEM_TOS_ROOTUSER_TOS_ROOT)ENDPOINT)ArgumentParser	Namespace)Iterator)Callable)hours;=zAnaconda-ToS-Acceptzrepo.anaconda.comc                l    U R                  S5      nUR                  SSSSS9  UR                  SSS	S9  g )
NzChannel Customizationz-cz	--channelappendz3Additional channels to search for Terms of Service.actionhelpz--override-channels
store_truez?Do not search default or .condarc channels. Requires --channel.)add_argument_groupadd_argument)parserchannel_groups     9lib/python3.13/site-packages/conda_anaconda_tos/plugin.py_add_channelr8   B   sP    --.EFMB	   N      c           	        U R                  S5      nUR                  5       nS[        S4S[        S4S[        S4S[
        S	44 H  u  p4nUR                  US
SUUS9  M     UR                  SSSS9  U R                  [        S9  g )NzLocal Metadata Storage Locationz--sitezSystem-wide storage location.z--systemz$Conda installation storage location.z--userzUser storage location.z--envz#Conda environment storage location.tos_rootstore_constdestr0   constr1   z
--tos-rootstorezCustom storage location.r/   r;   )	r3   add_mutually_exclusive_groupr"   r#   r$   r!   r4   set_defaultsDEFAULT_TOS_ROOT)r5   location_grouplocation_mutexflagvaluetexts         r7   _add_locationrJ   Q   s    ../PQN#@@BN	="AB	_&LM	=":;	, EF	T 	##  	$ 	
 '   
 !12r9   c                    U R                  S5      nUR                  5       nUR                  SS[        SS9  UR                  SSSS	S
S9  U R	                  [
        S9  g )NzCache Controlz--cache-timeoutr@   zACache timeout (in seconds) to check for Terms of Service updates.)r0   typer1   z--ignore-cachecache_timeoutr<   r   z?Ignore the cache and always check for Terms of Service updates.r=   )rM   )r3   rB   r4   intrC   DEFAULT_CACHE_TIMEOUT)r5   cache_groupcache_mutexs      r7   
_add_cacherR   i   sw    ++O<K::<KP	   N   &;<r9   c                0    U R                  SS[        SS9  g )Nz--jsonr2   zEReport all output as json. Suitable for using conda programmatically.)r0   defaultr1   )r4   r   )r5   s    r7   	_add_jsonrU   |   s!    
T	  r9   c           	     ,   U R                  SSS[         S[         3S[         S3S9  [        U 5        [	        U 5        [        U 5        [        U 5        [        U 5        U R                  [        S9  U R                  S	S
SSS9nUR                  SSS9n[        U5        [	        U5        [        U5        [        U5        [        U5        UR                  SSS9n[        U5        [	        U5        [        U5        [        U5        [        U5        UR                  SSS9n[        U5        [	        U5        [        U5        [        U5        [        U5        UR                  SSS9n[        U5        [	        U5        [        U5        [        U5        [        U5        [        U5        UR                  SSS9n[        U5        UR                  SSS9nUR                  SSSS9  UR                  SSS S9  UR                  S!SS"S9  [        U5        g#)$z.Configure the parser for the `tos` subcommand.z-Vz	--versionversion z	Show the z version number and exit.)r0   rW   r1   rA   
subcommandz(The following subcommands are available.cmdF)titledescriptionr>   requiredacceptznAccept the Terms of Service for all active channels (default, .condarc, and/or those specified via --channel).)r1   rejectznReject the Terms of Service for all active channels (default, .condarc, and/or those specified via --channel).viewzlView the Terms of Service for all active channels (default, .condarc, and/or those specified via --channel).interactivezInteractively accept/reject/view Terms of Service for all active channels (default, .condarc, and/or those specified via --channel).infozMDisplay information about the plugin (e.g., search path and cache directory).cleanzClean the cache directories.z--cacher2   zRemove all cache files.r/   z--tosz"Remove all acceptances/rejections.z--allz"Invoke both `--cache` and `--tos`.N)r4   r   r   r8   r   rR   rU   r	   rC   rD   add_subparsers
add_parserrJ   )r5   
subparsersaccept_parserreject_parserview_parserinteractive_parserinfo_parserclean_parsers           r7   configure_parserrm      s{    *Ak]+
";<   fvfv
!12 &&>	 ' J ))I * M m$- }m ))I * M m$- }m ''I ( K k"+{k $..I /  #$()$%!" !)* ''7 ( K k ((+ ) L &  
 1  
 1  
 lr9   c           	         SSK Jn  U" [        R                  5      R	                  5         [        5       n0 nU R                  S:X  a  [        nGOU R                  S:X  a  [        nGOU R                  S:X  a  [        nOU R                  S	:X  aJ  [         n[        R"                  R$                  US
'   [        R&                  US'   [        R(                  US'   OU R                  S:X  a  [+        [        R,                  US9$ U R                  S:X  aD  [/        U R0                  U R2                  U R4                  U R6                  [        R,                  US9$ [8        n[        R(                  US'   U" [        R:                  U R6                  U R<                  [        R,                  US.UD6$ ! [
         aD    SSKJn  SSKJ	n  U" [        R                  5      R                  5       =n(       d	  U" U5      Se GNf = f)zExecute the `tos` subcommand.r   )
PrefixData)Path)EnvironmentLocationNotFoundNr^   r_   r`   ra   auto_accept_tos
always_yesverboserb   )jsonconsolerc   )r   tosallr;   ru   rv   )r;   rM   ru   rv   )conda.core.prefix_dataro   r   target_prefixassert_existsAttributeErrorpathlibrp   conda.exceptionsrq   existsr   rZ   r   r   r   r   pluginsrr   rs   rt   r   ru   r   r   rw   rx   r;   r   channelsrM   )argsro   rp   rq   prefixrv   kwargsr0   s           r7   executer      s   @57(()779 iGFxx8	X		V		]	"#$+OO$C$C !&11|#OOy	V	g>>	W	**]]
 	
 #OOy			((\\  S  @ @w445<<>>>-f54? ?@s   *F+ +A
G98G9c               #  8   #    [        S[        S[        S9v   g7f)z,Return a list of subcommands for the plugin.rw   a  A subcommand for viewing, accepting, rejecting, and otherwise interacting with a channel's Terms of Service (ToS). This plugin periodically checks for updated Terms of Service for the active/selected channels. Channels with a Terms of Service will need to be accepted or rejected prior to use. Conda will only allow package installation from channels without a Terms of Service or with an accepted Terms of Service. Attempting to use a channel with a rejected Terms of Service will result in an error.)namer0   summaryrm   N)r   r   rm    r9   r7   conda_subcommandsr   5  s$       * s   c            	   #  >   #    [        SS[        S[        S9S9v   g7f)z)Return a list of settings for the plugin.rr   z=Automatically accept Terms of Service (ToS) for all channels.F)element_type)r   r\   	parameterN)r   r
   boolr   r9   r7   conda_settingsr   I  s$      S$U> s   c                    [        [        R                  [        [        [        R
                  [        R                  [        R                  R                  [        R                  [        S.6  g )N)r;   rM   ru   rt   rr   rs   json_printer)r   r   r   rD   rO   ru   rt   r   rr   rs   r   )_commands    r7   _pre_command_check_tosr   S  s@    			!+\\77%%!	r9   T)tryfirstc               #  2   #    [        S[        1 SkS9v   g7f)z-Return a list of pre-commands for the plugin.	check_tos>	   createremoverenamesearchupdateinstall
env_create
env_remove
env_update)r   r0   run_forN)r   r   r   r9   r7   conda_pre_commandsr   `  s      %

 s   c                 T   / n [        [        R                  6  H  n [        U[        /S9nU R                  [        R                  UR                  [        [        UR                  R                  R                  5       5      5      UR                  R                  (       a  SOS[        [        UR                  R                  R                  5       5      5      45      5        M     ["        (       a  U R                  S5        [$        R                  U 5      $ ! [          a     GM  f = f)N)extend_search_pathacceptedrejectedzCI=true)r   r   r   r    rD   r.   KEY_SEPARATORjoinbase_urlstrrN   metadatarW   	timestamptos_acceptedacceptance_timestampr   r   FIELD_SEPARATOR)valueschannel
local_pairs      r7   _get_tos_acceptance_headerr   t  s    F!1!12	+$4#5J MM""((C
 3 3 ; ; E E GHI&0&9&9&F&F
JC
 3 3 H H R R TUV		 3& 
ri '' $ 		s   D
D'&D'c              #     #    U [         ;   a7  UR                  S[         35      (       d  [        [        [        5       S9v   ggg7f)z0Return a list of request headers for the plugin./)r   rH   N)HOSTSendswithr%   r   TOS_ACCEPT_HEADERr   )hostpaths     r7   conda_request_headersr     sC     
 	(n-- ",.
 	
 . 	s   AAN)r5   r&   returnNone)r   r'   r   rN   )r   zIterator[CondaSubcommand])r   zIterator[CondaSetting])r   r   r   r   )r   zIterator[CondaPreCommand])r   r   )r   r   r   r   r   zIterator[CondaRequestHeader])M__doc__
__future__r   datetimer   	functoolsr   typingr   conda.base.contextr   conda.cli.helpersr   r	   conda.common.configurationr
   conda.common.constantsr   conda.pluginsr   r   r   r   r   rich.consoler    r   r   apir   r   rv   r   r   r   r   r   r   r   r   
exceptionsr   localr    r   r!   r"   r#   r$   remoter%   argparser&   r'   collections.abcr(   r)   rD   total_secondsrO   r   r   r   r   r8   rJ   rR   rU   rm   r   r   r   r   r   r   r   r   r9   r7   <module>r      s0   , "     & C 9 '  ! # !	 	 	 - % M M 2( !  "*88:    *  
30=&rj7t 
 
& 
 

 
4 & ( (4 

 

r9   