
    yIf&                    0   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mZmZmZ ddlmZmZmZmZ ddlmZ dd	lmZ e	rd d
lmZ d dlmZ ddlmZ ddl m!Z!  ed          Z" G d de          Z# G d de#          Z$ G d de#          Z%dZ&dS )    )annotationsN)ABCabstractmethod)Path)TYPE_CHECKINGAnyCallableIteratorMappingSequenceTypeVarcast   )ConfigConstantDefinitionConfigDefinitionConfigDynamicDefinitionConfigLoadArgs)SetEnv)EnvList)Loader)Config)Factory)SectionVc                      e Zd ZdZd7d
Zed8d            Zd8dZ	 	 d9d:dZd;dZ	e
d<d!            Zd=d$Zd>d&Zd?d)Zd@dAd,ZdBd-ZdCd/ZdDd1ZdEd3ZdFd4ZedBd5            ZedGd6            ZdS )H	ConfigSetzdA set of configuration that belong together (such as a tox environment settings, core tox settings).confr   sectionr   env_name
str | NonereturnNonec                    || _         || _        || _        g | _        i | _        i | _        i | _        d| _        |                                  d S )NF)	_section	_env_name_confloaders_defined_keys_alias_finalregister_config)selfr   r   r   s       C/var/www/piapp/venv/lib/python3.11/site-packages/tox/config/sets.py__init__zConfigSet.__init__   sR    !
*,:<&(
&(    c                    t           N)NotImplementedErrorr-   s    r.   r,   zConfigSet.register_config$   s    !!r0   c                    d| _         d S )NT)r+   r4   s    r.   mark_finalizedzConfigSet.mark_finalized(   s    r0   Nkeysstr | Sequence[str]of_typetype[V]default%Callable[[Config, str | None], V] | Vdescstrpost_processCallable[[V], V] | NonefactoryFactory[Any] | NoneConfigDynamicDefinition[V]c                    | j         rd}t          |          |                     |          }t          ||||||          }	|                     ||	          }
t          t          t                   |
          S )a  
        Add configuration value.

        :param keys: the keys under what to register the config (first is primary key)
        :param of_type: the type of the config value
        :param default: the default value of the config value
        :param desc: a help message describing the configuration
        :param post_process: a callback to post-process the configuration value after it has been loaded
        :param factory: factory method used to build contained objects (if ``of_type`` is a container type it
          should perform the contained item creation, otherwise creates objects that match the type)
        :return: the new dynamic config definition
        7config set has been marked final and cannot be extended)r+   RuntimeError
_make_keysr   	_add_confr   r   )r-   r7   r9   r;   r=   r?   rA   msgkeys_
definitionresults              r.   
add_configzConfigSet.add_config+   ss    * ; 	$KCs###%%,UD'7LZabb
z22+A.777r0   valuer   ConfigConstantDefinition[V]c                    | j         rd}t          |          |                     |          }t          |||          }|                     ||          }t          t          t                   |          S )a  
        Add a constant value.

        :param keys: the keys under what to register the config (first is primary key)
        :param desc: a help message describing the configuration
        :param value: the config value to use
        :return: the new constant config value
        rE   )r+   rF   rG   r   rH   r   r   )r-   r7   r=   rN   rI   rJ   rK   rL   s           r.   add_constantzConfigSet.add_constantH   sl     ; 	$KCs###%%-eT5AA
z22,Q/888r0   Sequence[str]c                6    t          | t                    r| fn| S r2   )
isinstancer>   )r7   s    r.   rG   zConfigSet._make_keysY   s    $T3//9wwT9r0   rK   ConfigDefinition[V]c                    |d         }|| j         v r|                     ||           d | j        |<   |D ]}|| j        |<   |D ]}|| j         |<   |S )Nr   )r(   _on_duplicate_confr)   r*   )r-   r7   rK   keyitems        r.   rH   zConfigSet._add_conf]   s{    1g$-##C444
3 	$ 	$D #DK 	, 	,C!+DM#r0   rX   c                V    d| j          d| j        |          d| }t          |          )Nz'duplicate configuration definition for z:
has: z
new: )namer(   
ValueError)r-   rX   rK   rI   s       r.   rW   zConfigSet._on_duplicate_confi   s6    r	rr4=Y\K]rrfprroor0   rY   r   c                ,    |                      |          S )z
        Get the config value for a given key (will materialize in case of dynamic config).

        :param item: the config key
        :return: the configuration value
        )loadr-   rY   s     r.   __getitem__zConfigSet.__getitem__m   s     yyr0   chainlist[str] | Nonec           	         | j         |         }|                    | j        | j        t	          || j        | j                            S )a&  
        Get the config value for a given key (will materialize in case of dynamic config).

        :param item: the config key
        :param chain: a chain of configuration keys already loaded for this load operation (used to detect circles)
        :return: the configuration value
        )r(   __call__r&   r'   r   r[   r   )r-   rY   ra   config_definitions       r.   r^   zConfigSet.loadv   sB     !M$/ ))$*dlNSXZ^ZceierDsDstttr0   c                0    | j         j         d| j        dS )Nz	(loaders=))	__class____name__r'   r4   s    r.   __repr__zConfigSet.__repr__   s     .)EEDLEEEEr0   Iterator[str]c                N    t          | j                                                  S )zD:return: iterate through the defined config keys (primary keys used))iterr)   r7   r4   s    r.   __iter__zConfigSet.__iter__   s    DJOO%%&&&r0   boolc                    || j         v S )z
        Check if a configuration key is within the config set.

        :param item: the configuration value
        :return: a boolean indicating the truthiness of the statement
        r*   r_   s     r.   __contains__zConfigSet.__contains__   s     t{""r0   	list[str]c                   t                      }d | j        D             }| j        D ]:}t          |          |vr'|                    |                                           ;|| j                                        z  }t          |          S )zH:return: Return a list of keys present in the config source but not usedc                D    h | ]}|j         	t          |j                   S r2   )parentid).0is     r.   	<setcomp>z#ConfigSet.unused.<locals>.<setcomp>   s'    NNNA9M2ah<<9M9M9Mr0   )setr'   rw   update
found_keysr(   r7   sorted)r-   foundparentsloaders       r.   unusedzConfigSet.unused   s    %%NNNNNl 	2 	2F&zz((V..00111##%%%e}}r0   c                    | j         |         S )z
        Get the primary key for a config key.

        :param key: the config key
        :return: the key that's considered the primary for the input key
        rq   )r-   rX   s     r.   primary_keyzConfigSet.primary_key   s     {3r0   c                    | j         j        S r2   )r$   r[   r4   s    r.   r[   zConfigSet.name   s    }!!r0   c                    | j         S r2   )r%   r4   s    r.   r   zConfigSet.env_name   s
    ~r0   )r   r   r   r   r   r    r!   r"   r!   r"   )NN)r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   r!   rC   )r7   r8   r=   r>   rN   r   r!   rO   )r7   r8   r!   rR   )r7   rR   rK   rU   r!   rU   rX   r>   rK   rU   r!   r"   )rY   r>   r!   r   r2   )rY   r>   ra   rb   r!   r   r!   r>   )r!   rk   )rY   r>   r!   ro   )r!   rs   )rX   r>   r!   r>   )r!   r    )ri   
__module____qualname____doc__r/   r   r,   r6   rM   rQ   staticmethodrG   rH   rW   r`   r^   rj   rn   rr   r   r   propertyr[   r    r0   r.   r   r      s       nn	 	 	 	 " " " ^"    15'+8 8 8 8 8:9 9 9 9" : : : \:
 
 
 
      	u 	u 	u 	u 	uF F F F' ' ' '# # # #	 	 	 	        " " " X"    X  r0   r   c                  L     e Zd ZdZd fdZddZddZddZddZddZ	 xZ
S )CoreConfigSetz*Configuration set for the core tox config.r   r   r   r   rootr   src_pathr!   r"   c                    || _         || _        t                                          ||d            d}|                     ddgt
          t          g           |           d S )N)r   r   z(define environments to automatically runenv_listenvlistr7   r9   r;   r=   )_root	_src_pathsuperr/   rM   r   )r-   r   r   r   r   r=   rh   s         r.   r/   zCoreConfigSet.__init__   sb    
!w>>>9j)4gwWY{{aefffffr0   r   r    c                >    t          t          | d         dz            S )Ntox_rootz.toxr   r   r-   r   r   s      r.   _default_work_dirzCoreConfigSet._default_work_dir       D$z*V3444r0   c                >    t          t          | d         dz            S )Nwork_dirz.tmpr   r   s      r.   _default_temp_dirzCoreConfigSet._default_temp_dir   r   r0   folderc                @    | j         j        j        r| j         j        n|S r2   )r&   optionsr   )r-   r   s     r.   _work_dir_post_processz$CoreConfigSet._work_dir_post_process   s    &*j&8&AMtz""vMr0   c                l   |                      dgd| j                   |                     ddgt          | j        d           |                     dd	gt          | j        | j        d
           |                     dgt          | j        d           |                      ddt          j	                   d S )Nconfig_file_pathzpath to the configuration file)r7   r=   rN   r   	toxinidirz:the root directory (where the configuration file is found)r   r   
toxworkdirzworking directory)r7   r9   r;   r?   r=   temp_dirz6a folder for temporary files (is not cleaned at start)host_pythonzthe host python executable path)
rQ   r   rM   r   r   r   r   r   sys
executabler4   s    r.   r,   zCoreConfigSet.register_config   s     23:Zbfbpqqqk*JM	 	 	
 	
 	
 	l+*4$ 	 	
 	
 	
 	*I	 	 	
 	
 	
 	-)JCN[[[[[r0   rX   r>   rK   rU   c                    d S r2   r   )r-   rX   rK   s      r.   rW   z CoreConfigSet._on_duplicate_conf   s    r0   )
r   r   r   r   r   r   r   r   r!   r"   )r   r   r   r    r!   r   )r   r   r!   r   r   r   )ri   r   r   r   r/   r   r   r   r,   rW   __classcell__rh   s   @r.   r   r      s        44g g g g g g5 5 5 55 5 5 5N N N N\ \ \ \0       r0   r   c                  4     e Zd ZdZd fd
ZddZddZ xZS )EnvConfigSetz(Configuration set for a tox environment.r   r   r   r   r   r>   r!   r"   c                f    t                                          |||           t          | _        d S r2   )r   r/   dictdefault_set_env_loader)r-   r   r   r   rh   s       r.   r/   zEnvConfigSet.__init__   s-    w111GK###r0   c                     d fd}d fd} j         j        d                              d	d
gt          |t          d j         j                  d|           d S )Nvaluesr   r!   c                    |                                                      d           |                      ddid           | S )NF)overridePYTHONIOENCODINGzutf-8T)r|   r   )r   r-   s    r.   set_env_post_processz:EnvConfigSet.register_config.<locals>.set_env_post_process   sF    MM$5577%MHHHMM-w7$MGGGMr0   rawobjectc                    t          | t                    st          |           t          | j        j                  S r2   )rT   r>   	TypeErrorr   r[   r   )r   r   r-   s    r.   set_env_factoryz5EnvConfigSet.register_config.<locals>.set_env_factory   s9    c3'' %nn$#ty$->>>r0   r   set_envsetenv zIenvironment variables to set when running commands in the tox environment)r7   r9   rA   r;   r=   r?   )r   r   r!   r   )r   r   r!   r   )r&   corerM   r   r[   r   )r-   r   r   r   s   `  @r.   r,   zEnvConfigSet.register_config   s    	 	 	 	 	 	
	? 	? 	? 	? 	? 	? 	?
 zz*X&#2ty$->>\- 	 	
 	
 	
 	
 	
r0   c                @    | j         j         d| j        d| j        dS )Nz(name=z
, loaders=rg   )rh   ri   r%   r'   r4   s    r.   rj   zEnvConfigSet.__repr__   s*    .)^^^^T\^^^^r0   )r   r   r   r   r   r>   r!   r"   r   r   )ri   r   r   r   r/   r,   rj   r   r   s   @r.   r   r      sy        22L L L L L L
 
 
 
*_ _ _ _ _ _ _ _r0   r   )r   r   r   )'
__future__r   r   abcr   r   pathlibr   typingr   r   r	   r
   r   r   r   r   r9   r   r   r   r   r   r   typesr   tox.config.loader.apir   tox.config.mainr   loader.convertr   loader.sectionr   r   r   r   r   __all__r   r0   r.   <module>r      s   " " " " " " 



 # # # # # # # #       [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ h h h h h h h h h h h h             (,,,,,,&&&&&&''''''''''''GCLLU U U U U U U Up, , , , ,I , , ,^_ _ _ _ _9 _ _ _@r0   