
    c3                        d dl Z d dl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ZdZd	Zd
                    d                    d  ej                    D                                 ZdZd Z eeeee          Zd Zd Zd Zd Zd Zd Zd ZdZdZ dZ! eee ee!          Z"d Z#d Z$dZ% eeeee%          Z&d Z'd Z(dS )     Nwith_directory_contents)#assert_identical_except_blank_lines)ProjectFileDEFAULT_PROJECT_FILENAMEpossible_project_file_namesEnvSpec)	conda_apia8  # This is an Anaconda project file.
#
# Here you can describe your project and how to run it.
# Use `anaconda-project run` to run the project.
# The file is in YAML format, please see http://www.yaml.org/start.html for more.
#

#
# Set the 'name' key to name your project
#
name: <NAME>
#
# Set the 'icon' key to give your project an icon
#
icon:
#
# Set a one-sentence-or-so 'description' key with project details
#
description:
#
# In the commands section, list your runnable scripts, notebooks, and other code.
# Use `anaconda-project add-command` to add commands.
#
commands: {}
#
# In the variables section, list any environment variables your code depends on.
# Use `anaconda-project add-variable` to add variables.
#
variables: {}
#
# In the services section, list any services that should be
# available before your code runs.
# Use `anaconda-project add-service` to add services.
#
services: {}
#
# In the downloads section, list any URLs to download to local files
# before your code runs.
# Use `anaconda-project add-download` to add downloads.
#
downloads: {}
%s%s%s%sz#
# In the packages section, list any packages that must be installed
# before your code runs.
# Use `anaconda-project add-packages` to add packages.
#
packages: []
z#
# In the channels section, list any Conda channel URLs to be searched
# for packages.
#
# For example,
#
# channels:
#    - mychannel
#
channels: []
z#
# In the platforms section, list platforms the project should work on
# Examples: "linux-64", "osx-64", "win-64"
# Use `anaconda-project add-platforms` to add platforms.
#
platforms:
{platforms}

c                 :    g | ]}d                      |          S )z- {p})p)format).0r   s     Glib/python3.11/site-packages/anaconda_project/test/test_project_file.py
<listcomp>r   W   s&    hhh 3 3hhh    )	platformsa
  #
# You can define multiple, named environment specs.
# Each inherits any global packages or channels,
# but can have its own unique ones also.
# Use `anaconda-project add-env-spec` to add environment specs.
#
env_specs:
  default:
    packages: []
    channels: []
c                     t           | |||fz  S N)expected_default_file_templatepackageschannelsr   	env_specss       r   _make_file_contentsr   f   s    )XxI,VVVr   r   c                  D    d } t          t                      |            d S )Nc                    t           j                            | t                    }t           j                            |          rJ t          j        |           }|J t           j                            |          rJ |                                 t           j                            |          sJ t          j	        |dd          5 }|
                                }t                              dt           j                            |                     }t          ||           d d d            d S # 1 swxY w Y   d S )Nrutf-8<NAME>)ospathjoinr   existsr   load_for_directorysavecodecsopenreadexpected_default_filereplacebasenamer   )dirnamefilenameproject_filefilecontentsexpecteds         r   create_filez5test_create_missing_project_file.<locals>.create_fileq   s_   7<<)ABB7>>(+++++"5g>>'''7>>(+++++w~~h'''''[300 	DDyy{{H,44Xrw?O?OPW?X?XYYH/(CCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds   AD55D9<D9r   dictr4   s    r    test_create_missing_project_filer8   p   s0    D D D DFFK00000r   c                 6      fd}t           di|           d S )Nc                     t           j                            |           }t           j                            |          sJ t	          j        |           }|                    ddg          }d|k    sJ d S )Nabc)r"   r#   r$   r%   r   r&   	get_value)r.   r/   r0   valuerelative_names       r   
check_filez._use_existing_project_file.<locals>.check_file   so    7<<77w~~h'''''"5g>>&&Sz22e|r   	a:
  b: cr   r@   rA   s   ` r   _use_existing_project_filerD      s9         ]L9:FFFFFr   c                  .    t          t                     d S r   )rD   r    r   r   +test_use_existing_project_file_default_namerG      s    788888r   c                  8    t           D ]} t          |            d S r   )r   rD   )names    r   (test_use_existing_project_file_all_namesrJ      s,    + ) )"4(((() )r   c                 6      fd}t           di|           d S )Nc                 X   t           j                            |           }t           j                            |          sJ t           j                            | d          }t          j        |           t          j        |          }|                    ddg          }d|k    sJ d S )Nsubdirr;   r<   r=   )r"   r#   r$   r%   makedirsr   r&   r>   )r.   r/   rM   r0   r?   r@   s        r   rA   z:_use_existing_project_file_from_subdir.<locals>.check_file   s    7<<77w~~h'''''gx00
F"5f==&&Sz22e|r   rB   r   rC   s   ` r   &_use_existing_project_file_from_subdirrO      s9         ]L9:FFFFFr   c                  .    t          t                     d S r   )rO   r   rF   r   r   *test_use_existing_project_file_from_subdirrQ      s    *+CDDDDDr   c                  D    d } t          t                      |            d S )Nc                 6   t           j                            | t                    }t           j                            |          rJ t          j        |           }|J t           j                            |          rJ |                    ddg          J d S )Nr;   r<   )r"   r#   r$   r   r%   r   r&   r>   )r.   r/   r0   s      r   read_missing_filezCtest_load_directory_without_project_file.<locals>.read_missing_file   s    7<<)ABB7>>(+++++"5g>>'''7>>(+++++%%sCj1199999r   r5   )rT   s    r   (test_load_directory_without_project_filerU      s.    : : : DFF$566666r   z#
# In the packages section, list any packages that must be installed
# before your code runs.
# Use `anaconda-project add-packages` to add packages.
#
packages:
- anaconda
z#
# In the channels section, list any Conda channel URLs to be searched
# for packages.
#
# For example,
#
# channels:
#    - mychannel
#
channels:
- mychannel
a  #
# You can define multiple, named environment specs.
# Each inherits any global packages or channels,
# but can have its own unique ones also.
# Use `anaconda-project add-env-spec` to add environment specs.
#
env_specs:
  abc:
    description: ABC
    packages: []
    channels: []
c                  D    d } t          t                      |            d S )Nc                    d }t           j                            | t                    }t           j                            |          rJ t          j        | |          }|J t           j                            |          rJ |                                 t           j                            |          sJ t          j	        |dd          5 }|
                                }t                              dt           j                            |                     }t          ||           d d d            d S # 1 swxY w Y   d S )Nc            	      4    t          ddgg dgddd          gS Nabcanaconda	mychannelABCrF   rI   conda_packagespip_packagesr   descriptioninherit_from_namesinherit_fromr	   rF   r   r   default_env_specs_funczjtest_create_missing_project_file_one_default_env_spec.<locals>.create_file.<locals>.default_env_specs_func   6    U(2|%'"-$)+-%') ) ) r   rd   r   r    r!   )r"   r#   r$   r   r%   r   r&   r'   r(   r)   r*   expected_one_env_spec_contentsr,   r-   r   r.   rd   r/   r0   r1   r2   r3   s          r   r4   zJtest_create_missing_project_file_one_default_env_spec.<locals>.create_file   sv   		 		 		 7<<)ABB7>>(+++++"5gVlmmm'''7>>(+++++w~~h'''''[300 	DDyy{{H5==hHXHXY`HaHabbH/(CCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D   AD::D>D>r5   r7   s    r   5test_create_missing_project_file_one_default_env_specrj      s0    D D D0 DFFK00000r   c                  D    d } t          t                      |            d S )Nc                    d }t           j                            | t                    }t           j                            |          rJ t          j        | |          }|J t           j                            |          rJ |                                 t           j                            |          sJ t          |           t          j
        |dd          5 }|                                }|                    dd          }t                              dd          }|                    dt           j                            |                     }t          ||           d d d            d S # 1 swxY w Y   d S )Nc            	      4    t          ddgg dgddd          gS rY   r	   rF   r   r   rd   zotest_create_missing_project_file_one_default_env_spec_deps.<locals>.create_file.<locals>.default_env_specs_func   re   r   rf   r   r    r   dependenciesr!   )r"   r#   r$   r   r%   r   r&   r'   printr(   r)   r*   r,   rg   r-   r   )r.   rd   r/   r0   r1   r2   #expected_one_env_spec_contents_depsr3   s           r   r4   zOtest_create_missing_project_file_one_default_env_spec_deps.<locals>.create_file   s   		 		 		 7<<)ABB7>>(+++++"5gVlmmm'''7>>(+++++w~~h'''''h[300 	DDyy{{H''
NCCH2P2X2XYces2t2t/:BB8RWM]M]^eMfMfggH/(CCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds   B	E55E9<E9r5   r7   s    r   :test_create_missing_project_file_one_default_env_spec_depsrq      s0    D D D6 DFFK00000r   a  #
# You can define multiple, named environment specs.
# Each inherits any global packages or channels,
# but can have its own unique ones also.
# Use `anaconda-project add-env-spec` to add environment specs.
#
env_specs:
  abc:
    description: ABC
    packages:
    - anaconda
    channels:
    - mychannel
  xyz:
    description: XYZ
    packages:
    - foo
    channels:
    - bar
c                  D    d } t          t                      |            d S )Nc                    d }t           j                            | t                    }t           j                            |          rJ t          j        | |          }|J t           j                            |          rJ |                                 t           j                            |          sJ t          j	        |dd          5 }|
                                }t                              dt           j                            |                     }t          ||           d d d            d S # 1 swxY w Y   d S )Nc            
      b    t          ddgg dgddd          t          ddgg d	gd
dd          gS NrZ   r[   r\   r]   rF   r^   xyzfoobarXYZr	   rF   r   r   rd   zktest_create_missing_project_file_two_default_env_specs.<locals>.create_file.<locals>.default_env_specs_func3  b    U(2|%'"-$)+-%') ) ) U(-w%'"'$)+-%') ) ) r   rf   r   r    r!   )r"   r#   r$   r   r%   r   r&   r'   r(   r)   r*   expected_two_env_spec_contentsr,   r-   r   rh   s          r   r4   zKtest_create_missing_project_file_two_default_env_specs.<locals>.create_file2  sv   	 	 	$ 7<<)ABB7>>(+++++"5gVlmmm'''7>>(+++++w~~h'''''[300 	DDyy{{H5==hHXHXY`HaHabbH/(CCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Dri   r5   r7   s    r   6test_create_missing_project_file_two_default_env_specsr|   1  s0    D D D> DFFK00000r   c                  D    d } t          t                      |            d S )Nc                    d }t           j                            | t                    }t           j                            |          rJ t          j        | |          }|J t           j                            |          rJ |                                 t           j                            |          sJ t          j	        |dd          5 }|
                                }|                    dd          }t                              dd          }|                    dt           j                            |                     }t          ||           d d d            d S # 1 swxY w Y   d S )Nc            
      b    t          ddgg dgddd          t          ddgg d	gd
dd          gS ru   r	   rF   r   r   rd   zptest_create_missing_project_file_two_default_env_specs_deps.<locals>.create_file.<locals>.default_env_specs_funcV  rz   r   rf   r   r    r   rn   r!   )r"   r#   r$   r   r%   r   r&   r'   r(   r)   r*   r,   r{   r-   r   )r.   rd   r/   r0   r1   r2   #expected_two_env_spec_contents_depsr3   s           r   r4   zPtest_create_missing_project_file_two_default_env_specs_deps.<locals>.create_fileU  s   	 	 	$ 7<<)ABB7>>(+++++"5gVlmmm'''7>>(+++++w~~h'''''[300 	DDyy{{H''
NCCH2P2X2XYces2t2t/:BB8RWM]M]^eMfMfggH/(CCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds   B	E&&E*-E*r5   r7   s    r   ;test_create_missing_project_file_two_default_env_specs_depsr   T  s1    D D DB DFFK00000r   ))r(   r"   ,anaconda_project.internal.test.tmpfile_utilsr   #anaconda_project.test.project_utilsr   anaconda_project.project_filer   r   r   anaconda_project.env_specr
   anaconda_project.internalr   r   empty_global_packagesempty_global_channelsr   r$   default_platforms_with_currentdefault_global_platformsempty_default_env_specsr   r+   r8   rD   rG   rJ   rO   rQ   rU   anaconda_global_packagesmychannel_global_channelsabc_empty_env_specrg   rj   rq   abc_xyz_env_specsr{   r|   r   rF   r   r   <module>r      sH    				 P P P P P P S S S S S S l l l l l l l l l l - - - - - - / / / / / /)" V 
  FTYYhh=eY=e=g=ghhhiiFjj 
 W W W ,+5J5J6N6MO O O 1 1 1"G G G9 9 9) ) )

G 
G 
GE E E	7 	7 	7    "5!4>V>W?W?Q"S "S "S 1 1 181 1 1> * "5!4>S>S?W?P"R "R "R  1  1  1F"1 "1 "1 "1 "1r   