
    Bh                     J   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	 	 	 	 	 	 ddZddZ dZ!	 	 	 	 	 	 	 	 	 	 ddZ"ddZ#y)     )annotations)Iterable)SequenceN)Path)TYPE_CHECKING   )
UsageError)failabsolutepath)
commonpathsafe_exists)Union)	TypeAliasr   
ConfigDictc                    	 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     c/var/www/html/Telegram-Engagement-Pod-/env/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_scalarX   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   r9   	toml_textconfigr   resultr,   kr+   s
             r   load_config_dict_from_filerD   )   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   -NrF   )r   
startswithr   parentsis_filer3   rD   parent)invocation_dirargsconfig_namesxfound_pyproject_tomlargargpathbaseconfig_namep
ini_configs              r   locate_configrW   `   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(   )existsrI   r   rJ   rK   )rL   pathscommon_ancestorr   shareds        r   get_common_ancestorr]      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 )NrG   )rH   rO   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_dirrK   )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   ).0rQ   rd   ra   s     r   	<genexpr>z%get_dirs_from_args.<locals>.<genexpr>   s+      C~ 	/45s   #&)rO   r   r/   bool)rO   r   r/   r   )r   r   r/   r   r   )rM   rg   possible_pathsr   rd   ra   s       @@r   get_dirs_from_argsrm      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.)rm   r   rD   rK   r]   rW   rI   rJ   
is_fs_rootosr   
expandvarsrf   r	   )inifilerM   rootdir_cmd_argrL   rootdirdirsinipath_inipathinicfgancestorpossible_rootdirs              r   determine_setupr{      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   )rp   r   
splitdriver   sep)rU   s    r   ro   ro      s+    
 77c!f%a(BFF22r-   )r   r   r/   ziniconfig.IniConfig)r?   r   r/   zConfigDict | None)rL   r   rM   Iterable[Path]r/   z+tuple[Path | None, Path | None, ConfigDict])rL   r   rZ   r   r/   r   )rM   zIterable[str]r/   z
list[Path])
rr   
str | NonerM   zSequence[str]rs   r   rL   r   r/   z$tuple[Path, Path | None, ConfigDict])rU   r   r/   rk   )$
__future__r   collections.abcr   r   rp   pathlibr   r7   typingr   r   
exceptionsr	   _pytest.outcomesr
   _pytest.pathlibr   r   r   r   typing_extensionsr   r1   r   r*   r   __annotations__r   rD   rW   r]   rm   r5   r{   ro    r-   r   <module>r      s    " $ $ 	  
    " ! ( & ' + !eCcN&;!;<J	<	,444n
 1B 
4U, u 3*3* 3*  	3*
 3* *3*l3r-   