
    wBf2                       d Z ddlmZ ddlZddlZddlZddlmZmZ ddlmZ	 ddl
mZ ddlmZ ddlmZ d	d
lmZ d	dlmZ d	dlmZ d	dlmZmZmZ d	dlmZ d	dlmZ d	dlmZ ddl m!Z!m"Z" ddl#m#Z#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7 ddl8m9Z: ddl;m9Z< ddl=m9Z> ddl?m9Z@ ddlAm9ZB ddlCm9ZD ddlEm9ZF ddlGm9ZH ddlIm9ZJ ddlKm9ZL ddlMm9ZN ddlOm9ZP ddlQm9ZR ddlSm9ZT ddlUm9ZV ddlWm9ZX ddlYm9ZZ ddl[m9Z\ ddl]m9Z^  ee_      Z` ej                  dd      Zb ej                  dd      Zch dZdd%dZed%dZfd&dZgd Zh G d de	      Z G d d ej                        Zjd! Zkd" Zld# Zmd'd$Zny)(z%Conda command line interface parsers.    )annotationsN)SUPPRESSRawDescriptionHelpFormatter)ArgumentParser)import_module)	getLogger)Popen   )__version__)
isiterable)dals)contextsys_rc_pathuser_rc_path)on_win)NULL)
deprecated   )ExtendConstActionNullCountAction)find_commandsfind_executable)add_output_and_prompt_optionsadd_parser_channels add_parser_create_install_updateadd_parser_default_packagesadd_parser_helpadd_parser_jsonadd_parser_knownadd_parser_networking"add_parser_package_install_optionsadd_parser_platformadd_parser_prefixadd_parser_pruneadd_parser_pscheckadd_parser_show_channel_urlsadd_parser_solveradd_parser_solver_modeadd_parser_update_modifiersadd_parser_verbose)configure_parser%z%%>   runinfoinitlistcleanconfigcreateexportremoverenamesearchupdatecompareinstallnoticespackageupgradeactivate
deactivater   c                     t        dddi| }t        |       |j                  ddt        t               |j                  ddt        d       |S )	NdescriptionzSconda is a tool for managing and deploying applications, environments and packages.z--json
store_true)actiondefaulthelpz--no-pluginsz2Disable all plugins that are not built into conda. )r   r*   add_argumentr   r   )kwargs
pre_parsers     8lib/python3.12/site-packages/conda/cli/conda_argparse.pygenerate_pre_parserrK   a   sr     & J z"	   A	       c                 P   t        di | }|j                  ddddt        z  d       |j                  ddd	d
t        d      }t        |       t        |       t        |       t        |       t        |       t        |       t        |       t        |       t        |       t        |       t        |       t!        |       t#        |       t%        |       t'        |dg       t)        |       t+        |       t-        |       t/        |dg       t1        |       |S )Nz-Vz	--versionversionzconda %sz'Show the conda version number and exit.)rC   rN   rE   COMMANDcommandsz=The following built-in and plugins subcommands are available.cmdT)metavartitlerA   destrC   required	uninstall)aliasesr=   rF   )rK   rG   r   add_subparsers_GreedySubParsersActionconfigure_parser_mock_activate configure_parser_mock_deactivateconfigure_parser_cleanconfigure_parser_compareconfigure_parser_configconfigure_parser_createconfigure_parser_envconfigure_parser_exportconfigure_parser_infoconfigure_parser_initconfigure_parser_installconfigure_parser_listconfigure_parser_noticesconfigure_parser_packageconfigure_parser_removeconfigure_parser_renameconfigure_parser_runconfigure_parser_searchconfigure_parser_updateconfigure_parser_plugins)rH   parsersub_parserss      rJ   generate_parserrp   y   s    *6*F
[(6   ''S& ( K #;/$[1;'[)K(K(%K(+&+&[)+&[)[)K+?K(%K(K)=[)MrL   c                   t        | dd      x}rpt        j                  j                  |j                         |j                  t        | d|             }t        j                  j                  |j                         |S t        | dd      x}r^t        j                  dddd	       t        d
|       }|sddl
m}  ||      t        |g| j                  t        j                        S | j                   j#                  dd      \  }}t%        |      }	|j'                  d      d   j)                  dd      }
t        j                  j                  |
        t        |	|      | |      }t        j                  j                  |
       |S )z
    Serves as the primary entry point for commands referred to in this file and for
    all registered plugin subcommands.
    _plugin_subcommandN_args_executablez23.3z25.3z)Loading conda subcommands via executableszUse the plugin system instead.)topicaddendumzconda-r
   )CommandNotFoundError.r   main_ )getattrr   plugin_managerinvoke_pre_commandsnamerC   invoke_post_commandsr   ru   r   
exceptionsrw   _execrs   osenvironfuncrsplitr   splitreplace)argsrn   plugin_subcommandresultr   
executablerw   module_name	func_namemodulecommands              rJ   do_callr      sm    $D*>EEE 	223D3I3IJ"))'$*FG334E4J4JK2 M1 }d3	3	3=5		
 %vdV_5
9&t,,j.4::.

;; "&!1!1#q!9Y{+##C(,44WbA227;++D&933G<MrL   c                v    t        | j                  j                  d   j                  j	                               S Nr   )tuple_subparsers_group_actionschoiceskeys)rn   s    rJ   find_builtin_commandsr      s/     ##2215==BBDEErL   c                  >     e Zd Zdd fd
Z fdZdd fd
Z xZS )r   T)add_helpc               p    |j                  dt               t        |   |ddi| |rt	        |        y y )Nformatter_classr   F)
setdefaultr   super__init__r   )selfr   r   rH   	__class__s       rJ   r   zArgumentParser.__init__   s<    +-HI$99&9D! rL   c                    |j                   #t        |      r|D ]  }t        |   ||        y t        |   ||       y N)r   r   r   _check_value)r   rC   valueelementr   s       rJ   r   zArgumentParser._check_value   sC    >>%*U*;  6$VW56 G /rL   N)override_argsc                   t        |   |i |}|xs i j                         D ]3  \  }}|t        ust	        ||t              t        u s't        |||       5 |S r   )r   
parse_argsitemsr   r|   setattr)r   r   r   rH   parsed_argsr   r   r   s          rJ   r   zArgumentParser.parse_args   sd    g($9&9)/R668 	2KD%D W[$%E%MT51	2 rL   )__name__
__module____qualname__r   r   r   __classcell__r   s   @rJ   r   r      s    '+ "0 /3  rL   c                  *     e Zd ZdZd fd	Zd Z xZS )rY   zA custom subparser action to conditionally act as a greedy consumer.

    This is a workaround since argparse.REMAINDER does not work as expected,
    see https://github.com/python/cpython/issues/61252.
    c                   t         |   ||||       | j                  |d      }t        |dd      rF	 t        |t        j
                        }t        |t        j
                         t        |      |_	        y y # t        $ r d}Y w xY w)Nr   greedyFrF   )
r   __call___name_parser_mapr|   argparse_UNRECOGNIZED_ARGS_ATTRdelattrAttributeErrorr   rs   )r   rn   	namespacevaluesoption_stringunknownr   s         rJ   r   z _GreedySubParsersAction.__call__   s    FMB&&vay1 68U+!)X-M-MN	8#C#CD
 $GnIO , " s   4A: :BBc                2    t        | j                  d       S )zDSort actions for subcommands to appear alphabetically in help blurb.c                    | j                   S r   )rT   )rC   s    rJ   <lambda>z9_GreedySubParsersAction._get_subactions.<locals>.<lambda>  s
     rL   )key)sorted_choices_actions)r   s    rJ   _get_subactionsz'_GreedySubParsersAction._get_subactions  s    d++1KLLrL   r   )r   r   r   __doc__r   r   r   r   s   @rJ   rY   rY      s    -"MrL   rY   c                >    t        rt        | |      S t        | |      S r   )r   	_exec_win
_exec_unixexecutable_argsenv_varss     rJ   r   r     s    I(KKZ(KKrL   c                   t        | |      }	 |j                          t	        j
                  |j                         y # t        $ r |j                          Y ;w xY w# t	        j
                  |j                         w xY w)N)env)r	   communicateKeyboardInterruptwaitsysexit
returncode)r   r   ps      rJ   r   r     s[    o8,A	 	  	 	s!   ? AA AA !A?c                8    t        j                  | d   | |       y r   )r   execvper   s     rJ   r   r     s    JJq!?H=rL   c                   t         j                  j                         }|j                         D ]  \  }}|t        v r#t
        j                  t        d| d             1| j                  ||j                  |j                  d      }|j                  r|j                  |       	 t        |       nd|_        |j                  |        t         j                   ryt#        t%                     j'                  |      dhz
  }|D ]c  }|t        v r#t
        j                  t        d	| d             .| j                  |d
| dd
| dd      }d|_        |j                  |       e y# t        j                  $ r Y w xY w)a  
    For each of the provided plugin-based subcommands, we'll create
    a new subparser for an improved help printout and calling the
    :meth:`~conda.plugins.types.CondaSubcommand.configure_parser`
    with the newly created subcommand specific argument parser.
    z!
                    The plugin 'z' is trying to override the built-in command
                    with the same name, which is not allowed.

                    Please uninstall the plugin to stop seeing this error message.
                    F)rA   rE   r   T)rr   Nr   z*
                    The (legacy) plugin 'zSee `conda z	 --help`.)rt   )r   r}   get_subcommandsr   BUILTIN_COMMANDSlogerrorr   
add_parsersummaryr+   r   r   ArgumentErrorr   set_defaults
no_pluginssetr   
difference)ro   plugin_subcommandsr   r   rn   legacys         rJ   rm   rm     s    !//??A#5#;#;#= &B ##II!!% '	 '')11"**	 ( 
 --..v6' !FM 	/@AM&BP  !,,-?@E7JF . ##II**. 0	 ''%dV95tfI.	 ( 
 -5.# )) s   'E..FF)returnr   )r   zargparse.Namespacern   r   )r   None)or   
__future__r   r   r   r   r   r   r   ArgumentParserBase	importlibr   loggingr   
subprocessr	   r{   r   auxlib.compatr   
auxlib.ishr   base.contextr   r   r   common.compatr   common.constantsr   deprecationsr   actionsr   r   r   r   helpersr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   
main_cleanr+   r\   main_comparer]   main_configr^   main_creater_   main_envr`   main_exportra   	main_inforb   	main_initrc   main_installrd   	main_listre   main_mock_activaterZ   main_mock_deactivater[   main_noticesrf   main_packagerg   main_removerh   main_renameri   main_runrj   main_searchrk   main_updaterl   r   r   r   escaped_user_rc_pathescaped_sys_rc_pathr   rK   rp   r   r   _SubParsersActionrY   r   r   r   rm   rF   rL   rJ   <module>r     s&   , "  	 
 : #    &  = = " # % 7 9    ( C F D D > D @ @ F @ R V F F D D > D D+|++C6 )k))#t4  .0)X%PF' 0Mh88 M:L>Q.rL   