
    $TXgg                    D   d Z ddlmZ ddlZddlZddl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mZ dd	lmZ dd
lmZ ddlmZ ddlmZ erddlmZmZmZ ddlmZ ddZd dZd Z d Z!d Z"d Z#i g d	 	 	 	 	 	 	 	 	 d!dZ$d"dZ%d"dZ&d#dZ'd$dZ(d%dZ)d&dZ*d Z+y)'zCLI implementation for `conda config`.

Allows for programmatically interacting with conda's configuration files (e.g., `~/.condarc`).
    )annotationsN)SUPPRESS)MappingSequence)chain)	getLogger)isfilejoin)Path)wrap)TYPE_CHECKING   )DEFAULTS_CHANNEL_NAME)ArgumentParser	Namespace_SubParsersAction)Anyc           	        ddl m} ddlm} ddlm}m}m} ddlm	} ddl
m} |j                  dd	      }	|j                  dd	      }
d
} |d| d|	 d      } |d| d      } | j                  	 dF|||d|} ||       |j                  dd|	 d      }|j                         }|j!                  ddd|
 d       |j!                  dddj#                  |j$                  xs d|	             |j!                  ddd       |j                  d      }|j                         }|j!                  d d!d d"#       |j!                  d$dd%       |j!                  d&dd'       |j!                  d(d!d d)#       |j!                  d*dd+       |j                  d,      }|j                         }|j!                  d-d!dd.d d/0       |j!                  d1dd2d3g d40       |j!                  d5d6dd2d7g d40       |j!                  d8dd2d9g d40       |j!                  d:dd2d;g d40       |j!                  d<d2d=g d/>       |j!                  d?dd@       |j!                  dAdBd|t&        C       |j)                  dDE       |S )GNr   )dals)CONDA_HOMEPAGE_URL)contextsys_rc_pathuser_rc_path)NULL   )add_parser_json%z%%z(Modify configuration values in .condarc.z	
        zc

        This is modeled after the git config command.  Writes to the user .condarc
        file (z) by default. Use the
        --show-sources flag to display all identified configuration locations on
        your computer.

        z*
        See `conda config --describe` or a  /docs/config.html
        for details on all the options that can go in .condarc.

        Examples:

        Display all configuration values as calculated and compiled::

            conda config --show

        Display all identified configuration sources::

            conda config --show-sources

        Print the descriptions of all available configuration
        options to your command line::

            conda config --describe

        Print the description for the "channel_priority" configuration
        option to your command line::

            conda config --describe channel_priority

        Add the conda-canary channel::

            conda config --add channels conda-canary

        Set the output verbosity to level 3 (highest) for
        the current activate environment::

            conda config --set verbosity 3 --env

        Add the 'conda-forge' channel as a backup to 'defaults'::

            conda config --append channels conda-forge

        )helpdescriptionepilogzConfig File Location Selectionz5Without one of these flags, the user config file at 'z
' is used.z--system
store_truez&Write to the system .condarc file at 'z'.)actionr   z--envzzWrite to the active conda environment .condarc file ({}). If no environment is active, write to the user config file ({}).z<no active environment>z--filestorezWrite to the given file.zConfig Subcommandsz--show*z~Display configuration values as calculated and compiled. If no arguments given, show information for all configuration values.)nargsdefaultr   z--show-sourcesz-Display all identified configuration sources.z
--validatezcValidate all configuration sources. Iterates over all .condarc files and checks for parsing errors.z
--describezrDescribe given configuration parameters. If no arguments given, show information for all configuration parameters.z--write-defaultz`Write the default configuration to a file. Equivalent to `conda config --describe > ~/.condarc`.zConfig Modifiersz--getzGet a configuration value.KEY)r%   r"   r   r&   metavarz--appendappendz5Add one configuration value to the end of a list key.)r'   VALUEz	--prepend--addz;Add one configuration value to the beginning of a list key.--setzSet a boolean or string key.z--removezfRemove a configuration value from a list key.
                This removes all instances of the value.z--remove-keyz0Remove a configuration key (and all its values).)r"   r   r&   r(   z--stdinzIApply configuration information given in yaml format piped through stdin.z-fz--force)r"   r&   r   zconda.cli.main_config.execute)func)config)
auxlib.ishr   base.constantsr   base.contextr   r   r   common.constantsr   helpersr   replace
add_parseradd_argument_groupadd_mutually_exclusive_groupadd_argumentformatactive_prefixr   set_defaults)sub_parserskwargsr   r   r   r   r   r   r   escaped_user_rc_pathescaped_sys_rc_pathsummaryr   r    pconfig_file_location_grouplocation_config_subcommandsconfig_subcommands_config_modifiersconfig_modifierss                        5lib/python3.12/site-packages/conda/cli/main_config.pyconfigure_parserrI      s   !3AA'('//T:%--c488G			  $$ %			
K **<)= $>	%	'FR 				
 	A A "#!5!5(
?@T?UU_`" *FFHH56I5J"M  
 6!!>%> 
  	 (79ST
 ../CD,IIK##P	 $  ##< $ 
 ##) $  ##8	 $  ##@ $  ,,-?@(EEG!!) "  !!H  "  !!N  "  !!/  "  !!<  "  !!C "  !!X "  NN   NN7N8H    c                j    ddl m} ddlm} 	 t	        | |      S # |t
        f$ r} ||      d }~ww xY w)Nr   
CondaErrorCouldntParseError) rM   
exceptionsrO   execute_configNotImplementedError)argsparserrM   rO   es        rH   executerW      s:    .dF++23 ms    2-2c                   ddl m} ddlm}m} g }| j                         D ]  \  }}t        |t              rC|r,|j                  | d       |j                   ||             D|j                  | d       Y ||      rC|r,|j                  | d       |j                   ||             |j                  | d       |j                  dj                  |||nd              |S )	Nr   )
isiterable)pretty_list
pretty_map:z: {}z: []z{}: {}None)
common.compatrY   common.configurationrZ   r[   items
isinstancer   r)   r9   )drY   rZ   r[   lineskvs          rH   format_dictrf      s    *>E	1a!s!W%Z]+s&\*]s!W%[^,s$Z(LLAFKL  LrJ   c                   ddl m} ddlm} ddlm} g }|j                  |       }|d   }|j                  d      }|d   }t        j                  |d   |	      }	|d
   dk(  rH|j                  dj                  | dj                  t        |D 
ch c]  }
|
 c}
                         nK|j                  dj                  | |d
   dj                  t        |D 
ch c]  }
|
 c}
                         |r/|j                  dj                  dj                  |                   |r|j                  d| d       |j                  d t        |d   d      D               |j                  d       |D cg c]  }d|z   	 }}|j                   || t        j                   |	      i      j#                         j%                  d             |D cg c]  }d|z   	 }}|j                  d       |S c c}
w c c}
w c c}w c c}w )Nr   EntityEncoderr   )yaml_round_trip_dumpaliasesstring_delimiterelement_typesdefault_value)clsparameter_type	primitivez{} ({})z, z{} ({}: {})z  aliases: {}z  env var string delimiter: ''c              3  &   K   | ]	  }d |z     yw)z  N ).0lines     rH   	<genexpr>z0parameter_description_builder.<locals>.<genexpr>&  s     L+K44$;+Ks   r   F   rP   z# 
)auxlib.entityri   r1   r   common.serializerk   describe_parametergetjsondumpsr)   r9   r
   sortedextendr   loadsstripsplit)nameri   r   rk   builderdetailsrl   rm   rn   default_value_stretrw   s               rH   parameter_description_builderr     s   -&7G((.Gi G{{#56O,M

7?#;O K/T499V-4P-BR-4P-Q#RS	
 	  ()		&}!=}"}!=>?	
 --dii.@AB67G6HJKNNL40F+KLLNN2'./wttd{wG/NNdDJJ/@$ABCIIKQQRVW (//wttd{wG/NN2N7 5Q "> 0 0s   	G4	G98G>Hc                    ddl m}  g }d}| j                  j                         D ]  \  }}||v r|j	                  d       |j	                  d|dd       |j	                  d       |j	                  d       |j                  t        j                  d	 |D                     |j	                  d        d
j                  |      S )Nr   rj   zCLI-onlyzHidden and Undocumentedz8# ######################################################z# ## z^48z ##rP   c              3  2   K   | ]  }t        |        y wNr   rv   r   s     rH   rx   z*describe_all_parameters.<locals>.<genexpr>A  s       @O-d3   rz   )	r1   r   category_mapr`   r)   r   r   from_iterabler
   )r   r   skip_categoriescategoryparameter_namess        rH   describe_all_parametersr   4  s    &G=O%,%9%9%?%?%A!/&QRxnC01QRr  @O  	

 	r &B 99WrJ   c           
     Z   t        d      j                  }t        |t        f      r+|j	                         D ]  \  }}t        | dz   |z   |        y t        |t        t        t        f      r$ |dj                  d| t        |      f             y t        |t        t        f      rt        |      }t        t        |            D ]b  \  }}| dk(  r5|d|dz
  fv r, |dj                  d| t        |      |dk(  rd	nd
f             @ |dj                  d| t        |      f             d y y )Nconda.stdout. r,   channelsr   r   r+   z  # lowest priorityz  # highest priority)r   infora   dictr`   print_config_itemboolintstrr
   listtuplelen	enumeratereversedrepr)keyvaluestdout_writerd   re   numitemsqitems           rH   r   r   I  s   ^,11L%$!KKMDAqcCi!mQ/ "	ED#s+	,SXXwSZ89:	ED%=	) u: %1GAtj Q1hl*;%;HH# J56!V1AW		 SXXwT$Z&@AB 2 
*rJ   r   warningsc               b   ddl m} | j                  d      }|d   |j                         vrF|j                  r|j                  d|d          y t        d|d   t        j                         y |}	 |D ]  }||   }	 	 |j                  r||| <   y t        | |       y # t        $ r Y y w xY w)Nr   rj   r   r   zUnknown key: )file)r1   r   r   list_parametersr   r)   printsysstderrr   KeyError)r   r.   r   r   r   	key_parts
sub_configparts           rH   _get_keyr   e  s     '		#I|72244<<OOmIaL+;<= 	 M)A,!12DJ
/D#D)J  <<"DIc:.  s   6B" "	B.-B.c                n   ddl m} | j                  d      }	 |j                  |d         d   }|dk(  r)t        |      d	k(  r|\  } |j                  | |d
      || <   y |dk(  r)t        |      dk(  r|\  } }||j                  | i       |<   y ddlm}  || d      # t        $ r ddlm}  || d      w xY w)Nr   rj   r   r   rq   CondaKeyErrorunknown parameterrr   r   z--set parametermapinvalid parameter)
r1   r   r   r}   r   rQ   r   r   typify_parameter
setdefault)r   r   r.   r   r   rq   r   subkeys           rH   _set_keyr     s    &		#I6 33IaLABRS $Y1)<..sD:KLs	5	 S^q%8V-1#r"6*.C!455  6.C!455	6s   B B4c                   ddl m} | j                  d      }	 |j                  |d         d   }|dk(  rgt        |      d	k(  rY|\  } | |vr| d
k7  rddlm}  || d      dg|| <   |||    vrddlm}  || d|d      ||    D cg c]
  }||k7  s	| c}|| <   y ddlm}  || d      # t        $ r ddlm}  || d      w xY wc c}w )Nr   rj   r   r   rq   r   r   sequencer   r   undefined in configdefaultszvalue z not present in configr   )r1   r   r   r}   r   rQ   r   r   )r   r   r.   r   r   rq   r   is           rH   _remove_itemr     s    &		#I6 33IaLABRS #I!(;fj 6#C)>??%,F3Kvc{"2vdX5K%LMM"(+;+Qdq+;s.C!455/  6.C!455	6& <s   B+ 
CC+Cc                    | j                  d      }|}	 |d d D ]  }||   }	 ||d   = y # t        $ r ddlm}  || d      w xY w)Nr   r   r   r   )r   r   rQ   r   )r   r.   r   r   r   r   s         rH   _remove_keyr     s_    		#IJ8crND#D)J #y}% 8.C!677	8s	   + Ac                x    ddl m} 	  |t        |       j                               xs i S # t        $ r i cY S w xY w)Nr   yaml_round_trip_load)r|   r   r   	read_textFileNotFoundError)pathr   s     rH   _read_rcr     s;    7#DJ$8$8$:;ArA 	s   "+ 99c                   ddl m} ddlm}m}m}m}m}m} ddl	m
}	m}
 d }|	j                  j                  j                  ||       |	j                  j                  j                  ||       |	j                  j                  j                  ||       |	j                  j                  j                  ||       |	j                  j                  j                  ||       |	j                  j                  j                  ||       	 t        |       j!                   |
|             y # t"        $ r} |d|  d|      d }~ww xY w)Nr   rL   )ChannelPriorityDepsModifierPathConflictSafetyChecksSatSolverChoiceUpdateModifier)yamlrk   c                6    | j                  t        |            S r   )represent_strr   )dumperdatas     rH   enum_representerz#_write_rc.<locals>.enum_representer  s    ##CI..rJ   z Cannot write to condarc file at z
Caused by )rP   rM   r0   r   r   r   r   r   r   r|   r   rk   representerRoundTripRepresenteradd_representerr   
write_textOSError)r   r.   rM   r   r   r   r   r   r   r   rk   r   rV   s                rH   	_write_rcr     s.     >/ 	))99& 	))99& 	))99& 	))99( 	))99) 	))99)UT
26:; U;D6aUSTTUs    D( (	E1D??Ec                `    t        |       }|D ]  \  }}t        |||        t        | |       y r   )r   r   r   )r   rT   r.   r   r   s        rH   set_keysr     s/    d^F
UeV$ dFrJ   c                <  678 ddl m} ddlm} ddlm}m6m}m} ddl	m
} ddlm} ddlm}	 t        d      j                   }
t        d	      j                   }g }i }| j"                  r6j$                  rZ |
t%        j&                  6j)                         j+                         D ci c]  \  }}t-        |      | c}}d
dd|             y g }6j)                         j+                         D ]E  \  }}|j/                  d| d       |j1                  t3        |             |j/                  d       G  |
dj5                  |             y | j6                  | j6                  rR| j6                  }6j9                         }t;        |      t;        |      z
  }|r-ddl	m} ddlm }  |d ||             6j9                         }|D ci c]  }|tC        6|       }}6j$                  r! |
t%        j&                  |d
dd|             nd|v rH|d   jE                         D ci c](  }|jF                  |jH                   d|jJ                   * c}|d<   d|v r8ddl	m} |d   j+                         D ci c]  \  }}| ||d       c}}|d<   d|v rd7tM        7fd|d   D              |d<    |
dj5                  t3        |                   6jO                          y | jP                  | jP                  r| jP                  }6j9                         }t;        |      t;        |      z
  }|rddl	m} ddlm }  |d ||             6j$                  r> |
t%        j&                  |D cg c]  }6jS                  |       c}d
dd|             y g }|j1                  tU        jV                  d |D                      |
dj5                  |             y 6j$                  rd8tY        tU        jV                  8fd6jZ                  j+                         D                    } |
t%        j&                  |D cg c]  }6jS                  |       c}d
dd|             y  |
t]                      y | j^                  r6ja                          y | jb                  r|}nM| jd                  r&6jf                  rt5        6jf                  d      }n|}n| jh                  r| jh                  }n|}| jj                  rztm        |      r@to        |      5 }|jq                         js                         } d d d         r |d | d!      to        |d"      5 }|ju                  t]                      d d d        y tv        jx                  j{                  |      r!to        |      5 } |	|      xs i }!d d d        nBtv        jx                  j{                  |      r!to        |      5 } |	|      xs i }!d d d        ni }! |6fd#6j9                               }"|"d$   }#|"d%   }$| j|                  K6ja                          | j|                  xs tY        !j                               D ]  }t        |!||&        | j                  r> |d't        j                  jp                        }%|%sy 	  |	|%      }&!j                  |&       t        | j                  | j.                  fd*      D ]  \  }(})|(D ]  \  }}*d+|v r|j                  d+d,      n|d f\  }}+|d-k(  xr |!v},|,r|*t        k7  r |        t        g!|<   ||#v r!j                  |g       }-n9||$v r#!j                  |i       j                  |+g       }-ndd.lmK}.  |.d/| d0      t        |-t              rt        |-t,              r.dd1lmN}/ |!|   j                  j                  }0 |/d2|d3|0 d+      |*|-v r|,r
|*t        k(  r|+|d+z   |+z   n|}1|)rd4nd5}2d6|* d7|1 d8|2 }3|+|-D 4cg c]
  }4|4|*k7  s	|4 c}4x}-|!|<   n|-D 4cg c]
  }4|4|*k7  s	|4 c}4x}-|!|   |+<   6j$                  s	 ||3       n|j/                  |3       |-j                  |)rd9n
t        |-      |*         | j:                  D ]  \  }}*t        ||*!        | j                  D ]  \  }}*t        ||*!        | j                  D ]  }t        |!        | j|                  st        |!       6j$                  rd,d:lYmZ}5  |5|||;       y y c c}}w c c}w c c}w c c}}w c c}w c c}w # 1 sw Y   xY w# 1 sw Y   y xY w# 1 sw Y   fxY w# 1 sw Y   sxY w# t        $ r dd(lmE}'  |'d)|%       w xY wc c}4w c c}4w )<Nr   rL   rh   )_warn_defaults_deprecationr   r   r   )timeout)groupby_to_dictr   r   zconda.stderrT),z: )	sort_keysindent
separatorsrp   z==> z <==rP   rz   )dashlist)ArgumentErrorz"Invalid configuration parameters: custom_channelsz://custom_multichannels   )r   channel_settingsz    c              3  X   K   | ]!  }d  j                  t        |             # yw)rz   N)r
   rf   )rv   mappingidents     rH   rx   z!execute_config.<locals>.<genexpr>\  s/      .#8 L%%k'&:;#8s   '*c              3  2   K   | ]  }t        |        y wr   r   r   s     rH   rx   z!execute_config.<locals>.<genexpr>~  s      (HW5d;r   r   c              3  0   K   | ]  \  }}|vr|  y wr   ru   )rv   r   r   r   s      rH   rx   z!execute_config.<locals>.<genexpr>  s&      (9U5Ho#?: (9Us   z.condarcz
The file 'z' already contains configuration information.
Remove the file to proceed.
Use `conda config --describe` to display default configuration.wc                ,    j                  |       d   S )Nrq   )r}   )rA   r   s    rH   <lambda>z execute_config.<locals>.<lambda>  s    ',,Q/0@ArJ   r   r   r      )
ParseErrorzinvalid yaml content:
)TFr   r   r   )CondaValueErrorzKey 'z$' is not a known sequence parameter.rN   zkey z should be a list, not topbottomz
Warning: 'z' already in 'z' list, moving to the r   )stdout_json_success)rc_pathr   r~   )[rP   rM   r{   ri   r1   r   r   r   r   	common.ior   common.iteratorsr   r|   r   r   r   show_sourcesr   r   collect_allr`   r   r)   r   rf   r
   showr   setr   rQ   r   getattrvaluesr   schemerC   r   validate_configurationdescriber}   r   r   r   r   r   validatevalidate_allsystemenvr:   r   write_defaultr	   openreadr   writeosr   existsr~   keysr   stdinr   update	Exceptionr  zipprependr   r   r   r  ra   r   rO   	__class____name__insertr   r   remover   
remove_keyr   r   commonr  )9rT   rU   rM   ri   r   r   r   r   groupbyr   r   stderr_writejson_warningsjson_getsourcer  rc   reprsparamater_names	all_names
not_paramsr   r   r   rb   channelmultichannel_namer   r   r   r  fhr   	rc_configgrouped_paramaterssequence_parametersmap_parameterscontentparsedr  argr#  r   r   channels_is_unpopulatedarglistr  rO   badmessage_keyrC   messagerA   r  r   r   r   s9                                                         @@@rH   rR   rR   	  so	   -  $=7^,11L^,11LMH<<

 /6.A.A.C.I.I.K.KNFF FV+.K #*%	& 	 E!(!4!4!6!<!<!>tF8401[/0R  "? 5)*yy99"iiO//1I_-I>J06#8*9M8NO  &557O3BC?CS''3''?C<<

"*% !A% $%%6#7#>#>#@(#@ LLW^^$4C8H8H7I"JJ#@(#$ &*0 899O7P7V7V7X-7X3)8 &x'CC7X-() "Q&(- .#$%7#8. )$%
 ;q>23&&(}} =="mmO//1I_-I>J06#8*9M8NO  ||JJFUVod33D9oV"& #.)L 	9 '' (HW( 
 TYYw/0, 	) ||"I"('' (9@9M9M9S9S9U( # JJFUVod33D9oV"& #.) 	 467}}{{	  700*=G"G	))'?g"wwy(   	 *V V  '32HH,./   
ww~~g']b,R06BI ] 
	$+",R06BI  	 A! -Z8'.N xx887vinn&677CS)(]K 8 zz!SYY^^,	B)'2FV$ T\\4;;7GWIC/2cz#))C+T{KC&)Z&7&PCy<P#& 00.0"7!8	#))#..sB7&#..sB7BB62N8%cU2V&WXXw1*Wc:R:n..77'$sg5LSEQR(STTw*t7L/L4:4FcCi&0C$+5&tfN;-G]^f]gh>;B/P7aa4i7/PPGinCJ7X7aaSWi77XXGinV4|| )!((1NN1S\4@W  H^ XX	TdI&  [[	TS$	* ! C#  88'9%||/GmR CD D(-< W6 W:    ]
 6  	B/6wi@AA	BV 0Q7Xsx   &d#d))-d.<d35d9d>ee(e(e),e6 
ff(
f3feee&)e36f)r<   r   returnr   )rT   r   rU   r   rB  r   )
r   r   r.   r   r   zdict[str, Any]r   z	list[str]rB  r]   )r   r   r   r   r.   r   rB  r]   )r   r   r.   r   rB  r]   )r   str | os.PathLike | PathrB  r   )r   rC  r.   r   rB  r]   )rT   ztuple[str, Any]r   rC  rB  r]   ),__doc__
__future__r   r   r  r   argparser   collections.abcr   r   	itertoolsr   loggingr   os.pathr	   r
   pathlibr   textwrapr   typingr   r0   r   r   r   r   r   rI   rW   rf   r   r   r   r   r   r   r   r   r   r   rR   ru   rJ   rH   <module>rN     s   
 #  	 
  -         2EEGT.)X*C@ /	// 	/
 / 
/@606@8)UXZSrJ   