
    DIe`
                       d 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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  ej        ddd           ej        ddd          dd                        ZdddZd ZdS )zCLI implementation for `conda rename`.

Renames an existing environment by cloning it and then removing the original environment.
    )annotationsN)partial)Path   )DRY_RUN_PREFIX)contextvalidate_prefix_name)install)expand)
deprecated)CondaEnvException)rm_rf)rename_contextz24.3z24.9nameprefixreturnstrc                 .   t          t          j                                      t          j                  rt          d          t          t          j                                      t          j                  rt          d          t          j        S )z
    Validate that we are receiving at least one value for --name or --prefix
    and ensure that the "base" environment is not being renamed
    z(The 'base' environment cannot be renamedz$Cannot rename the active environment)r   r   target_prefixsamefileroot_prefixr   active_prefix     5lib/python3.11/site-packages/conda/cli/main_rename.pyvalidate_srcr      su     G!""++G,?@@ L JKKKG!""++G,ABB H FGGG  r   Fdestforceboolc                P   t           j        | v rt          |           } nt          | t          d          } |snt           j                            |           rOt           j                            t           j                            |                     }t          d| d          | S )z*Ensure that our destination does not existF)ctx
allow_basezThe environment 'z(' already exists. Override with --force.)
ossepr   r	   r   pathexistsbasenamenormpathr   )r   r   env_names      r   validate_destinationr*   '   s    	v~~d||#Dg%HHH 
RW^^D)) 
7##BG$4$4T$:$:;;RRRR
 
 	
 Kr   c                    t                      t           j         j                   fd} j        r;t	           j                  5   |             ddd           dS # 1 swxY w Y   dS  |             dS )z:Executes the command for renaming an existing environment.)r   c            
     @   t          t          j        t          j        t          j                  t          t                    f} | D ]R}j        r?t          t           d|j
        j         dd                    |j                              H |             Sd S )N)quietjson ,)r   r
   cloner   r-   r.   r   dry_runprintr   func__name__joinargs)actionsr4   r7   destinationsources     r   clone_and_removez!execute.<locals>.clone_and_remove;   s    m\   E6""	(
  	 	D| TT$)*<TTsxx	?R?RTTUUUU		 	r   )r2   N)r   r*   r9   r   r   r2   )r7   _r;   r9   r:   s   `  @@r   executer=   6   s    ^^F&t'7tzJJJK      & z K>>> 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A))A-0A-)r   r   )F)r   r   r   r   r   r   )__doc__
__future__r   r#   	functoolsr   pathlibr   base.constantsr   base.contextr   r	   clir
   common.pathr   deprecationsr   
exceptionsr   gateways.disk.deleter   gateways.disk.updater   argumentr   r*   r=   r   r   r   <module>rK      sf    # " " " " " 				             + + + + + + 8 8 8 8 8 8 8 8                   % % % % % % * * * * * * ( ( ( ( ( ( 1 1 1 1 1 1 VVV,,VVX..! ! ! /. -,!        r   