
    <Bh@                        S r SSKJr  SSK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  \	(       a
  SS	KJrJrJr  SS
 jr\" SSSS9SSS jj5       r\" SSSS9SS j5       r\" SSSS9SSS jj5       rSS jrg)zCLI implementation for `conda rename`.

Renames an existing environment by cloning it and then removing the original environment.
    )annotationsN)partial)Path)TYPE_CHECKING)
deprecatedCondaEnvException)ArgumentParser	Namespace_SubParsersActionc                    SSK Jn  SSKJnJn  SnU" SU S35      nU" S5      nU R
                  "  SUUUS	.UD6nU" U5        UR                  S
SS9  U" U5        UR                  SS9  U$ )N   )dals   )add_output_and_prompt_optionsadd_parser_prefixzRename an existing environment.z	
        z

        This command renames a conda environment via its name (-n/--name) or
        its prefix (-p/--prefix).

        The base environment and the currently-active environment cannot be renamed.
        z
        Examples::

            conda rename -n test123 test321

            conda rename --name test123 test321

            conda rename -p path/to/test123 test321

            conda rename --prefix path/to/test123 test321

        )helpdescriptionepilogdestinationz#New name for the conda environment.)r   zconda.cli.main_rename.execute)func)rename)
auxlib.ishr   helpersr   r   
add_parseradd_argumentset_defaults)	sub_parserskwargsr   r   r   summaryr   r   ps	            5lib/python3.13/site-packages/conda/cli/main_rename.pyconfigure_parserr#      s    !I/G			 			K 	F 				
 	A aNN='LNM!!$NN7N8H    z25.9z26.3zUse PrefixData.validate_path())addendumc                p    SSK Jn  U" [        U 5      R                  5      (       a  [	        SU  S3U5      eg)zBEnsure that the new prefix does not contain protected directories.r   )is_conda_environmentzThe specified prefix 'aB  ' appears to be a top level directory within an existing conda environment (i.e., {history_file} exists). Creating an environment in this location has the potential to irreversibly corrupt your conda installation and/or other conda environments, please choose a different location for your new conda environment. Aborting.N)conda.gateways.disk.testr'   r   parentr	   )prefixjsonr'   s      r"   check_protected_dirsr,   G   sD     >DL//00$VH -/ / 
 	
 1r$   z:Use PrefixData.validate_path(), PrefixData.validate_name()c                 N   SSK Jn   SSKJn  [	        U R
                  5      nU" U5        UR                  U R                  5      (       a  [        S5      eU R                  (       a+  UR                  U R                  5      (       a  [        S5      e[        U5        [        U5      $ )z
Ensure that we are receiving at least one valid value for the environment
to be renamed and that the "base" environment is not being renamed
r   contextr   )validate_prefix_exists(The 'base' environment cannot be renamed$Cannot rename the active environment)base.contextr/   installr0   r   target_prefixsamefileroot_prefixr	   active_prefixr,   str)r/   r0   r*   s      r"   validate_srcr:   X   s~     '/'''(F6"w**++ JKK1F1F!G!G FGGV$v;r$   z25.3z4Use `conda.cli.install.validate_new_prefix` instead.c                \   SSK JnJn  SSKJn  SSKJn  [        R                  U ;   a	  U" U 5      n OU" XSS9n U(       dl  [        R                  R                  U 5      (       aH  [        R                  R                  [        R                  R                  U 5      5      nU" SU S35      eU $ )	z*Ensure that our destination does not existr   )r/   validate_prefix_name)expandr   F)ctx
allow_baseThe environment '&' already exists. Override with --yes.)r3   r/   r<   common.pathr=   
exceptionsr	   osseppathexistsbasenamenormpath)destforcer/   r<   r=   r	   env_names          r"   validate_destinationrM   r   s     =$.	vv~d|#D%HRWW^^D))77##BGG$4$4T$:;z)OP
 	
 Kr$   c                  ^ ^^^	^
^^ SSK Jm  SSKJm  SSKJm
  SSKJn  SSKJ	m  SSK
Jn  UR                  5       nUR                  5         UR                  5       (       a  [        S5      eTR                   (       a5  UR"                  R%                  TR                   5      (       a  [        S	5      e['        UR"                  5      m[(        R*                  T R,                  ;   a"  U" T R,                  5      nUR/                  S
S9  OUR1                  T R,                  5      n['        UR"                  5      m	T R2                  (       d.  UR5                  5       (       a  [        SUR"                   S35      eSUU UU	U
UU4S jjnT R2                  (       a"  U" T	T R6                  S9   U" 5         SSS5        gU" 5         g! , (       d  f       g= f)z:Executes the command for renaming an existing environment.r   )DRY_RUN_PREFIXr.   )r4   )
PrefixData)rm_rf)rename_contextr1   r2   T)expand_pathr@   rA   c            
     :  > [        TR                  TTTR                  TR                  S9[        TT5      4n U  H]  nTR                  (       aB  [        T SUR                  R                   SSR                  UR                  5       35        MV  U" 5         M_     g )N)quietr+    ,)
r   clonerU   r+   dry_runprintr   __name__joinargs)	actionsr   rO   r]   r/   r   r4   rQ   sources	     r"   clone_and_remove!execute.<locals>.clone_and_remove   s    mm\\ E6"	(
 D||($))*<*<)=Qsxx		?R>STU	 r$   )rY   Nr   )returnNone)base.constantsrO   r3   r/   clir4   core.prefix_datarP   gateways.disk.deleterQ   gateways.disk.updaterR   from_contextassert_environmentis_baser	   r8   prefix_pathr6   r9   rD   rE   r   validate_path	from_nameyesrG   rY   )r]   parserrP   rR   source_prefix_datadest_prefix_datar`   rO   r/   r   r4   rQ   r_   s   `      @@@@@@r"   executers      sw   /&-,5 $002))+!!## JKK!3!?!?!H!H" "   FGG#//0F 
vv!!!%d&6&67&&4&8%//0@0@A&223K88(//11 0 < <==cd
 	
 & xxK> ?  		 ?> s   &F??
G)r   r   rb   r
   )F)r*   z
str | Pathr+   boolrb   rc   )rb   r9   )rJ   r9   rK   rt   rb   r9   )r]   r   rp   r
   rb   int)__doc__
__future__r   rD   	functoolsr   pathlibr   typingr   conda.deprecationsr   conda.exceptionsr	   argparser
   r   r   r#   r,   r:   rM   rs    r$   r"   <module>r      s   
 # 	     ) .EE.b FF%EF
 G
  

I

* 

C

$8r$   