
    עiO                       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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Zd dlmZ dZ G d d      Z e       Ze G d d             Z	 	 	 	 ddZ G d de      Z G d d      Z G d d      Z G d dej:                        Z G d dej>                        Z  G d dejB                        Z"y)     )annotationsN)Callable)Mapping)Sequence)Any)final)Literal)NoReturn   )
UsageError)check_ispytestfile_or_dirc                      e Zd ZddZy)NotSetc                     y)Nz<notset> selfs    Z/sites/domain-asset-master/.venv/lib/python3.12/site-packages/_pytest/config/argparsing.py__repr__zNotSet.__repr__   s        Nreturnstr)__name__
__module____qualname__r   r   r   r   r   r      s    r   r   c                      e Zd ZdZ	 	 ddd	 	 	 	 	 	 	 ddZedd       Zej                  dd       ZddZ	 d	 	 	 	 	 	 	 dd	Z	dd
Z
	 d	 	 	 	 	 ddZ	 d	 	 	 	 	 ddZ	 d	 	 	 	 	 ddZdefdd	 	 	 	 	 	 	 	 	 	 	 ddZy)ParserzParser for command line arguments and config-file values.

    :ivar extra_info: Dict of generic param -> value to display in case
        there's an error processing the command line arguments.
    NF	_ispytestc               h   t        |       ddlm} || _        i | _        t        | || j                        | _        | j                  j                  d      }t        |d| d      | _	        | j                  g| _
        | j                  j                  t        d      }||_        i | _        i | _        y )	Nr   )filescompleterzCustom options
_anonymousTr    *)nargs)r   _pytest._argcompleter#   _processopt
extra_infoPytestArgumentParser	optparseradd_argument_groupOptionGroupr$   _groupsadd_argumentFILE_OR_DIR	completer_inidict_ini_aliases)r   usage
processoptr!   r#   anonymous_arggroupfile_or_dir_args          r   __init__zParser.__init__'   s     	y!7%*,-dE4??K!^^>>?OP%dd
 (..55k5M$2!9;,.r   c                .    | j                   j                  S Nr+   progr   s    r   r<   zParser.progA   s    ~~"""r   c                &    || j                   _        y r:   r;   )r   values     r   r<   zParser.progE   s    #r   c                Z    | j                   r|j                  r| j                  |       y y y r:   )r(   dest)r   options     r   processoptionzParser.processoptionI   s*    {{  (  r   c                   | j                   D ]  }|j                  |k(  s|c S  | j                  j                  |xs |      }t	        ||| d      }d}t        | j                         D ]  \  }}|j                  |k(  s n | j                   j                  |dz   |       | j                  j                  j                  |dz   | j                  j                  j                                |S )a  Get (or create) a named option Group.

        :param name: Name of the option group.
        :param description: Long description for --help output.
        :param after: Name of another group, used for ordering --help output.
        :returns: The option group.

        The returned group object has an ``addoption`` method with the same
        signature as :func:`parser.addoption <pytest.Parser.addoption>` but
        will be shown in the respective group in the output of
        ``pytest --help``.
        Tr    r   r   )	r.   namer+   r,   r-   	enumerateinsert_action_groupspop)r   rD   descriptionaftergrouparggroupigrps           r   getgroupzParser.getgroupN   s     \\ 	EzzT!	 >>44[5HDIHdDDA- 	FAsxx5 	 	AE5) 	%%,,QUDNN4Q4Q4U4U4WXr   c                <     | j                   j                  |i | y)a  Register a command line option.

        :param opts:
            Option names, can be short or long options.
        :param attrs:
            Same attributes as the argparse library's :meth:`add_argument()
            <argparse.ArgumentParser.add_argument>` function accepts.

        After command line parsing, options are available on the pytest config
        object via ``config.option.NAME`` where ``NAME`` is usually set
        by passing a ``dest`` attribute, for example
        ``addoption("--long", dest="NAME", ...)``.
        N)r$   	addoption)r   optsattrss      r   rQ   zParser.addoptionm   s     	"!!4151r   c                   ddl m}  || j                         |D cg c]  }t        j                  |       }}|t        j                         }	 d|_        | j                  j                  ||      |`S c c}w # |`w xY w)zParse the arguments.

        Unlike ``parse_known_args`` and ``parse_known_and_unknown_args``,
        raises PrintHelp on `--help` and UsageError on unknown flags

        :meta private:
        r   )try_argcompleteT	namespace)	r'   rU   r+   osfspathargparse	Namespace_raise_print_helpparse_intermixed_args)r   argsrW   rU   xstrargss         r   parsezParser.parse}   s{     	9')-.A299Q<.. **,I	,*.I'>>7797U+ / +s   A8#A= =Bc                .    | j                  ||      d   S )zbParse the known arguments at this point.

        :returns: An argparse namespace object.
        rV   r   )parse_known_and_unknown_args)r   r^   rW   s      r   parse_known_argszParser.parse_known_args   s     000KANNr   c                   |D cg c]  }t        j                  |       }}t        j                  dk  sdt        j                  cxk  rdk  rgn nd| j                  j                  ||      \  }}|J t        |t              }g }|D ]&  }|j                  d      r|n|j                  |       ( ||fS | j                  j                  ||      S c c}w )a	  Parse the known arguments at this point, and also return the
        remaining unknown flag arguments.

        :returns:
            A tuple containing an argparse namespace object for the known
            arguments, and a list of unknown flag arguments.
        )         )rf      )rf   ri   r   -)rX   rY   sysversion_infor+   rd   getattrr0   
startswithappendparse_known_intermixed_args)	r   r^   rW   r_   r`   unknownr   unknown_flagsargs	            r   rc   z#Parser.parse_known_and_unknown_args   s     *..A299Q<..j(Gs7G7G,T*,T!%!@!@)!TIw(((!)[9K')M T"%.."5;NNsSTm++>>==gyQQ /s   Cr   )aliasesc               "   |dv sJ |d}|t         u rt        |      }|||f| j                  |<   |D ][  }|| j                  v rt        d|d      | j                  j                  |      x}t        |d|      || j                  |<   ] y)a  Register a configuration file option.

        :param name:
            Name of the configuration.
        :param type:
            Type of the configuration. Can be:

                * ``string``: a string
                * ``bool``: a boolean
                * ``args``: a list of strings, separated as in a shell
                * ``linelist``: a list of strings, separated by line breaks
                * ``paths``: a list of :class:`pathlib.Path`, separated as in a shell
                * ``pathlist``: a list of ``py.path``, separated as in a shell
                * ``int``: an integer
                * ``float``: a floating-point number

                .. versionadded:: 8.4

                    The ``float`` and ``int`` types.

            For ``paths`` and ``pathlist`` types, they are considered relative to the config-file.
            In case the execution is happening without a config-file defined,
            they will be considered relative to the current working directory (for example with ``--override-ini``).

            .. versionadded:: 7.0
                The ``paths`` variable type.

            .. versionadded:: 8.1
                Use the current working directory to resolve ``paths`` and ``pathlist`` in the absence of a config-file.

            Defaults to ``string`` if ``None`` or not passed.
        :param default:
            Default value if no config-file option exists but is queried.
        :param aliases:
            Additional names by which this option can be referenced.
            Aliases resolve to the canonical name.

            .. versionadded:: 9.0
                The ``aliases`` parameter.

        The value of configuration keys can be retrieved via a call to
        :py:func:`config.getini(name) <pytest.Config.getini>`.
        )	Nstringpathspathlistr^   linelistboolintfloatNrv   zalias z- conflicts with existing configuration optionz is already an alias of )NOT_SETget_ini_default_for_typer2   
ValueErrorr3   get)r   rD   helptypedefaultrt   aliasalreadys           r   addinizParser.addini   s    n  

 

 
	
 

 <Dg.t4G#T73d 	,E% UI%RS   ,,0077D E9,DWK!PQQ'+De$	,r   )NN)r4   
str | Noner5   z!Callable[[Argument], None] | Noner!   rz   r   Noner   )r>   r   r   r   )rA   Argumentr   r   ) N)rD   r   rI   r   rJ   r   r   r-   rR   r   rS   r   r   r   r:   )r^    Sequence[str | os.PathLike[str]]rW   argparse.Namespace | Noner   argparse.Namespace)r^   r   rW   r   r   z$tuple[argparse.Namespace, list[str]])rD   r   r   r   r   zYLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float'] | Noner   r   rt   Sequence[str]r   r   )r   r   r   __doc__r8   propertyr<   setterrB   rO   rQ   ra   rd   rc   r}   r   r   r   r   r   r      sz    !8</
  // 6/
 / 
/4 # # 
[[$ $) EI&)7A	>2& 04,., -, 
	,6 04	O.	O -	O 
		O 04R.R -R 
.	R@ P, "$P,P, P,	P, P, P, 
P,r   r   c                4    | dv rg S | dk(  ry| dk(  ry| dk(  ryy)	zs
    Used by addini to get the default value for a given config option type, when
    default is not supplied.
    )rw   rx   r^   ry   rz   Fr{   r   r|   g        r   r   )r   s    r   r~   r~     s3     88				r   c                       e Zd ZdZddZddZy)ArgumentErrorzURaised if an Argument instance is created with invalid or
    inconsistent arguments.c                2    || _         t        |      | _        y r:   )msgr   	option_id)r   r   rA   s      r   r8   zArgumentError.__init__%  s    Vr   c                j    | j                   rd| j                    d| j                   S | j                  S )Nzoption : )r   r   r   s    r   __str__zArgumentError.__str__)  s.    >>T^^,Btxxj9988Or   N)r   r   rA   zArgument | strr   r   r   )r   r   r   r   r8   r   r   r   r   r   r   !  s    %r   r   c                  8    e Zd ZdZddZd	dZd
dZddZddZy)r   zClass that mimics the necessary behaviour of optparse.Option.

    It's currently a least effort implementation and ignoring choices
    and integer prefixes.

    https://docs.python.org/3/library/optparse.html#optparse-standard-option-types
    c                   || _         g | _        g | _        	 |d   | _        	 |d   | _        | j                  |       |j                  d      }|r|| _        y| j                  r(| j                  d   dd j                  dd      | _        y	 | j                  d   d	d | _        y# t        $ r Y w xY w# t        $ r Y w xY w# t        $ r}d
| _        t        d|       |d}~ww xY w)z5Store params in private vars for use in add_argument.r   r   r@   r      Nrj   _r   z???zneed a long or short option)_attrs_short_opts
_long_optsr   KeyErrorr   _set_opt_stringsr   r@   replace
IndexErrorr   )r   namesrS   r@   es        r   r8   zArgument.__init__9  s    &(%'	fDI	 +DL 	e$ 99V,DI__*12.66sC@DIP ,,Q/3	  		
  		  P!	#$A4HaOPs:   
B% 
B4 C %	B10B14	C ?C 	C%C  C%c                4    | j                   | j                  z   S r:   )r   r   r   s    r   r   zArgument.namesT  s    $//11r   c                    ddd| j                   fD ]  }	 t        | |      | j                  |<    | j                  S # t        $ r Y 6w xY w)Nr   r@   r   )r@   rm   r   AttributeError)r   attrs     r   rS   zArgument.attrsW  sX    		: 	D$+D$$7D!	
 {{ " s   <	AAc                X   |D ]  }t        |      dk  rt        d|d|       t        |      dk(  r<|d   dk(  r|d   dk7  st        d|d|       | j                  j                  |       k|dd d	k(  r|d   dk7  st        d
|d|       | j                  j                  |        y)zhDirectly from optparse.

        Might not be necessary as this is passed to argparse later on.
        r   zinvalid option string z&: must be at least two characters longr   rj   r   zinvalid short option string z/: must be of the form -x, (x any non-dash char)--zinvalid long option string z*: must start with --, followed by non-dashN)lenr   r   ro   r   )r   rR   opts      r   r   zArgument._set_opt_strings`  s    
  	,C3x!|#,SG 4; ; 
 SQA##a&C-'6sg >H H 
   '',AaD(SVs]'5cW =C C 
 &&s+-	,r   c                   g }| j                   r|dt        | j                         z   gz  }| j                  r|dt        | j                        z   gz  }|dt        | j                        z   gz  }t	        | d      r|dt        | j
                        z   gz  }t	        | d      r|dt        | j                        z   gz  }dj                  d	j                  |            S )
Nz_short_opts: z_long_opts: zdest: r   ztype: r   z	default: zArgument({}), )	r   reprr   r@   hasattrr   r   formatjoin)r   r^   s     r   r   zArgument.__repr__}  s    _tD,<,<'==>>D??^d4??&;;<<DDO+,,4 XTYY/00D4#[4#5566D$$TYYt_55r   N)r   r   rS   r   r   r   )r   z	list[str])r   zMapping[str, Any])rR   r   r   r   r   )	r   r   r   r   r8   r   rS   r   r   r   r   r   r   r   0  s!    P62,:6r   r   c                  H    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZd	dZd	dZdd
dZy)r-   z,A group of options shown in its own section.c                R    t        |       || _        || _        g | _        || _        y r:   )r   	_arggrouprD   optionsparser)r   rL   rD   r   r!   s        r   r8   zOptionGroup.__init__  s(     	y!!	')r   c                    t        |      j                  d | j                  D              }|rt        d| d      t	        |i |}| j                  |d       y)aJ  Add an option to this group.

        If a shortened version of a long option is specified, it will
        be suppressed in the help. ``addoption('--twowords', '--two-words')``
        results in help showing ``--two-words`` only, but ``--twowords`` gets
        accepted **and** the automatic destination is in ``args.twowords``.

        :param opts:
            Option names, can be short or long options.
        :param attrs:
            Same attributes as the argparse library's :meth:`add_argument()
            <argparse.ArgumentParser.add_argument>` function accepts.
        c              3  J   K   | ]  }|j                         D ]  }|   y wr:   )r   ).0r   rD   s      r   	<genexpr>z(OptionGroup.addoption.<locals>.<genexpr>  s-      *
SYY[*
-1D*
*
s   !#zoption names z already addedF
shortupperN)setintersectionr   r   r   _addoption_instance)r   rR   rS   conflictrA   s        r   rQ   zOptionGroup.addoption  sd     t9)) *
 LL*
 
 }XJnEFF4)5)  E :r   c                @    t        |i |}| j                  |d       y )NTr   )r   r   )r   rR   rS   rA   s       r   
_addoptionzOptionGroup._addoption  s$    4)5)  D 9r   c                l   |s8|j                   D ])  }|d   dk(  s|d   j                         s t        d       | j                  r| j                  j	                  |        | j
                  j                  |j                         i |j                          | j                  j                  |       y )Nr   rj   r   zlowercase shortoptions reserved)r   islowerr   r   rB   r   r/   r   rS   r   ro   )r   rA   r   r   s       r   r   zOptionGroup._addoption_instance  s    )) Hq6S=SV^^%5$%FGGH ;;KK%%f-###V\\^Fv||~FF#r   N)F)
rL   zargparse._ArgumentGrouprD   r   r   zParser | Noner!   rz   r   r   r   )rA   r   r   rz   r   r   )r   r   r   r   r8   rQ   r   r   r   r   r   r-   r-     sN    6  )  	
  
;,:
$r   r-   c                  8     e Zd Z	 	 	 	 	 	 	 	 d fdZddZ xZS )r*   c                R    || _         t        | 	  |dt        dd       || _        y )NF@)r4   add_helpformatter_classallow_abbrevfromfile_prefix_chars)_parsersuperr8   DropShorterLongHelpFormatterr)   )r   r   r4   r)   	__class__s       r   r8   zPytestArgumentParser.__init__  s6     8"% 	 	
 %r   c           	         | j                    d| }| j                  r?|ddj                  d t        | j                  j	                               D              z   z  }t        | j                         |z         )z1Transform argparse error message into UsageError.z	: error: 
c              3  2   K   | ]  \  }}d | d|   yw)z  r   Nr   )r   kvs      r   r   z-PytestArgumentParser.error.<locals>.<genexpr>  s%      $"&!Q"QCr!$s   )r<   r)   r   sorteditemsr   format_usage)r   messager   s      r   errorzPytestArgumentParser.error  ss    9WI.??4$)) $*01F1F1H*I$   C **,s233r   )r   r   r4   r   r)   zdict[str, str]r   r   )r   r   r   r
   )r   r   r   r8   r   __classcell__r   s   @r   r*   r*     s3    %% % #	%
 
%$4r   r*   c                  6     e Zd ZdZd fdZd fdZd Z xZS )r   a+  Shorten help for long options that differ only in extra hyphens.

    - Collapse **long** options that are the same except for extra hyphens.
    - Shortcut if there are only two options and one of them is a short one.
    - Cache result on the action object as this is called at least 2 times.
    c                n    d|vr!t         j                  j                         |d<   t        |   |i | y )Nwidth)_pytest_ioget_terminal_widthr   r8   )r   r^   kwargsr   s      r   r8   z%DropShorterLongHelpFormatter.__init__  s3    & %kk<<>F7O$)&)r   c                   t         |   |      }|r
|d   dk7  r|S t        |dd       }|r|S |j                  d      }t	        |      dk(  r+t	        |d         dk(  st	        |d         dk(  r	||_        |S g }i }|D ]u  }t	        |      dk(  s|d   dk(  r|j                  d      st        d	| d
|      |dd  }|j                  dd      }	|	|vst	        ||	         t	        |      k  sq|||	<   w |D ]s  }t	        |      dk(  s|d   dk(  r|j                  |       |dd  |j                  |j                  dd            k(  sR|j                  |j                  ddd             u dj                  |      }
|
|_        |
S )Nr   rj   _formatted_action_invocationr   r   r    r   z&long optional argument without "--": []r   =)r   _format_action_invocationrm   splitr   r   rn   r   r   ro   r   r   )r   actionorgstrresr   return_list
short_longrA   xxoption	shortenedformatted_action_invocationr   s              r   r   z6DropShorterLongHelpFormatter._format_action_invocation  s   26:fQi3&M!&*H$OJ,,t$w<1#gaj/Q"6#gaj/Q:N28F/M%'
 	1F6{a6!9#3$$T*#<VHAF  abzH ((b1I
*c*Y2G.H3L / )1
9%	1  	@F6{a6!9#3""6*abzZ^^FNN3,CDD""6>>#sA#>?		@
 '+ii&<#.I+**r   c                    ddl }g }|j                         D ]1  }|j                  |j                  |j	                         |             3 |S )z}Wrap lines after splitting on original newlines.

        This allows to have explicit line breaks in the help text.
        r   N)textwrap
splitlinesextendwrapstrip)r   textr   r   lineslines         r   _split_linesz)DropShorterLongHelpFormatter._split_lines  sD    
 	OO% 	=DLLtzz|U;<	=r   )r^   r   r   r   r   r   )r   zargparse.Actionr   r   )r   r   r   r   r8   r   r   r   r   s   @r   r   r     s    *$+L
r   r   c                  R     e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 	 	 d fdZ	 	 	 	 	 	 ddZ xZS )OverrideIniActionzCustom argparse action that makes a CLI flag equivalent to overriding an
    option, in addition to behaving like `store_true`.

    This can simplify things since code only needs to inspect the config option
    and not consider the CLI flag.
    c               L    t        |   ||dg|i | || _        || _        y )Nr   )r   r8   
ini_option	ini_value)	r   option_stringsr@   r&   r  r  r^   r   r   s	           r   r8   zOverrideIniAction.__init__(  s.     	qB4B6B$"r   c                    t        || j                  d       t        |dd       }|g }|j                  | j                   d| j
                          t        |d|       y )NToverride_inir   )setattrr@   rm   ro   r  r  )r   r   rW   r^   r   current_overridess         r   __call__zOverrideIniAction.__call__6  s_     		499d+#I~tD$ "  DOO#4Adnn5E!FG	>+<=r   r:   )r  r   r@   r   r&   zint | str | Noner  r   r  r   r   r   )r   zargparse.ArgumentParserrW   r   r   r   )r   r   r   r   r8   r  r   r   s   @r   r  r     sm     #'	#%# #  	# # # 
#>'> &> 
>r   r  )r   zRLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float']r   r   )#
__future__r   rZ   collections.abcr   r   r   rX   rk   typingr   r   r	   r
   
exceptionsr   _pytest._ior   _pytest.deprecatedr   r0   r   r}   r   r~   	Exceptionr   r   r-   ArgumentParserr*   HelpFormatterr   Actionr  r   r   r   <module>r     s    "  $ # $ 	 
     "  -  
 ( i, i, i,X 		*I X6 X6v4$ 4$n4822 4:>8#9#9 >B"> ">r   