
    yIf                      x   d dl Z d dlmZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d d	lmZ d dlZd
dlmZ d dlmZ d dlmZ d dlmZ d dlmZ dedej        fdZdedeeeeeee         f         f                  fdZdedee         de
ee         ee         eeeeee         f         f         f         fdZdedee         defdZdee         dee         fdZdZdee         de	e         dee         dede
eee         eeeeee         f         f         f         f
dZdedefd ZdS )!    N)Path)Dict)Iterable)List)Optional)Sequence)Tuple)Union   )
UsageError)failabsolutepath)
commonpathsafe_existspathreturnc                     	 t          j        t          |                     S # t           j        $ r"}t	          t          |                    |d}~ww xY w)zParse the given generic '.ini' file using legacy IniConfig parser, returning
    the parsed object.

    Raise UsageError if the file cannot be parsed.
    N)	iniconfig	IniConfigstr
ParseErrorr   )r   excs     L/var/www/piapp/venv/lib/python3.11/site-packages/_pytest/config/findpaths.py_parse_ini_configr      sV    ,"3t99--- , , ,S""+,s    # AAAfilepathc                    | j         dk    rIt          |           }d|v r't          |d                                                   S | j        dk    ri S n| j         dk    rtt          |           }d|j        v r't          |d                                                   S d|j        v r*t          t                              d          d	           n| j         d
k    rt          j
        dk    rddl}nddl}|                     d          }	 |                    |          }n'# |j        $ r}t!          |  d|           |d}~ww xY w|                    di                               di                               dd          }|Odt$          dt&          t(          t*          t(                   f         fdfd|                                D             S dS )zLoad pytest configuration from the given file path, if supported.

    Return None if the file does not contain valid pytest configuration.
    z.inipytest
pytest.iniz.cfgztool:pytest	setup.cfg)filenameF)pytracez.toml)      r   Nzutf-8)encodingz: toolini_optionsvr   c                 N    t          | t                    r| nt          |           S N)
isinstancelistr   )r)   s    r   make_scalarz/load_config_dict_from_file.<locals>.make_scalarP   s!    &q$//;qqSVV;    c                 .    i | ]\  }}| |          S  r1   ).0kr)   r.   s      r   
<dictcomp>z.load_config_dict_from_file.<locals>.<dictcomp>S   s'    AAA$!QA{{1~~AAAr/   )suffixr   dictitemsnamesectionsr   CFG_PYTEST_SECTIONformatsysversion_infotomllibtomli	read_textloadsTOMLDecodeErrorr   getobjectr
   r   r   )r   r   r>   	toml_textconfigr   resultr.   s          @r   load_config_dict_from_filerH   !   s    &  %h//	y  	(+1133444 },,	 - 
F	"	"%h//	I...	-06688999+++ #**K*@@%PPPP 
G	#	#w&&NNNN####&&&88		<]]9--FF& 	< 	< 	<11C1122;	< FB''++Hb99==mTRR<v <%T#Y*? < < < < BAAA&,,..AAAA4s   D& &
E
0EE
invocation_dirargsc                 (   g d}d |D             }|s| g}d}|D ]h}t          |          }|g|j        R D ]K}|D ]F}||z  }|                                r+|j        dk    r||}t	          |          }	|	|||	fc c c S GLi|
|j        |i fS ddi fS )zxSearch in the list of arguments for a valid ini-file for pytest,
    and return a tuple of (rootdir, inifile, cfg-dict).)r    z.pytest.inipyproject.tomlztox.inir!   c                 V    g | ]&}t          |                              d           $|'S )-)r   
startswith)r2   xs     r   
<listcomp>z!locate_config.<locals>.<listcomp>e   s1    :::!3q66#4#4S#9#9:A:::r/   NrL   )r   parentsis_filer8   rH   parent)
rI   rJ   config_namesfound_pyproject_tomlargargpathbaseconfig_namep
ini_configs
             r   locate_configr]   X   s     L ;:t:::D  +/ 
3 
3s##/w// 	3 	3D+ 3 3;&99;; 3v!1116J6R/0,!;A!>!>J!-#Q
222222223	3 '#*,@"DDr>r/   pathsc                     d }|D ]L}|                                 s||}||j        v s||k    r,||j        v r|}8t          ||          }||}M|| }n|                                r|j        }|S r+   )existsrR   r   rS   rT   )rI   r^   common_ancestorr   shareds        r   get_common_ancestorrc   y   s     '+O - -{{}} 	""OO$,..$/2I2I000"&#D/::%&,O(		 	 	"	" 1)0r/   c                     dt           dt          fddt           dt           fddt          dt          fdfd| D             }fd|D             S )	NrP   r   c                 ,    |                      d          S )NrN   )rO   rP   s    r   	is_optionz%get_dirs_from_args.<locals>.is_option   s    ||C   r/   c                 8    |                      d          d         S )Nz::r   )splitrf   s    r   get_file_part_from_node_idz6get_dirs_from_args.<locals>.get_file_part_from_node_id   s    wwt}}Qr/   r   c                 <    |                                  r| S | j        S r+   )is_dirrT   )r   s    r   get_dir_from_pathz-get_dirs_from_args.<locals>.get_dir_from_path   s    ;;== 	K{r/   c              3   ^   K   | ]'} |          t           |                    V  (d S r+   r   )r2   rW   rj   rg   s     r   	<genexpr>z%get_dirs_from_args.<locals>.<genexpr>   sY        y~~//4455     r/   c                 D    g | ]}t          |           |          S r1   r   )r2   r   rm   s     r   rQ   z&get_dirs_from_args.<locals>.<listcomp>   s2    TTT+dBSBSTd##TTTr/   )r   boolr   )rJ   possible_pathsrm   rj   rg   s     @@@r   get_dirs_from_argsrs      s    !S !T ! ! ! ! c  c                   N UTTTTTTTr/   z][pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead.inifilerootdir_cmd_argc                 d   d}t          |          }| r,t          |           }|}t          |          pi }||j        }nt	          ||          }	t          ||	g          \  }}}|k|i|	g|	j        R D ]}
|
dz                                  r|
} nA||	gk    rt          ||          \  }}}|#t	          |||	g          }t          |          r|	}|rSt          t          j
                            |                    }|                                st          d| d          |J |||pi fS )a  Determine the rootdir, inifile and ini configuration values from the
    command line arguments.

    :param inifile:
        The `--inifile` command line argument, if given.
    :param args:
        The free command line arguments.
    :param rootdir_cmd_arg:
        The `--rootdir` command line argument, if given.
    :param invocation_dir:
        The working directory when pytest was invoked.
    Nzsetup.pyzDirectory 'z+' not found. Check your '--rootdir' option.)rs   r   rH   rT   rc   r]   rR   rS   
is_fs_rootosr   
expandvarsrl   r   )rt   rJ   ru   rI   rootdirdirsinipath_inipathinicfgancestorpossible_rootdirs              r   determine_setupr      s   & Gd##D +(("*+H55;"oG&~t<<#0(#L#L &?6%-$A0@$A$A + + $z1::<< .GE H:%%/<^T/R/R,GWf?1&(B G "'** +"* rw11/BBCC~~ 	RgRRR   GV\r))r/   r[   c                     t           j                            t          |                     d         t           j        k    S )z
    Return True if the given path is pointing to the root of the
    file system ("/" on Unix and "C:\\" on Windows for example).
    r   )rx   r   
splitdriver   sep)r[   s    r   rw   rw      s,    
 7c!ff%%a(BF22r/   ) rx   pathlibr   r<   typingr   r   r   r   r   r	   r
   r   
exceptionsr   _pytest.outcomesr   _pytest.pathlibr   r   r   r   r   r   rH   r]   rc   rs   r:   r   rq   rw   r1   r/   r   <module>r      s   				       



                                               " " " " " " ! ! ! ! ! ! ( ( ( ( ( ( & & & & & & ' ' ' ' ' '	,D 	,Y%8 	, 	, 	, 	,44d3c49n--./4 4 4 4n
4. 8D>8D>4U3S	>5J0J+KKL   BD> 
   4UXc] UtDz U U U U, u 3*c]3* 3-3* c]	3*
 3* 4$c5d3i+@&@!AAB3* 3* 3* 3*l3$ 34 3 3 3 3 3 3r/   