
    $TXg`3                       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^ ddl_m9Z`  eea      Zb ej                  dd      Zd ej                  dd      Zeh dZfd%dZgd%dZhd&dZid Zj G d de	      Z G d d ej                        Zld! Zmd" Znd# Zod'd$Zpy)(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%%>   envruninfoinitlistcleanconfigcreateexportremoverenamesearchupdatecompareinstallnoticespackageupgradeactivatecommands	uninstall
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_parserrN   e   sr     & J z"	   A	       c                 f   t        di | }|j                  ddddt         d       |j                  ddd	d
t        d      }t        |       t        |       t        |       t        |       t        |       t        |       t        |       t        |       t        |       t        |       t        |       t!        |       t#        |       t%        |       t'        |       t)        |       t+        |dg       t-        |       t/        |       t1        |       t3        |dg       |S )Nz-Vz	--versionversionzconda z'Show the conda version number and exit.)rF   rQ   rH   COMMANDr@   z=The following built-in and plugins subcommands are available.cmdT)metavartitlerD   destrF   requiredrA   )aliasesr>   rI   )rN   rJ   r   add_subparsers_GreedySubParsersActionconfigure_parser_activateconfigure_parser_cleanconfigure_parser_commandsconfigure_parser_compareconfigure_parser_configconfigure_parser_createconfigure_parser_deactivate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_pluginsconfigure_parser_removeconfigure_parser_renameconfigure_parser_runconfigure_parser_searchconfigure_parser_update)rK   parsersub_parserss      rM   generate_parserrr   }   s    *6*F
&6   ''S& ( K k*;'k*[)K(K(,%K(+&+&[)+&[)[)[)K+?K(%K(K)=MrO   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namerF   invoke_post_commandsr   rw   r   
exceptionsry   _execru   osenvironfuncrsplitr   splitreplace)argsrp   plugin_subcommandresultr   
executablery   module_name	func_namemodulecommands              rM   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<MrO   c                v    t        | j                  j                  d   j                  j	                               S Nr   )tuple_subparsers_group_actionschoiceskeys)rp   s    rM   find_builtin_commandsr      s/     ##2215==BBDEErO   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   rK   	__class__s       rM   r   zArgumentParser.__init__   s<    +-HI$99&9D! rO   c                    |j                   #t        |      r|D ]  }t        |   ||        y t        |   ||       y N)r   r   r   _check_value)r   rF   valueelementr   s       rM   r   zArgumentParser._check_value   s>    >>%*U*; $VW5 ! G /rO   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   rK   parsed_argsr   r   r   s          rM   r   zArgumentParser.parse_args   s_    g($9&9)/R668KD%D W[$%E%MT51 9 rO   )__name__
__module____qualname__r   r   r   __classcell__r   s   @rM   r   r      s    '+ "0 /3  rO   c                  *     e Zd ZdZd fd	Zd Z xZS )rZ   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   greedyFrI   )
r   __call___name_parser_mapr~   argparse_UNRECOGNIZED_ARGS_ATTRdelattrAttributeErrorr   ru   )r   rp   	namespacevaluesoption_stringunknownr   s         rM   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   )rV   )rF   s    rM   <lambda>z9_GreedySubParsersAction._get_subactions.<locals>.<lambda>
  s    rO   )key)sorted_choices_actions)r   s    rM   _get_subactionsz'_GreedySubParsersAction._get_subactions  s    d++1KLLrO   r   )r   r   r   __doc__r   r   r   r   s   @rM   rZ   rZ      s    -"MrO   rZ   c                >    t        rt        | |      S t        | |      S r   )r   	_exec_win
_exec_unixexecutable_argsenv_varss     rM   r   r     s    I(KKZ(KKrO   c                   t        | |      }	 |j                          t	        j
                  |j                         y # t        $ r |j                          Y ;w xY w# t	        j
                  |j                         w xY w)N)r-   )r	   communicateKeyboardInterruptwaitsysexit
returncode)r   r   ps      rM   r   r     s[    o8,A	 	  	 	s!   ? AA AA !A?c                8    t        j                  | d   | |       y r   )r   execvper   s     rM   r   r     s    JJq!?H=rO   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)rD   rH   r   T)rt   Nr-   z*
                    The (legacy) plugin 'zSee `conda z	 --help`.)rv   )r   r   get_subcommandsr   BUILTIN_COMMANDSlogerrorr   
add_parsersummaryr+   r   r   ArgumentErrorr   set_defaults
no_pluginssetr   
difference)rq   plugin_subcommandsr   r   rp   legacys         rM   rj   rj     s    !//??A#5#;#;#= ##II!!% '	 '')11"**	 ( 
 --..v6' !FM 	/@AM $>P  !,,-?@E7JF ##II**. 0	 ''%dV95tfI.	 ( 
 -5 # )) s   'E..FF)returnr   )r   zargparse.Namespacerp   r   )r   None)qr   
__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_commandsr]   main_comparer^   main_configr_   main_creater`   main_envrb   main_exportrc   	main_inford   	main_initre   main_installrf   	main_listrg   main_mock_activater[   main_mock_deactivatera   main_noticesrh   main_packageri   main_removerk   main_renamerl   main_runrm   main_searchrn   main_updatero   r   r   r   escaped_user_rc_pathescaped_sys_rc_pathr   rN   rr   r   r   _SubParsersActionrZ   r   r   r   rj   rI   rO   rM   <module>r     s)   , "  	 
 : #    &  = = " # % 7 9    ( C H F D D > D @ @ F @ M Q F F D D > D D+|++C6 )k))#t4  40*Z%PF' 0Mh88 M:L>Q.rO   