
    [jE                       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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 dlmZ dZe G d d                      Zdd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j                  Z dS )     )annotationsN)Callable)Sequence)Any)final)Literal)NoReturn   )
UsageError)NOTSET)check_ispytestfile_or_dirc                      e Zd ZdZ	 	 d2dddd3dZed4d            Zej        d5d            Zd6dZ	 d7d8dZ	d9dZ
	 d:d;d%Z	 d:d;d&Z	 d:d<d(Zdefd)d*d=d1ZdS )>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)prog	_ispytestusage
str | None
processopt!Callable[[Argument], None] | Noner   r   boolreturnNonec               |   t          |           ddlm} || _        i | _        t          || j        |          | _        | j                            d          }t          |d| d          | _	        | j	        g| _
        i | _        | j                            t          d	          }||_        i | _        i | _        d S )
Nr   )filescompleterr   zCustom options
_anonymousTr   *)nargs)r   _pytest._argcompleter   _processopt
extra_infoPytestArgumentParser	optparseradd_argument_groupOptionGroupr   _groups	_opt2destadd_argumentFILE_OR_DIR	completer_inidict_ini_aliases)selfr   r   r   r   r   anonymous_arggroupfile_or_dir_args           ]/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/_pytest/config/argparsing.py__init__zParser.__init__    s     	y!!!777777%*,-eT_4PPP!^>>?OPP%dd
 
 
 ()+.55k5MM$2!9;,.    strc                    | j         j        S Nr%   r   r/   s    r2   r   zParser.prog=   s    ~""r4   valuec                    || j         _        d S r7   r8   )r/   r:   s     r2   r   zParser.progA   s    #r4   optionArgumentc                T    | j         r|j        r|                      |           d S d S d S r7   )r"   dest)r/   r<   s     r2   processoptionzParser.processoptionE   sE     	){ )  (((((	) 	)) )r4    namedescriptionafterr'   c                   | j         D ]}|j        |k    r|c S | j                            |p|          }t	          ||| d          }d}t          | j                   D ]\  }}|j        |k    r n| j                             |dz   |           | j        j                            |dz   | 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(   rB   r%   r&   r'   	enumerateinsert_action_groupspop)r/   rB   rC   rD   grouparggroupigrps           r2   getgroupzParser.getgroupJ   s     \ 	 	EzT!! " >44[5HDIIHdDDAAA-- 	 	FAsx5   !AE5))) 	%,,QUDN4Q4U4U4W4WXXXr4   optsattrsr   c                *     | j         j        |i | dS )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/   rO   rP   s      r2   rR   zParser.addoptioni   s$     	"!41511111r4   args Sequence[str | os.PathLike[str]]	namespaceargparse.Namespace | Noneargparse.Namespacec                    ddl m}  || j                   d |D             }|t          j                    }	 d|_        | j                            ||          |`S # |`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_argcompletec                6    g | ]}t          j        |          S  osfspath.0xs     r2   
<listcomp>z Parser.parse.<locals>.<listcomp>        ...A29Q<<...r4   NTrV   )r!   rZ   r%   argparse	Namespace_raise_print_helpparse_intermixed_args)r/   rT   rV   rZ   strargss        r2   parsezParser.parsey   s     	988888'''..... *,,I	,*.I'>7797UU++	+++++s   "A A"c                <    |                      ||          d         S )zbParse the known arguments at this point.

        :returns: An argparse namespace object.
        re   r   )parse_known_and_unknown_args)r/   rT   rV   s      r2   parse_known_argszParser.parse_known_args   s"     000KKANNr4   $tuple[argparse.Namespace, list[str]]c                   d |D             }t           j        dk     sdt           j        cxk    rdk     rqn nn| j                            ||          \  }}|J t	          |t
                    }g }|D ].}|                    d          r|n|                    |           /||fS | j                            ||          S )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.
        c                6    g | ]}t          j        |          S r\   r]   r`   s     r2   rc   z7Parser.parse_known_and_unknown_args.<locals>.<listcomp>   rd   r4   )         )rr      )rr   ru   r
   N-)	sysversion_infor%   rn   getattrr+   
startswithappendparse_known_intermixed_args)r/   rT   rV   rj   unknownr   unknown_flagsargs           r2   rm   z#Parser.parse_known_and_unknown_args   s     /....j((Gs7G,T,T,T,T*,T,T,T,T,T!%!@!@)!T!TIw(((!)[99K')M T T"%.."5"5F;NNsSSSSm++>==gyQQQr4   r\   )aliaseshelptypeYLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float'] | Nonedefaultr   Sequence[str]c                  |dv sJ |d}|t           u rt          |          }|||f| j        |<   |D ]X}|| j        v rt          d|d          | j                            |          x}t          |d|          || j        |<   YdS )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pathlistrT   linelistr   intfloatNr   zalias z- conflicts with existing configuration optionz is already an alias of )r   get_ini_default_for_typer-   
ValueErrorr.   get)r/   rB   r   r   r   r   aliasalreadys           r2   addinizParser.addini   s    n  

 

 

 

 

 <Df.t44G#T73d 	, 	,E%% SUSSS    ,00777D E!P!PW!P!PQQQ'+De$$	, 	,r4   )NN)
r   r   r   r   r   r   r   r   r   r   r   r5   )r:   r5   r   r   )r<   r=   r   r   )rA   N)rB   r5   rC   r5   rD   r   r   r'   rO   r5   rP   r   r   r   r7   )rT   rU   rV   rW   r   rX   )rT   rU   rV   rW   r   ro   )rB   r5   r   r5   r   r   r   r   r   r   r   r   )__name__
__module____qualname____doc__r3   propertyr   setterr@   rN   rR   rk   rn   rm   r   r   r\   r4   r2   r   r      sy         !8</
  / / / / / /: # # # X# 
[$ $ $ [$) ) ) ) EI    >2 2 2 2& 04, , , , ,6 04	O 	O 	O 	O 	O 04R R R R R@ P, "$P, P, P, P, P, P, P, P,r4   r   r   RLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float']r   r   c                B    | dv rg S | dk    rdS | dk    rdS | dk    rdS dS )	zs
    Used by addini to get the default value for a given config option type, when
    default is not supplied.
    )r   r   rT   r   r   Fr   r   r   g        rA   r\   )r   s    r2   r   r     sD     888		u	q	srr4   c                  z    e Zd ZdZddZddZdd
Zedd            Zedd            Z	edd            Z
ddZdS )r=   z$An option defined in an OptionGroup.actionargparse.Actionr   r   c                    || _         d S r7   )_action)r/   r   s     r2   r3   zArgument.__init__   s    r4   dict[str, Any]c                    | j         j        S r7   )r   __dict__r9   s    r2   rP   zArgument.attrs#  s    |$$r4   r   c                    | j         j        S r7   )r   option_stringsr9   s    r2   nameszArgument.names&  s    |**r4   r5   c                    | j         j        S r7   )r   r?   r9   s    r2   r?   zArgument.dest)      |  r4   r   c                    | j         j        S r7   )r   r   r9   s    r2   r   zArgument.default-  s    |##r4   
Any | Nonec                    | j         j        S r7   )r   r   r9   s    r2   r   zArgument.type1  r   r4   c                   t          | dd           }|dS g }|dt          |                                           z   gz  }|dt          | j                  z   gz  }|j        r|dt          | j                  z   gz  }|dt          | j                  z   gz  }d                    d                    |                    S )	Nr   zArgument(<uninitialized>)zopts: zdest: ztype: z	default: zArgument({}), )ry   reprr   r?   r   r   formatjoin)r/   r   rT   s      r2   __repr__zArgument.__repr__5  s    y$//>..D...//DOO+,,; 	1XTY/00DtDL11122$$TYYt__555r4   N)r   r   r   r   )r   r   )r   r   r   )r   r   )r   r   )r   r   r   r   r3   rP   r   r   r?   r   r   r   r\   r4   r2   r=   r=     s        ..   % % % %+ + + + ! ! ! X! $ $ $ X$ ! ! ! X!
6 
6 
6 
6 
6 
6r4   r=   c                  6    e Zd ZdZ	 dddZddZddZddZdS )r'   z,A group of options shown in its own section.FrK   argparse._ArgumentGrouprB   r5   parserParser | Noner   r   r   r   c                \    t          |           || _        || _        g | _        || _        d S r7   )r   	_arggrouprB   optionsr   )r/   rK   rB   r   r   s        r2   r3   zOptionGroup.__init__E  s2     	y!!!!	')r4   rO   rP   r   c                    t          |                              d | j        D                       }|rt          d| d          |                     ||d           dS )a  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.
            Note that lower-case short options (e.g. `-x`) are reserved.
        :param attrs:
            Same attributes as the argparse library's :meth:`add_argument()
            <argparse.ArgumentParser.add_argument>` function accepts.
        c              3  H   K   | ]}|                                 D ]}|V  d S r7   )r   )ra   optrB   s      r2   	<genexpr>z(OptionGroup.addoption.<locals>.<genexpr>a  sO       *
 *
SYY[[*
 *
-1D*
 *
 *
 *
 *
 *
 *
r4   zoption names z already addedFallow_reservedN)setintersectionr   r   _addoption_inner)r/   rO   rP   conflicts       r2   rR   zOptionGroup.addoptionR  s     t99)) *
 *
 L*
 *
 *
 
 
  	GEXEEEFFFdE%@@@@@r4   c                6    |                      ||d           dS )z}Like addoption(), but also allows registering short lower case options (e.g. -x),
        which are reserved for pytest core.Tr   N)r   rS   s      r2   
_addoptionzOptionGroup._addoptionh  s%     	dE$?????r4   tuple[str, ...]r   r   c                   |sM|D ]J}t          |          dk    r5|d         dk    r)|d                                         rt          d          K | j        j        |i |}t          |          }| j                            |           | j        rG|	                                D ]}|j
        | j        j        |<   | j                            |           d S d S )N   r   rv   r
   z$lowercase short options are reserved)lenislowerr   r   r*   r=   r   r{   r   r   r?   r)   r@   )r/   rO   rP   r   r   r   r<   rB   s           r2   r   zOptionGroup._addoption_innerm  s      	M M Ms88q==SVs]]s1v~~7G7G]$%KLLL,,d<e<<&!!F###; 	. : :.4k%d++K%%f-----	. 	.r4   N)F)
rK   r   rB   r5   r   r   r   r   r   r   r   )rO   r   rP   r   r   r   r   r   )r   r   r   r   r3   rR   r   r   r\   r4   r2   r'   r'   B  s|        66      A A A A,@ @ @ @
. . . . . .r4   r'   c                  .     e Zd Zddd fd
ZddZ xZS )r$   Nr   r   r   r#   dict[str, str]r   r   r   c               n    t                                          ||dt          dd           || _        d S )NF@)r   r   add_helpformatter_classallow_abbrevfromfile_prefix_chars)superr3   DropShorterLongHelpFormatterr#   )r/   r   r#   r   	__class__s       r2   r3   zPytestArgumentParser.__init__  sE     	8"% 	 	
 	
 	
 %r4   messager5   r	   c           	        | j          d| }| j        rI|dd                    d t          | j                                                  D                       z   z  }t          |                                 |z             )z1Transform argparse error message into UsageError.z	: error: 
c              3  ,   K   | ]\  }}d | d| V  dS )z  z: Nr\   )ra   kvs      r2   r   z-PytestArgumentParser.error.<locals>.<genexpr>  sC       $ $"&!QQ!$ $ $ $ $ $r4   )r   r#   r   sorteditemsr   format_usage)r/   r   msgs      r2   errorzPytestArgumentParser.error  s     ..W..? 	4$)) $ $*01F1F1H1H*I*I$ $ $    C **,,s2333r4   )r   r   r#   r   r   r   r   r   )r   r5   r   r	   )r   r   r   r3   r   __classcell__r   s   @r2   r$   r$   ~  s`          % % % % % % % %&	4 	4 	4 	4 	4 	4 	4 	4r4   r$   c                  8     e Zd ZdZd fdZd fdZddZ xZS )r   zShorten 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.
    rT   r   kwargsr   r   c                    d|vr!t           j                                        |d<    t                      j        |i | d S )Nwidth)_pytest_ioget_terminal_widthr   r3   )r/   rT   r   r   s      r2   r3   z%DropShorterLongHelpFormatter.__init__  sG    &  %k<<>>F7O$)&)))))r4   r   r   r5   c                   t                                          |          }|r|d         dk    r|S |                    d          }t          |          dk    r4t          |d                   dk    st          |d                   dk    r|S g }i }|D ]}t          |          dk    s|d         dk    r"|                    d          sJ d| d	            |dd          }|                    dd
          }||vs&t          ||                   t          |          k     r|||<   |D ]}t          |          dk    s|d         dk    r|                    |           |dd          |                    |                    dd
                    k    r*|                    |                    ddd                     d                    |          S )Nr   rv   r   r   r
    z--z&long optional argument without "--": []rA   =)	r   _format_action_invocationsplitr   rz   replacer{   r   r   )
r/   r   orgstrr   return_list
short_longr<   xxoption	shortenedr   s
            r2   r   z6DropShorterLongHelpFormatter._format_action_invocation  s   226:: 	fQi3&&M,,t$$w<<1#gaj//Q"6"6#gaj//Q:N:NM%'
 	1 	1F6{{a6!9#3#3$$T**  BBBB   abbzH ((b11I
**c*Y2G.H.H3L L / / )1
9%  	@ 	@F6{{a6!9#3#3""6***abbzZ^^FNN3,C,CDDDD""6>>#sA#>#>???yy%%%r4   textr   r   	list[str]c                    g }|                                 D ]<}|                    t          j        |                                |                     =|S )z}Wrap lines after splitting on original newlines.

        This allows to have explicit line breaks in the help text.
        )
splitlinesextendtextwrapwrapstrip)r/   r   r   lineslines        r2   _split_linesz)DropShorterLongHelpFormatter._split_lines  sP    
 OO%% 	= 	=DLLtzz||U;;<<<<r4   )rT   r   r   r   r   r   )r   r   r   r5   )r   r5   r   r   r   r   )r   r   r   r   r3   r   r   r   r   s   @r2   r   r     sy         * * * * * *& & & & & &>       r4   r   c                  0     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.
    Nr   r   r?   r5   r    int | str | None
ini_option	ini_valuer   r   c               b     t                      j        ||dg|R i | || _        || _        d S )Nr   )r   r3   r  r  )	r/   r   r?   r    r  r  rT   r   r   s	           r2   r3   zOverrideIniAction.__init__  sB     	qB4BBB6BBB$"r4   r   argparse.ArgumentParserrV   rX   c                    t          || j        d           t          |dd           }|g }|                    | j         d| j                    t          |d|           d S )NToverride_inir   )setattrr?   ry   r{   r  r  )r/   r   rV   rT   r   current_overridess         r2   __call__zOverrideIniAction.__call__  su     		49d+++#I~tDD$ "  DO!F!Fdn!F!FGGG	>+<=====r4   r7   )r   r   r?   r5   r    r  r  r5   r  r5   r   r   )r   r  rV   rX   r   r   )r   r   r   r   r3   r  r   r   s   @r2   r  r    se          #'	# # # # # # #> > > > > > > >r4   r  )r   r   r   r   )!
__future__r   rf   collections.abcr   r   r^   rw   r   typingr   r   r   r	   
exceptionsr   _pytest._ior   _pytest.compatr   _pytest.deprecatedr   r+   r   r   r=   r'   ArgumentParserr$   HelpFormatterr   Actionr  r\   r4   r2   <module>r     s%   " " " " " "  $ $ $ $ $ $ $ $ $ $ $ $ 				 



                          " " " " " "     ! ! ! ! ! ! - - - - - -  l, l, l, l, l, l, l, l,^   *"6 "6 "6 "6 "6 "6 "6 "6J9. 9. 9. 9. 9. 9. 9. 9.x4 4 4 4 482 4 4 4@4 4 4 4 48#9 4 4 4n"> "> "> "> "> "> "> "> "> ">r4   