
    j+                       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	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)InvalidRequirementRequirement)CyclicDependencyGroupDependencyGroupIncludeDependencyGroupResolverDuplicateGroupNamesInvalidDependencyGroupObjectresolve_dependency_groupsreturn	list[str]c                     t           S N)__all__     Z/var/www/html/python-test/venv/lib/python3.11/site-packages/packaging/dependency_groups.py__dir__r      s    Nr   c                      e Zd ZdZdS )r   zy
    The same dependency groups were defined twice, with different non-normalized names.

    .. versionadded:: 26.1
    N__name__
__module____qualname____doc__r   r   r   r   r      s           r   r   c                  ,     e Zd ZdZd fdZdd
Z xZS )r
   zQ
    The dependency group includes form a cycle.

    .. versionadded:: 26.1
    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   8tuple[type[CyclicDependencyGroup], tuple[str, str, str]]c                8    | j         | j        | j        | j        ffS r   )r+   r    r"   r#   r)   s    r   
__reduce__z CyclicDependencyGroup.__reduce__:   s    !5tz4CU VWWr   )r    r!   r"   r!   r#   r!   r   r$   )r   r,   )r   r   r   r   r(   r/   __classcell__)r+   s   @r   r
   r
   $   sc         
 
 
 
 
 
X X X X X X X Xr   r
   c                      e Zd ZdZdS )r   z
    A member of a dependency group was identified as a dict, but was not in a valid
    format.

    .. versionadded:: 26.1
    Nr   r   r   r   r   r   A   s           r   r   c                  &    e Zd ZdZdZd
dZddZd	S )r   zV
    A reference to another dependency group by name.

    .. versionadded:: 26.1
    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.
        Nr3   )r)   r#   s     r   r(   zDependencyGroupInclude.__init__X   s     +r   c                0    | j         j         d| j        dS )N())r+   r   r#   r.   s    r   __repr__zDependencyGroupInclude.__repr__`   s!    .)CCD,>CCCCr   N)r#   r!   r   r$   )r   r!   )r   r   r   r   	__slots__r(   r8   r   r   r   r   r   O   sS          #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   ax  
    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]``.

    .. versionadded:: 26.1
    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_namesr;   _parsed_groups_include_graph_ancestors_resolve_cachefinalize)r)   r;   errorss      r   r(   z DependencyGroupResolver.__init__r   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"   rC   s      r   lookupzDependencyGroupResolver.lookup   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
        rF   rG   N)rH   r   rI   _resolverK   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    rC   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: )rA   rJ   
isinstancer	   appendr   rH   r#   r@   geterrorr
   extendrO   NotImplementedErrorrC   tuple)r)   r"   r    rC   parsedresolved_groupitemr#   s           r   rO   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
                    rU|                    t                    5  |
                    t          |                     d d d            n# 1 swxY w Y   mt	          |t                    rt          |                                          dk    r&|                    t          d|                     |d	         }t	          |t
                    s)d
|}|                    t          |                     |
                    t!          |                     8|                    t          d|                     _|j        rdS 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: r]   z6Dependency group include-group value is not a string: r3   )r?   r;   rU   LookupErrorrR   r!   	TypeErrorr   collectr   rS   r	   r   rX   keysr   r   rC   )r)   r"   rC   	raw_groupelementsr[   r#   msgs           r   rJ   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 ^^$677 7 7OOK$5$56667 7 7 7 7 7 7 7 7 7 7 7 7 7 7D'** T%%);;;LL4FdFF     %)$9M%mS99 	(#( (  Ys^^4444 2OOO    Y'Q'Q'QRRSSSS= 	2%*8__E""5))s   #D44D8	;D8	N)r;   r<   r   r$   )r"   r!   r   rD   )r"   r!   r   rM   )r"   r!   r    r!   rC   r   r   rM   )r"   r!   rC   r   r   rD   )	r   r   r   r   r(   rL   rP   rO   rJ   r   r   r   r   r   d   s         @ @ @ @&4 4 4 47 7 7 78* 8* 8* 8*t<* <* <* <* <* <*r   r   r;   r<   groupsr!   tuple[str, ...]c               X    t          |           t          fd|D                       S )a  
    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

    .. versionadded:: 26.1
    c              3  f   K   | ]+}                     |          D ]}t          |          V  ,d S r   )rP   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   rX   )r;   re   rk   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)rm   s    r   rH   rH   6  s$    !!#t,,22444r   rC   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&   r7   )itemsrH   
setdefaultrS   lenrU   r   join)	r;   rC   original_namesnormalized_groups
group_namevaluenormed_group_namenormed_namenamess	            r   r>   r>   :  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   )r;   r<   re   r!   r   rf   )rm   r!   r   r!   )r;   r<   rC   r   r   rs   )
__future__r   recollections.abcr   r   rC   r   requirementsr   r	   r   r   
ValueErrorr   r
   r   r   r   r   compilerp   rH   r>   r   r   r   <module>r      s   " " " " " " 				 - - - - - - - - # # # # # # 9 9 9 9 9 9 9 9         *   X X X X XJ X X X:    :   D D D D D D D D*r* r* r* r* r* r* r* r*tN N N N*  RZ	** 5 5 5 5     r   