
    9[g~                        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y)    )annotationsN)Path)Iterable)Sequence   )
UsageError)failabsolutepath)
commonpathsafe_existsc                    	 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   )pathexcs     S/var/www/html/bid-api/venv/lib/python3.12/site-packages/_pytest/config/findpaths.py_parse_ini_configr      sC    ,""3t9-- ,S"+,s     AAAc                B   | j                   dk(  r=t        |       }d|v rt        |d   j                               S | j                  dk(  ri S y| j                   dk(  ret        |       }d|j
                  v rt        |d   j                               S d|j
                  v r!t        t        j                  d      d	       y| j                   d
k(  rt        j                  dk\  rddl}nddl}| j                  d      }	 |j                  |      }|j#                  di       j#                  di       j#                  dd      }|.dd}|j                         D 	ci c]  \  }}	| ||	       c}	}S y# |j                  $ r}t!        |  d|       |d}~ww xY wc c}	}w )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_optionsc                <    t        | t              r| S t        |       S N)
isinstancelistr   )vs    r   make_scalarz/load_config_dict_from_file.<locals>.make_scalarM   s    &q$/q;SV;    )r'   objectreturnzstr | list[str])suffixr   dictitemsnamesectionsr	   CFG_PYTEST_SECTIONformatsysversion_infotomllibtomli	read_textloadsTOMLDecodeErrorr   get)
filepathr   r5   	toml_textconfigr   resultr(   kr'   s
             r   load_config_dict_from_filer@      s    & %h/	y 	(+11344 }},	H C 
F	"%h/	I...	-066899+++ #**K*@%P2 - 
G	#w&#&&&8		<]]9-F FB'++Hb9==mTR< 39,,.A.$!QA{1~%.AA && 	<zC512;	< Bs   ?E3 F3FFFc                   g d}|D cg c]  }t        |      j                  d      r|! }}|s| g}d}|D ]j  }t        |      }|g|j                  D ]J  }|D ]C  }||z  }	|	j	                         s|	j
                  dk(  r||	}t        |	      }
|
:||	|
fc c c S  L l ||j                  |i fS ddi fS c c}w )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   -NrB   )r   
startswithr   parentsis_filer/   r@   parent)invocation_dirargsconfig_namesxfound_pyproject_tomlargargpathbaseconfig_namep
ini_configs              r   locate_configrS   U   s    L :t!3q6#4#4S#9AtD:(,s#/w/D+;&99;vv!116J6R/0,!;A!>J!-#Q
22  , 0  '#**,@"DDr># ;s
   B;B;c                    d }|D ]N  }|j                         s||}||j                  v s||k(  r-||j                  v r|}>t        ||      }|M|}P || }|S |j                         r|j                  }|S r$   )existsrE   r   rF   rG   )rH   pathscommon_ancestorr   shareds        r   get_common_ancestorrY   v   s     $(O{{}""O$,,.$/2I000"&#D/:%&,O  (  
	 	 	")00r)   c                    dddddd}fd| D        }|D cg c]  }t        |      s ||       c}S c c}w )Nc                $    | j                  d      S )NrC   )rD   rK   s    r   	is_optionz%get_dirs_from_args.<locals>.is_option   s    ||C  r)   c                *    | j                  d      d   S )Nz::r   )splitr\   s    r   get_file_part_from_node_idz6get_dirs_from_args.<locals>.get_file_part_from_node_id   s    wwt}Qr)   c                >    | j                         r| S | j                  S r$   )is_dirrG   )r   s    r   get_dir_from_pathz-get_dirs_from_args.<locals>.get_dir_from_path   s    ;;=K{{r)   c              3  P   K   | ]  } |      st         |              y wr$   r
   ).0rM   r`   r]   s     r   	<genexpr>z%get_dirs_from_args.<locals>.<genexpr>   s+      C~ 	/45s   #&)rK   r   r+   bool)rK   r   r+   r   )r   r   r+   r   r   )rI   rc   possible_pathsr   r`   r]   s       @@r   get_dirs_from_argsri      sH    ! N 1?T+dBSd#TTTs   =
=z][pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead.c                "   d}t        |      }| r+t        |       }|}t        |      xs i }||j                  }nt	        ||      }	t        ||	g      \  }}}|a|_|	g|	j                  D ]  }
|
dz  j                         s|
} n4 ||	gk7  rt        ||      \  }}}|t	        |||	g      }t        |      r|	}|rGt        t        j                  j                  |            }|j                         st        d| d      |J |||xs 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.)ri   r   r@   rG   rY   rS   rE   rF   
is_fs_rootosr   
expandvarsrb   r   )inifilerI   rootdir_cmd_argrH   rootdirdirsinipath_inipathinicfgancestorpossible_rootdirs              r   determine_setuprw      sG   & Gd#D('+H5;"ooG&~t<#0(#L &?6%-$A0@0@$A $z1::<.G %B
 H:%/<^T/R,GWf?1&(BG "'*"*rww11/BC~~gY&QR  GV\r))r)   c                z    t         j                  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   )rl   r   
splitdriver   sep)rQ   s    r   rk   rk      s+    
 77c!f%a(BFF22r)   )r   r   r+   ziniconfig.IniConfig)r;   r   r+   z!dict[str, str | list[str]] | None)rH   r   rI   Iterable[Path]r+   z;tuple[Path | None, Path | None, dict[str, str | list[str]]])rH   r   rV   r{   r+   r   )rI   zIterable[str]r+   z
list[Path])
rn   
str | NonerI   zSequence[str]ro   r|   rH   r   r+   z4tuple[Path, Path | None, dict[str, str | list[str]]])rQ   r   r+   rg   )
__future__r   rl   pathlibr   r3   typingr   r   r   
exceptionsr   _pytest.outcomesr	   _pytest.pathlibr   r   r   r   r@   rS   rY   ri   r1   rw   rk    r)   r   <module>r      s    " 	  
    " ! ( & '	,44&4n
 AB 
4U, u 3*3* 3*  	3*
 3* :3*l3r)   