
    F-Ph                     *   U 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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 e
r)d dl	mZ d dlmZ eeeeee         f         f         Zded<   d-dZd.dZd/dZd0dZd1d"Z d#Z!d2d)Z"d3d,Z#dS )4    )annotations)Iterable)SequenceN)Path)TYPE_CHECKING   )
UsageError)failabsolutepath)
commonpathsafe_exists)Union)	TypeAliasr   
ConfigDictpathr   returniniconfig.IniConfigc                    	 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     X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/_pytest/config/findpaths.py_parse_ini_configr      sV    ,"3t99--- , , ,S""+,s    # AAAfilepathConfigDict | Nonec                d   | j         dk    rIt          |           }d|v r't          |d                                                   S | j        dk    ri S nZ| j         dk    rst          |           }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          }|$d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vobjectr   str | list[str]c                N    t          | t                    r| nt          |           S N)
isinstancelistr   )r+   s    r   make_scalarz/load_config_dict_from_file.<locals>.make_scalarX   s!    &q$//;qqSVV;    c                .    i | ]\  }}| |          S  r5   ).0kr+   r2   s      r   
<dictcomp>z.load_config_dict_from_file.<locals>.<dictcomp>[   s'    AAA$!QA{{1~~AAAr3   )r+   r,   r   r-   )suffixr   dictitemsnamesectionsr
   CFG_PYTEST_SECTIONformatsysversion_infotomllibtomli	read_textloadsTOMLDecodeErrorr	   get)r   r   rB   	toml_textconfigr   resultr2   s          @r   load_config_dict_from_filerK   )   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< < < < BAAA&,,..AAAA4s   D% %
E	/EE	invocation_dirargsIterable[Path]+tuple[Path | None, Path | None, ConfigDict]c                (   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)r6   xs     r   
<listcomp>z!locate_config.<locals>.<listcomp>m   s1    :::!3q66#4#4S#9#9:A:::r3   NrQ   )r   parentsis_filer<   rK   parent)
rL   rM   config_namesfound_pyproject_tomlargargpathbaseconfig_namep
ini_configs
             r   locate_configrb   `   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>r3   pathsc                    d }|D ]L}|                                 s||}||j        v s||k    r,||j        v r|}8t          ||          }||}M|| }n|                                r|j        }|S r/   )existsrW   r   rX   rY   )rL   rc   common_ancestorr   shareds        r   get_common_ancestorrh      s     $(O - -{{}} 	""OO$,..$/2I2I000"&#D/::%&,O(		 	 	"	" 1)0r3   Iterable[str]
list[Path]c                Z    dddddd	fd
| D             }fd|D             S )NrU   r   r   boolc                ,    |                      d          S )NrS   )rT   rU   s    r   	is_optionz%get_dirs_from_args.<locals>.is_option   s    ||C   r3   c                8    |                      d          d         S )Nz::r   )splitrn   s    r   get_file_part_from_node_idz6get_dirs_from_args.<locals>.get_file_part_from_node_id   s    wwt}}Qr3   r   r   c                <    |                                  r| S | j        S r/   )is_dirrY   )r   s    r   get_dir_from_pathz-get_dirs_from_args.<locals>.get_dir_from_path   s    ;;== 	K{r3   c              3  ^   K   | ]'} |          t           |                    V  (d S r/   r   )r6   r\   rr   ro   s     r   	<genexpr>z%get_dirs_from_args.<locals>.<genexpr>   sY        y~~//4455     r3   c                D    g | ]}t          |           |          S r5   r   )r6   r   ru   s     r   rV   z&get_dirs_from_args.<locals>.<listcomp>   s2    TTT+dBSBSTd##TTTr3   )rU   r   r   rl   )rU   r   r   r   )r   r   r   r   r5   )rM   possible_pathsru   rr   ro   s     @@@r   get_dirs_from_argsrz      s    ! ! ! !                N UTTTTTTTr3   z][pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead.inifile
str | NoneSequence[str]rootdir_cmd_arg$tuple[Path, Path | None, ConfigDict]c                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.)rz   r   rK   rY   rh   rb   rW   rX   
is_fs_rootosr   
expandvarsrt   r	   )r{   rM   r~   rL   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))r3   r`   rl   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   )r   r   
splitdriver   sep)r`   s    r   r   r      s,    
 7c!ff%%a(BF22r3   )r   r   r   r   )r   r   r   r   )rL   r   rM   rN   r   rO   )rL   r   rc   rN   r   r   )rM   ri   r   rj   )
r{   r|   rM   r}   r~   r|   rL   r   r   r   )r`   r   r   rl   )$
__future__r   collections.abcr   r   r   pathlibr   r@   typingr   r   
exceptionsr	   _pytest.outcomesr
   _pytest.pathlibr   r   r   r   typing_extensionsr   r:   r   r1   r   __annotations__r   rK   rb   rh   rz   r>   r   r   r5   r3   r   <module>r      s   " " " " " " " $ $ $ $ $ $ $ $ $ $ $ $ 				       



                 " " " " " " ! ! ! ! ! ! ( ( ( ( ( ( & & & & & & ' ' ' ' ' '  =++++++ !eCcN&;!;<J<<<<	, 	, 	, 	,4 4 4 4n   B   4U U U U, u 3* 3* 3* 3*l3 3 3 3 3 3r3   