
    <Bh1                     v   S r SSKrSSKrSSKJr  SSKJrJrJrJ	r	J
r
Jr  SSKJr  SSKJr  SSKJrJr  SS	KJr  SS
KJr  SSKJrJr  SSKJr  SSKJrJrJrJ r J!r!J"r"  SSK#J$r$  SSK%J&r&  SSK'J(r(  SSK)J*r*  \" \+5      r,\" SSSS9SSS\4S j5       r-\" SSSS9SS\4S j5       r.S\/S\04S jr1S4S jr2S5S jr3\Rh                  " S \Rj                  5      r6S! r7S" r8S5S# jr9S$ r:S% r;\S& 5       r<S6S' jr=\" SSS(S9S6S) j5       r>S* r?\" SS+S,S9S\/4S- j5       r@\" SS+S.S9S\/S\/4S/ j5       rAS0 rBS1 rCS2\/4S3 jrDg)7z.Common utilities for conda command line tools.    N)	getLogger)dirnameexistsisdirisfilejoinnormcase   )dals)PREFIX_MAGIC_FILE)contextenv_name)NULL)swallow_broken_pipe)expandpaths_equal)
deprecated)
CondaError"DirectoryNotACondaEnvironmentErrorEnvironmentFileNotFoundEnvironmentLocationNotFoundEnvironmentNotWritableErrorOperationNotAllowed)CONDA_SESSION_SCHEMES)file_path_is_writable)	MatchSpecrenderz25.3z25.9z)Use `conda.reporters.confirm_yn` instead.)addendumProceedyesnor"   c                 r   X!;   d   U5       eU[         L a  [        R                  (       d  U(       a  SSKJn  U" 5       e/ nU H6  nXb:X  a  UR                  SUS    S35        M"  UR                  US   5        M8     SR                  U SR                  U5      5      n UVVs0 s H  owUS   4  H  oU_M     M     nnnX!S'    [        R                  R                  U 5        [        R                  R                  5          [        R                  R                  5       R                  5       R                  5       n	X;  a  [%        S
U	 35        OA[        R                  R                  S5        [        R                  R                  5         X   $ M  s  snnf ! [          a  n
[#        S	U
 35      eS n
A
ff = f)Nr
   
DryRunExit[r   ]z	{} ({})? / zcannot read from stdin: zInvalid choice: 
)r   r   dry_run
exceptionsr&   appendformatr   sysstdoutwriteflushstdinreadlinestriplowerOSErrorr   print)messagechoicesdefaultr,   r&   optionsoptionchoicealtuser_choicees              0lib/python3.13/site-packages/conda/cli/common.pyconfirmrD   (   sx    &w&4GOO+lGNNQvayk+,NN6!9%	 
   #((7*;<G)0PvVAY<OSF{<OsGPBK


!

	=)),,.446<<>K %$[M23JJT"JJ''  Q  	=7s;<<	=s   "F:F 
F6#F11F6c                    U[         L a  [        R                  (       d  U(       a  SSKJn  U" 5       e[        R
                  (       a  g [        U SXS9nUS:X  a  SSKJn  U" S	5      eg! [         a    SSKJn  U" S5      ef = f)
Nr
   r%   Tr!   )r:   r;   r<   r,   )CondaSystemExitz
Operation aborted.  Exiting.r#   zExiting.)	r   r   r,   r-   r&   
always_yesrD   KeyboardInterruptrF   )r:   r<   r,   r&   r?   rF   s         rC   
confirm_ynrI   M   s}     	4GOO+l@]G
 ~0j))  @0>??@s   
A* *Bprefixreturnc                     [         R                  c  g[        U [         R                  5      =(       d.    [        U 5      [        [	        [         R                  5      5      :H  $ )z
Determines whether the args we pass in are pointing to the active prefix.
Can be used a validation step to make sure operations are not being
performed on the active prefix.
F)r   active_prefixr   r	   r   rJ   s    rC   is_active_prefixrO   h   sK     $FG112 	IFx1F1F(GHH    c           
          [        U 5      nUR                  nUR	                  5       (       d5  U(       a.  SSKJn  U" SUS[        U 5       3 SU S[        U5       3 35      e[        U5      $ !   SSKJn  U" SU  35      e= f)Nr
   CondaValueErrorzinvalid package specification: zHversion specifications not allowed with 'update'; use
    conda update  <z  or
    conda install )r   r-   rS   name
_is_simplelenstr)argjsonupdatespecrS   rU   s         rC   arg2specr]   w   s    G~ 99D??0!!%aCz\ 2 3!!$Qs4ykM 24
 	
 t9G0 ?uEFFs   A. .Bc                 >    U Vs/ s H  n[        X!S9PM     sn$ s  snf )N)rZ   )r]   )argsrZ   rY   s      rC   specs_from_argsr`      s    045HS$555s   a  
    (?P<name>[^=<>!\s]+)                # package name
    \s*                                 # ignore spaces
    (
        (?P<cc>=[^=]+(=[^=]+)?)         # conda constraint
        |
        (?P<pc>(?:[=!]=|[><]=?|~=).+)   # new pip-style constraints
    )?$
    c                 F    U R                  S5      S   R                  5       $ )N#r   )splitrstrip)lines    rC   strip_commentrf      s    ::c?1$$&&rP   c                 t   [         R                  [        U 5      5      nUc  g UR                  S5      R	                  5       UR                  S5      UR                  S5      pCnU(       a  X#R                  SS5      -   $ U(       a  UR                  S5      (       a  UR                  S5      S:X  d
   S	U  35       eUR                  S
5      (       d
   SU  35       eUR                  SS5      nS
R                  UR                  S
5      S S 5      S-   nUS-   U-   S-   U-   $ US-   UR                  SS5      -   $ U$ )NrU   ccpc= z~= z~=   z5Overly complex 'Compatible release' spec not handled .z'No '.' in 'Compatible release' version r*   z.*z >=z,==)
spec_patmatchrf   groupr7   replace
startswithcountr   rc   )re   mrU   rh   ri   verver2s          rC   spec_from_linerx      s$   }T*+AyGGFO))+QWWT]AGGDMbD	jjc***	==88D>Q& GvN& 88C==R$KD6"RR=**UB'C88CIIcN3B/047D%<#%-44#:

3 333rP   c                    SSK Jn  SnU" U SS9 n/ n [        U5       H  nUR                  5       nU(       a  UR	                  S5      (       a  M2  US:X  a  SnU(       a  UR                  U5        MT  [        U5      nUc  SSKJn  U" S	U S
U  35      eUR                  U5        M      S S S 5        U$ ! [         a  n	SSKJ
n
  U
" XI5      eS n	A	ff = f! , (       d  f       W$ = f)Nr
   )TmpDownloadF)verboserb   z	@EXPLICITTrR   zcould not parse 'z' in: )CondaFileIOError)gateways.connection.downloadrz   openr6   rs   r.   rx   r-   rS   r8   r|   )urlrZ   rz   explicitpathspecsre   r\   rS   rB   r|   s              rC   specs_from_urlr      s    :H	S%	(D	,T
zz|ts33;&#HLL&%d+<<),=dV6#*OPPT" # 
), L	  	,5"4++	,% 
)	(, Ls)   CBB55
C?CCC
C$c                 ,   ^  [        U 4S jU5       5      $ )Nc              3   N   >#    U  H  oR                  5       S    T;   v   M     g7f)r   N)rc   ).0r\   namess     rC   	<genexpr>!names_in_specs.<locals>.<genexpr>   s     :EDzz|A%'Es   "%)any)r   r   s   ` rC   names_in_specsr      s    :E:::rP   c                 R    U (       a   SR                  SR                  U 5      5      $ g)Nz[{}]rk   r*   )r/   r   )featuress    rC   disp_featuresr      s     }}SXXh/00rP   c                     [        U 5        g Nr   )ds    rC   stdout_jsonr      s	    
1IrP   c                 >   SU 0nUR                  SS 5      nU(       aZ  SU;   a%  US   Vs/ s H  oDR                  5       PM     snUS'   SU;   a%  US   Vs/ s H  oDR                  5       PM     snUS'   X2S'   UR                  U5        [        U5        g s  snf s  snf )NsuccessactionsLINKUNLINK)popdist_fields_dumpr[   r   )r   kwargsresultr   precs        rC   stdout_json_successr      s    !FjjD)GWCJ6?S?4446?SGFOwELXEV WEVT!6!6!8EV WGH#y
MM& T Ws   BBz7Use `conda.reporters.render(style='env_list')` instead.c                     [        U SUS9  g )N	envs_list)styleoutputr   )known_conda_prefixesr   s     rC   print_envs_listr      s     {6BrP   c                      SSK Jn   [        R                  (       d$  U " 5       (       d  SSKJn  U" [        S5      5      eg g )Nr
   )is_admin)r   z
            The create, install, update, and remove operations have been disabled
            on your system for non-privileged users.
        )
common._osr   r   non_admin_enabledr-   r   r   )r   r   s     rC   check_non_adminr      s9    %$$XZZ4!
 	
 .8$rP   z26.3z#Use PrefixData.assert_environment()c                     [        U 5      (       a,  [        [        U [        5      5      (       d  [	        U 5      e U $ [        U 5      e)zVerifies the prefix is a valid conda environment.

:raises EnvironmentLocationNotFound: Non-existent path or not a directory.
:raises DirectoryNotACondaEnvironmentError: Directory is not a conda environment.
:returns: Valid prefix.
:rtype: str
)r   r   r   r   r   r   rN   s    rC   validate_prefixr     sD     V}}d6#45664V<< 7
 M *&11rP   z Use PrefixData.assert_writable()c                     [        U [        5      n[        [        U5      5      (       a  [	        U5      (       a  U $ [        U 5      e)aE  Verifies the environment directory is writable by trying to access
the conda-meta/history file. If this file is not writable then we assume
the whole prefix is not writable and raise an exception.

:raises EnvironmentNotWritableError: Conda does not have permission to write to the prefix
:returns: Valid prefix.
:rtype: str
)r   r   r   r   r   r   )rJ   	test_paths     rC   validate_prefix_is_writabler     s<     V./IWY  %:9%E%E
%f
--rP   c                     [         R                  [         R                  " 5       :w  Ga(  [         R                  " 5       n U R	                  S0 5      R	                  S5      [         R                  :X  a  gU R	                  S0 5      R	                  S5      [         R                  :X  a  g[        [         R                  [         R                  5      (       d}  [        S U R                  5       5       S5      nUR	                  S5      [         R                  :X  a9  [        S[         R                   S[         R                   S35      n[        U5      eggg)	a?  Validates that the configured subdir is ok. A subdir that is different from
the native system is only allowed if it comes from the global configuration, or
from an environment variable.

:raises OperationNotAllowed: Active environment is not allowed to request
                             non-native platform packages
cmd_linesubdirenvvarsc              3      #    U  H4  u  p[        [        R                  UR                  5      (       d  M0  Uv   M6     g 7fr   )r   r   rM   parent)r   r   configs      rC   r   )validate_subdir_config.<locals>.<genexpr>D  s/      (?"7#8#8$++F F(?s   />	>Nz7
                    Active environment configuration (zF) is
                    implicitly requesting a non-native platform (z).
                    Please deactivate first or explicitly request the platform via
                    the --platform=[value] command line flag.
                    )r   r   _native_subdircollect_allgetr   rM   root_prefixnextitemsr   r   )context_sourcesactive_env_configmsgs      rC   validate_subdir_configr   -  s(    ~~//11
 "--/z2.228<N  B/33H=O W22G4G4GHH $(7(=(=(?
 ! !$$X.'..@ 77>7L7L6M NBBI..AQ R *#.. A I 2rP   c                     [         R                  (       d=  [         R                  (       d'  SU ;   a  SU  S3n [        SU  S35      n[	        U5        g g g )Nrk   "zp
            #
            # To activate this environment, use
            #
            #     $ conda activate z
            #
            # To deactivate an active environment, use
            #
            #     $ conda deactivate
            )r   quietrZ   r   r9   )env_name_or_prefixr:   s     rC   print_activater   Y  sZ    ==$$#$%7$8!:$ %7#7 8		
 	g ".=rP   filenamec                     U R                  SS5      S   nUS:X  a  [        U R                  SS5      S   5      n OU[        ;  a  [        U 5      n Og[        U 5      (       d	  [	        U S9eg)aT  
Validate the existence of an environment file.

This function checks if the given ``filename`` exists as an environment file.
If the `filename` has a URL scheme supported by ``CONDA_SESSION_SCHEMES``,
it assumes the file is accessible and returns without further validation.
Otherwise, it expands the given path and verifies its existence. If the file
does not exist, an ``EnvironmentFileNotFound`` exception is raised.

Parameters:
    filename (str): The path or URL of the environment file to validate.

Raises:
    EnvironmentFileNotFound: If the file does not exist and is not a valid URL.
z://rl   r   filern   N)r   )rc   r   r   r   r   )r   
url_schemes     rC   validate_file_existsr   l  sl      q)!,JV(..2267	0	0(#(%x88 rP   )FF)F)T)E__doc__rer0   loggingr   os.pathr   r   r   r   r   r	   
auxlib.ishr   base.constantsr   base.contextr   r   common.constantsr   	common.ior   common.pathr   r   deprecationsr   r-   r   r   r   r   r   r   gateways.connection.sessionr   gateways.disk.testr   models.match_specr   	reportersr   __name__logrD   rI   rX   boolrO   r]   r`   compileVERBOSEro   rf   rx   r   r   r   r   r   r   r   r   r   r   r   r    rP   rC   <module>r      s   5 	 
    . , # + - %  @ 6 )  

8
 }eT (
(@ 

8
 !% 
,S T *6 :: JJ',:;  
 

F
C
C
  FF%JKs  L" FF%GH. . . I.)/X&93 9rP   