
    j~                        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	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Zd)dZd*dZd+dZd,dZdZd-d$Zd.d'ZdS )/    )annotationsN)Path)Iterable)Sequence   )
UsageError)failabsolutepath)
commonpathsafe_exists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     b/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/_pytest/config/findpaths.py_parse_ini_configr      sV    ,"3t99--- , , ,S""+,s    # AAAfilepath!dict[str, str | list[str]] | 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_scalarM   s!    &q$//;qqSVV;    c                .    i | ]\  }}| |          S  r1   ).0kr'   r.   s      r   
<dictcomp>z.load_config_dict_from_file.<locals>.<dictcomp>P   s'    AAA$!QA{{1~~AAAr/   )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   r>   	toml_textconfigr   resultr.   s          @r   load_config_dict_from_filerG      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, dict[str, str | list[str]]]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)r2   xs     r   
<listcomp>z!locate_config.<locals>.<listcomp>b   s1    :::!3q66#4#4S#9#9:A:::r/   NrM   )r   parentsis_filer8   rG   parent)
rH   rI   config_namesfound_pyproject_tomlargargpathbaseconfig_namep
ini_configs
             r   locate_configr^   U   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+   )existsrS   r   rT   rU   )rH   r_   common_ancestorr   shareds        r   get_common_ancestorrd   v   s     $(O - -{{}} 	""OO$,..$/2I2I000"&#D/::%&,O(		 	 	"	" 1)0r/   Iterable[str]
list[Path]c                Z    dddddd	fd
| D             }fd|D             S )NrQ   r   r   boolc                ,    |                      d          S )NrO   )rP   rQ   s    r   	is_optionz%get_dirs_from_args.<locals>.is_option   s    ||C   r/   c                8    |                      d          d         S )Nz::r   )splitrj   s    r   get_file_part_from_node_idz6get_dirs_from_args.<locals>.get_file_part_from_node_id   s    wwt}}Qr/   r   r   c                <    |                                  r| S | j        S r+   )is_dirrU   )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   rX   rn   rk   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   rq   s     r   rR   z&get_dirs_from_args.<locals>.<listcomp>   s2    TTT+dBSBSTd##TTTr/   )rQ   r   r   rh   )rQ   r   r   r   )r   r   r   r   r1   )rI   possible_pathsrq   rn   rk   s     @@@r   get_dirs_from_argsrv      s    ! ! ! !                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
str | NoneSequence[str]rootdir_cmd_arg4tuple[Path, Path | None, dict[str, str | list[str]]]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.)rv   r   rG   rU   rd   r^   rS   rT   
is_fs_rootosr   
expandvarsrp   r   )rw   rI   rz   rH   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\   rh   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2r/   )r   r   r   r   )r   r   r   r   )rH   r   rI   rJ   r   rK   )rH   r   r_   rJ   r   r   )rI   re   r   rf   )
rw   rx   rI   ry   rz   rx   rH   r   r   r{   )r\   r   r   rh   )
__future__r   r~   pathlibr   r<   typingr   r   r   
exceptionsr   _pytest.outcomesr	   _pytest.pathlibr   r   r   r   rG   r^   rd   rv   r:   r   r}   r1   r/   r   <module>r      sk   " " " " " " 				       



                 " " " " " " ! ! ! ! ! ! ( ( ( ( ( ( & & & & & & ' ' ' ' ' '	, 	, 	, 	,4 4 4 4n   B   4U U U U, u 3* 3* 3* 3*l3 3 3 3 3 3r/   