
    [Fi                         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y)!    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     j/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/_pytest/config/findpaths.py_parse_ini_configr      sC    ,""3t9-- ,S"+,s     AAAfilepathc                    | 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      }|Ndt$        dt&        t(        t*        t(           f   f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_optionsvr   c                 <    t        | t              r| S t        |       S N)
isinstancelistr   )r(   s    r   make_scalarz/load_config_dict_from_file.<locals>.make_scalarP   s    &q$/q;SV;    )suffixr   dictitemsnamesectionsr   CFG_PYTEST_SECTIONformatsysversion_infotomllibtomli	read_textloadsTOMLDecodeErrorr   getobjectr
   r   r   )
r   r   r8   	toml_textconfigr   resultr-   kr(   s
             r   load_config_dict_from_filerC   !   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<v <%T#Y*? < 39,,.A$!QA{1~%AA && 	<zC512;	< Bs   ?F ;F;F8"F33F8invocation_dirargsc                    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    -NrG   )r   
startswithr   parentsis_filer2   rC   parent)rD   rE   config_namesxfound_pyproject_tomlargargpathbaseconfig_namep
ini_configs              r   locate_configrV   X   s    L :!3q6#4#4S#9A:D:+/ 
3s#/w/ 	3D+ 3;&99;vv!116J6R/0,!;A!>J!-#Q
223	3
3 '#**,@"DDr># ;s
   B;B;pathsc                     d }|D ]N  }|j                         s||}||j                  v s||k(  r-||j                  v r|}>t        ||      }|M|}P || }|S |j                         r|j                  }|S r*   )existsrJ   r   rK   rL   )rD   rW   common_ancestorr   shareds        r   get_common_ancestorr\   y   s     '+O -{{}""O$,,.$/2I000"&#D/:%&,O- (  
	 	 	")00r.   c                     dt         dt        fddt         dt         fddt        dt        fd}fd| D        }|D cg c]  }t        |      s ||       c}S c c}w )NrN   r   c                 $    | j                  d      S )NrH   )rI   rN   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.   r   c                 >    | j                         r| S | j                  S r*   )is_dirrL   )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   ).0rP   rc   r`   s     r   	<genexpr>z%get_dirs_from_args.<locals>.<genexpr>   s+      ~ 	/45s   #&)r   boolr   r   )rE   rf   possible_pathsr   rc   r`   s       @@r   get_dirs_from_argsrl      sn    !S !T ! c  c    N 1?T+dBSd#TTTs   A!
A!z][pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead.inifilerootdir_cmd_argc                 "   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.)rl   r   rC   rL   r\   rV   rJ   rK   
is_fs_rootosr   
expandvarsre   r   )rm   rE   rn   rD   rootdirdirsinipath_inipathinicfgancestorpossible_rootdirs              r   determine_setuprz      sK   & Gd#D("*+H5;"ooG&~t<#0(#L &?6%-$A0@0@$A + $z1::<.G+
 H:%/<^T/R,GWf?1&(BG "'*"*rww11/BC~~gY&QR  GV\r))r.   rT   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   )rq   r   
splitdriver   sep)rT   s    r   rp   rp      s+    
 77c!f%a(BFF22r.   ) rq   pathlibr   r6   typingr   r   r   r   r   r	   r
   r   
exceptionsr   _pytest.outcomesr   _pytest.pathlibr   r   r   r   r   r   rC   rV   r\   rl   r4   rz   rj   rp    r.   r   <module>r      s   	  
         " ! ( & '	,D 	,Y%8%8 	,44d3c49n--./4n
4. 8D>8D>4U3S	>5J0J+KKLBD> 
4UXc] UtDz U, u 3*c]3* 3-3* c]	3*
 3* 4$c5d3i+@&@!AAB3*l3$ 34 3r.   