
    bi'                       d dl mZ d dlZd dlmZmZ ddlmZ ddlm	Z	 g dZ
d"d
Z G d de          Z G d de          Z G d de          Z G d d          Z G d d          Zd#dZ ej        d          Zd$dZd%d!ZdS )&    )annotationsN)MappingSequence   )_ErrorCollector)Requirement)CyclicDependencyGroupDependencyGroupIncludeDependencyGroupResolverDuplicateGroupNamesInvalidDependencyGroupObjectresolve_dependency_groupsreturn	list[str]c                     t           S N)__all__     s/home/jenkins/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/packaging/dependency_groups.py__dir__r      s    Nr   c                      e Zd ZdZdS )r   z]
    The same dependency groups were defined twice, with different non-normalized names.
    N__name__
__module____qualname____doc__r   r   r   r   r      s           r   r   c                  $     e Zd ZdZd	 fdZ xZS )
r	   z5
    The dependency group includes form a cycle.
    requested_groupstrgroupinclude_groupr   Nonec                    || _         || _        || _        ||k    r| d}n| d| d| d| }t                                          d| d|            d S )Nz includes itselfz -> , z0Cyclic dependency group include while resolving z: )r   r!   r"   super__init__)selfr   r!   r"   reason	__class__s        r   r'   zCyclicDependencyGroup.__init__'   s    .
*E!!///FF%NN5NNENN}NNF++ +"(+ +	
 	
 	
 	
 	
r   )r   r    r!   r    r"   r    r   r#   )r   r   r   r   r'   __classcell__)r*   s   @r   r	   r	   "   sG         
 
 
 
 
 
 
 
 
 
r   r	   c                      e Zd ZdZdS )r   ze
    A member of a dependency group was identified as a dict, but was not in a valid
    format.
    Nr   r   r   r   r   r   9   s           r   r   c                  "    e Zd ZdZd	dZd
dZdS )r
   r"   r"   r    r   r#   c                    || _         dS )z
        Initialize a DependencyGroupInclude.

        :param include_group: The name of the group referred to by this include.
        Nr.   )r(   r"   s     r   r'   zDependencyGroupInclude.__init__H   s     +r   c                0    | j         j         d| j        dS )N())r*   r   r"   )r(   s    r   __repr__zDependencyGroupInclude.__repr__P   s!    .)CCD,>CCCCr   N)r"   r    r   r#   )r   r    )r   r   r   	__slots__r'   r3   r   r   r   r
   r
   E   sG        "I+ + + +D D D D D Dr   r
   c                  :    e Zd ZdZddZdd
ZddZddZddZdS )r   a\  
    A resolver for Dependency Group data.

    This class handles caching, name normalization, cycle detection, and other
    parsing requirements. There are only two public methods for exploring the data:
    ``lookup()`` and ``resolve()``.

    :param dependency_groups: A mapping, as provided via pyproject
        ``[dependency-groups]``.
    dependency_groups/Mapping[str, Sequence[str | Mapping[str, str]]]r   r#   c                    t                      }t          ||          | _        i | _        i | _        i | _        |                    d           d S )Nz$[dependency-groups] data was invalid)r   _normalize_group_namesr6   _parsed_groups_include_graph_ancestors_resolve_cachefinalize)r(   r6   errorss      r   r'   z DependencyGroupResolver.__init__`   s\     !""!78I6!R!R
  	 EG%BD>?????r   r!   r    0tuple[Requirement | DependencyGroupInclude, ...]c                    t          |          }t                                          d|d          5 }|                     ||          cddd           S # 1 swxY w Y   dS )z
        Lookup a group name, returning the parsed dependency data for that group.
        This will not resolve includes.

        :param group: the name of the group to lookup
        [dependency-groups] data for  was malformedN)_normalize_namer   on_exit_parse_groupr(   r!   r>   s      r   lookupzDependencyGroupResolver.lookups   s      &&&&CECCC
 
 	4$$UF33	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   AAAtuple[Requirement, ...]c                    t          |          }t                                          d|d          5 }|                     |||          cddd           S # 1 swxY w Y   dS )z
        Resolve a dependency group to a list of requirements.

        :param group: the name of the group to resolve
        rA   rB   N)rC   r   rD   _resolverF   s      r   resolvezDependencyGroupResolver.resolve   s      &&&&CECCC
 
 	7==v66	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   AA Ar   r>   r   c                   || j         v r| j         |         S |                     ||          }g }|D ]}t          |t                    r|                    |           .t          |t
                    rt          |j                  }|| j        	                    |d          v r*|
                    t          |||j                             g | j        	                    |d          |R | j        |<   |                    |                     |||                     t          d|           |j        rdS t!          |          | j         |<   | j         |         S )a  
        This is a helper for cached resolution to strings. It preserves the name of the
        group which the user initially requested in order to present a clearer error in
        the event that a cycle is detected.

        :param group: The normalized name of the group to resolve.
        :param requested_group: The group which was used in the original, user-facing
            request.
        r   z+Invalid dependency group item after parse: )r<   rE   
isinstancer   appendr
   rC   r"   r;   geterrorr	   extendrJ   NotImplementedErrorr>   tuple)r(   r!   r   r>   parsedresolved_groupitemr"   s           r   rJ   z DependencyGroupResolver._resolve   s    D'''&u--""5&11 	 	D$,, %%d++++D"899  /0B C C !D$A$E$EeR$P$PPPLL-+UD4F    D6::5"EEDD DD1-@ #))m_fMM    *H$HH   = 	2%*>%:%:E""5))r   c                   || j         v r| j         |         S || j        vr(|                    t          d| d                     dS | j        |         }t	          |t
                    r(|                    t          d|d                     dS t	          |t                    s(|                    t          d|d                     dS g }|D ]}t	          |t
                    r#|                    t          |                     :t	          |t                    rwt          |                                          dk    r&|                    t          d|                     |d	         }|                    t          |
                     |                    t          d|                     t          |          | j         |<   | j         |         S )NzDependency group 'z' not foundr   zDependency group z' contained a string rather than a list.z is not a sequence type.)include-groupzInvalid dependency group item: rX   r.   )r:   r6   rP   LookupErrorrM   r    	TypeErrorr   rN   r   r   rS   keysr   r
   )r(   r!   r>   	raw_groupelementsrV   r"   s          r   rE   z$DependencyGroupResolver._parse_group   s    D'''&u--...LL%L%%L%L%LMMNNN2*51	i%% 	LLXXXX   
 2)X.. 	LLOeOOOPP   2?A 	T 	TD$$$ T D 1 12222D'** T%%);;;LL4FdFF     %)$9MOO$:$W$W$WXXXXY'Q'Q'QRRSSSS%*8__E""5))r   N)r6   r7   r   r#   )r!   r    r   r?   )r!   r    r   rH   )r!   r    r   r    r>   r   r   rH   )r!   r    r>   r   r   r?   )	r   r   r   r   r'   rG   rK   rJ   rE   r   r   r   r   r   T   s        	 	@ @ @ @&4 4 4 47 7 7 78* 8* 8* 8*t/* /* /* /* /* /*r   r   r6   r7   groupsr    tuple[str, ...]c               X    t          |           t          fd|D                       S )z
    Resolve a dependency group to a tuple of requirements, as strings.

    :param dependency_groups: the parsed contents of the ``[dependency-groups]`` table
        from ``pyproject.toml``
    :param groups: the name of the group(s) to resolve
    c              3  f   K   | ]+}                     |          D ]}t          |          V  ,d S r   )rK   r    ).0r!   rresolvers      r   	<genexpr>z,resolve_dependency_groups.<locals>.<genexpr>
  sD      MMEX5E5Ee5L5LMMQMMMMMMMr   )r   rS   )r6   r^   rd   s     @r   r   r      s6     ''899HMMMMVMMMMMMr   z[-_.]+namec                \    t                               d|                                           S )N-)_NORMALIZE_PATTERNsublower)rf   s    r   rC   rC     s$    !!#t,,22444r   r>   r   ,dict[str, Sequence[str | Mapping[str, str]]]c                   i }i }|                                  D ]B\  }}t          |          }|                    |g                               |           |||<   C|                                 D ]T\  }}t	          |          dk    r<|                    t          d| dd                    |           d                     U|S )Nr   z"Duplicate dependency group names: z (r%   r2   )itemsrC   
setdefaultrN   lenrP   r   join)	r6   r>   original_namesnormalized_groups
group_namevaluenormed_group_namenormed_namenamess	            r   r9   r9     s     ,.NFH.4466 5 5
E+J77!!"3R88??
KKK/4+,,,2244  Uu::>>LL#:": :&*ii&6&6: : :    r   )r   r   )r6   r7   r^   r    r   r_   )rf   r    r   r    )r6   r7   r>   r   r   rl   )
__future__r   recollections.abcr   r   r>   r   requirementsr   r   r   
ValueErrorr   r	   r   r
   r   r   compileri   rC   r9   r   r   r   <module>r      s   " " " " " " 				 - - - - - - - - # # # # # # % % % % % %         *   
 
 
 
 
J 
 
 
.    :   D D D D D D D Dc* c* c* c* c* c* c* c*VN N N N&  RZ	** 5 5 5 5     r   