
    yIf
                        d dl mZ d dlZd dlmZmZ d dlmZ d dlm	Z	m
Z
mZmZmZ ddlmZmZmZ e	r 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de          Z G d d          ZdgZdS )    )annotationsN)OrderedDictdefaultdict)Path)TYPE_CHECKINGAnyIteratorSequenceTypeVar   )	ConfigSetCoreConfigSetEnvConfigSet)LoaderOverrideMap)Parsed)MemoryLoader)Section)SourceT)boundc                      e Zd ZdZd6dZd7dZed8d            Zed8d            Zd9dZ	d:dZ
d;dZd<dZed=d            Zed>d             Zed?d"            Z	 d@dAd/Z	 	 dBdCd3ZdDd5Zd#S )EConfigz"Main configuration object for tox.config_sourcer   optionsr   rootr   pos_argsSequence[str] | Nonework_dirreturnNonec                d   |d nt          |          | _        || _        || _        || _        t          t                    | _        |j        D ]'}| j        |j	                 
                    |           (|| _        t                      | _        d | _        t          t                    | _        d S N)tuple	_pos_args	_work_dir_root_optionsr   list
_overridesoverride	namespaceappend_srcr   _key_to_conf_set	_core_setmemory_seed_loaders)selfr   r   r   r   r   r+   s          C/var/www/piapp/venv/lib/python3.11/site-packages/tox/config/main.py__init__zConfig.__init__   s     "*!1uX!
'24'8'8( 	A 	AHOH./66x@@@@!	GR}}/3ITUYIZIZ       to_pathPath | Nonetuple[str, ...] | Nonec                >   | j         |t          j                    |k    rg }t          j                            t          |                    }| j         D ]}t          |          }|                                rv|                                sbt          j                            t          |                    }t          j        	                    ||          }|
                    |           |
                    |           t          |          S | j         S )z
        :param to_path: if not None rewrite relative posargs paths from cwd to to_path
        :return: positional argument
        )r%   r   cwdospathabspathstrexistsis_absoluterelpathr-   r$   )r2   r6   argsto_path_strargpath_argpath_arg_strrelatives           r3   r   zConfig.pos_args/   s    
 >%'*=$(**PWBWBWD'//#g,,77K~ 	% 	%99??$$ %X-A-A-C-C %#%7??3x==#A#AL!w|[IIHKK))))KK$$$$;;~r5   c                    | j         S )z+:return: working directory for this project)r&   r2   s    r3   r   zConfig.work_dirE   s     ~r5   c                    | j         j        S )z5:return: the location of the tox configuration source)r.   r<   rI   s    r3   src_pathzConfig.src_pathJ   s     y~r5   Iterator[str]c                @    | j                             | j                  S )z<:return: an iterator that goes through existing environments)r.   envscorerI   s    r3   __iter__zConfig.__iter__O   s    y~~di(((r5   Iterator[Section]c              #  H   K   | j                                         E d {V  d S r#   )r.   sectionsrI   s    r3   rS   zConfig.sectionsS   s2      9%%'''''''''''r5   r>   c                @    t          |           j         d| j        dS )Nz(config_source=))type__name__r.   rI   s    r3   __repr__zConfig.__repr__V   s$    t**%DDdiDDDDr5   itemboolc                :    t          fd| D                       S )z/:return: check if an environment already existsc              3  (   K   | ]}|k    |V  d S r#    ).0namerY   s     r3   	<genexpr>z&Config.__contains__.<locals>.<genexpr>[   s'      99DDDLL4LLLL99r5   )any)r2   rY   s    `r3   __contains__zConfig.__contains__Y   s&    9999D999999r5   parsedsourcec                    |j         |j        j        n|j         }|j        |j        j        n|j        }|                                }|                                } | |||||          S )z Make a tox configuration object.N)r   r   r   r   r   )root_dirr<   parentr   resolve)clsrc   r   rd   r   r   s         r3   makezConfig.make]   sz    
 ,2?+BV[''/5/F++FO||~~##%%s 
 
 
 	
r5   c                    | j         S r#   )r(   rI   s    r3   r   zConfig.optionso   s
    }r5   r   c                   | j         | j         S | j                                        }t          | || j        | j                  }|j                            | j                            |g | j	        |                     || _         |S )z:return: the core configurationN)baseoverride_mapconf)
r0   r.   get_core_sectionr   r'   rK   loadersextendget_loadersr*   )r2   core_sectionrO   s      r3   rO   zConfig.cores   s~     >%>!y1133T<T]KKDI11,RVZVelp1qqrrrr5   Nsectionr   rm   list[str] | Noneof_typetype[T]for_env
str | Nonerq   Sequence[Loader[Any]] | Noner   c                   |j         |pdd                    |pg           f}	 | j        |         S # t          $ r  || ||          }|| j        |<   |3|j                            | j                            |g                      | j        	                    ||| j
        |          D ]}|j                            |           ||j                            |           |cY S w xY w)N -)keyjoinr/   KeyErrorrq   rr   r1   getr.   rs   r*   r-   )	r2   ru   rm   rw   ry   rq   r   conf_setloaders	            r3   get_section_configzConfig.get_section_config~   s    k7=b#((4:2*>*>>	(-- 		 		 		wtWg66H)1D!#&" ''(@(D(DWb(Q(QRRR)//tPXYY 0 0 ''////" ''000OOO		s   0 B3C&%C&Fpackager   c                    | j                             |          \  }}}|                     ||r|n|t          ||          S )a  
        Return the configuration for a given tox environment (will create if not exist yet).

        :param item: the name of the environment is
        :param package: a flag indicating if the environment is of type packaging or not (only used for creation)
        :param loaders: loaders to use for this configuration (only used for creation)
        :return: the tox environments config
        )rm   rw   ry   rq   )r.   get_tox_env_sectionr   r   )r2   rY   r   rq   ru   	base_testbase_pkgs          r3   get_envzConfig.get_env   sU     (,y'D'DT'J'J$H&&$3)  ' 
 
 	
r5   r_   c                    | j                                       \  }}fd| j                                        D             | _        d S )Nc                V    i | ]%\  }}|d          j         k    |d         k    "||&S )r   r   )r   )r^   kvr_   ru   s      r3   
<dictcomp>z$Config.clear_env.<locals>.<dictcomp>   sF     x x x$!QSTUVSW[b[fSfSfklmnkoswkwkwAkwkwkwr5   )r.   r   r/   items)r2   r_   ___ru   s    `  @r3   	clear_envzConfig.clear_env   sS    66t<<B x x x x x$2G2M2M2O2O x x xr5   )r   r   r   r   r   r   r   r   r   r   r    r!   )r6   r7   r    r8   )r    r   )r    rL   )r    rQ   )r    r>   )rY   r>   r    rZ   )rc   r   r   r   rd   r   r    r   )r    r   )r    r   r#   )ru   r   rm   rv   rw   rx   ry   rz   rq   r{   r    r   )FN)rY   r>   r   rZ   rq   r{   r    r   )r_   r>   r    r!   )rW   
__module____qualname____doc__r4   r   propertyr   rK   rP   rS   rX   rb   classmethodrj   r   rO   r   r   r   r]   r5   r3   r   r      s       ,,[ [ [ [,   ,    X    X) ) ) )( ( ( (E E E E: : : : 
 
 
 [
"    X    X  15    2 04	
 
 
 
 
.y y y y y yr5   r   ) 
__future__r   r;   collectionsr   r   pathlibr   typingr   r   r	   r
   r   setsr   r   r   tox.config.loader.apir   r   
cli.parserr   loader.memoryr   loader.sectionr   rd   r   r   r   ___all__r]   r5   r3   <module>r      sY   " " " " " " 				 0 0 0 0 0 0 0 0       B B B B B B B B B B B B B B 8 8 8 8 8 8 8 8 8 8 99999999""""""++++++'''''' GCy!!!Wy Wy Wy Wy Wy Wy Wy Wyv r5   