o
    g¹«jØ+  ã                   @  sÊ   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
d„ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ dƒZG dd„ dƒZd'dd„Ze d¡Zd(dd „Zd)d$d%„ZdS )*é    )ÚannotationsN)ÚMappingÚSequenceé   )Ú_ErrorCollector)ÚInvalidRequirementÚRequirement)ÚCyclicDependencyGroupÚDependencyGroupIncludeÚDependencyGroupResolverÚDuplicateGroupNamesÚInvalidDependencyGroupObjectÚresolve_dependency_groupsÚreturnú	list[str]c                   C  s   t S ©N)Ú__all__© r   r   ú[/var/www/html/laksyashrimp/venv/lib/python3.10/site-packages/packaging/dependency_groups.pyÚ__dir__   s   r   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      ó    r   c                      s,   e Zd ZdZd‡ fdd	„Zddd„Z‡  ZS )r	   zQ
    The dependency group includes form a cycle.

    .. versionadded:: 26.1
    Úrequested_groupÚstrÚgroupÚinclude_groupr   ÚNonec                   s\   || _ || _|| _||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__r   r   r$   +   s   ÿÿÿzCyclicDependencyGroup.__init__ú8tuple[type[CyclicDependencyGroup], tuple[str, str, str]]c                 C  s   | j | j| j| jffS r   )r(   r   r   r    ©r%   r   r   r   Ú
__reduce__:   ó   z CyclicDependencyGroup.__reduce__)r   r   r   r   r    r   r   r!   )r   r)   )r   r   r   r   r$   r+   Ú__classcell__r   r   r'   r   r	   $   s    r	   c                   @  r   )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   r   r   c                   @  s(   e Zd ZdZdZddd„Zdd	d
„ZdS )r
   zV
    A reference to another dependency group by name.

    .. versionadded:: 26.1
    ©r    r    r   r   r!   c                 C  s
   || _ dS )zˆ
        Initialize a DependencyGroupInclude.

        :param include_group: The name of the group referred to by this include.
        Nr.   )r%   r    r   r   r   r$   X   s   
zDependencyGroupInclude.__init__c                 C  s   | j j› d| j›d�S )Nú(ú))r(   r   r    r*   r   r   r   Ú__repr__`   r,   zDependencyGroupInclude.__repr__N)r    r   r   r!   )r   r   )r   r   r   r   Ú	__slots__r$   r1   r   r   r   r   r
   O   s
    
r
   c                   @  sB   e Zd ZdZddd„Zddd„Zddd„Zddd„Zd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                 C  s2   t ƒ }t||ƒ| _i | _i | _i | _| d¡ d S )Nz$[dependency-groups] data was invalid)r   Ú_normalize_group_namesr3   Ú_parsed_groupsÚ_include_graph_ancestorsÚ_resolve_cacheÚfinalize)r%   r3   Úerrorsr   r   r   r$   r   s   þz DependencyGroupResolver.__init__r   r   ú0tuple[Requirement | DependencyGroupInclude, ...]c                 C  sL   t |ƒ}tƒ  d|›d�¡�}|  ||¡W  d  ƒ S 1 s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:   r   r   r   Úlookup…   s   
ÿ
$ýzDependencyGroupResolver.lookupútuple[Requirement, ...]c                 C  sN   t |ƒ}tƒ  d|›d�¡�}|  |||¡W  d  ƒ S 1 s w   Y  dS )z
        Resolve a dependency group to a list of requirements.

        :param group: the name of the group to resolve
        r<   r=   N)r>   r   r?   Ú_resolverA   r   r   r   Úresolve“   s   
ÿ$ýzDependencyGroupResolver.resolver   r:   r   c                 C  sâ   || j v r
| j | S |  ||¡}g }|D ]K}t|tƒr!| |¡ qt|tƒrYt|jƒ}|| j 	|d¡v r?| 
t|||jƒ¡ qg | j 	|d¡¢|‘R | j|< | |  |||¡¡ qtd|› �ƒ‚|jred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: )r8   r@   Ú
isinstancer   Úappendr
   r>   r    r7   ÚgetÚerrorr	   ÚextendrD   ÚNotImplementedErrorr:   Útuple)r%   r   r   r:   ÚparsedÚresolved_groupÚitemr    r   r   r   rD       s<   




ÿÿÿþÿÿ
z DependencyGroupResolver._resolvec              	   C  s€  || j v r
| j | S || jvr| td|› d�ƒ¡ dS | j| }t|tƒr3| td|›d�ƒ¡ dS t|tƒsE| td|›d�ƒ¡ dS g }|D ]e}t|tƒrm| t	¡� | 
t|ƒ¡ W d   ƒ n1 sgw   Y  qIt|tƒr¤t| ¡ ƒdkr…| td|›�ƒ¡ qI|d	 }t|tƒs›d
|›�}| t|ƒ¡ qI| 
t|d�¡ qI| td|›�ƒ¡ qI|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: rP   z6Dependency group include-group value is not a string: r.   )r6   r3   rI   ÚLookupErrorrF   r   Ú	TypeErrorr   Úcollectr   rG   r   r   rL   Úkeysr   r
   r:   )r%   r   r:   Ú	raw_groupÚelementsrO   r    Úmsgr   r   r   r@   Ú   s^   





ÿÿ
ÿ
ÿ€
ÿÿ
ÿÿÿ
z$DependencyGroupResolver._parse_groupN)r3   r4   r   r!   )r   r   r   r;   )r   r   r   rC   )r   r   r   r   r:   r   r   rC   )r   r   r:   r   r   r;   )	r   r   r   r   r$   rB   rE   rD   r@   r   r   r   r   r   d   s    



:r   r3   r4   Úgroupsr   útuple[str, ...]c                  s   t | ƒ‰ t‡ fd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  s(   � | ]}ˆ   |¡D ]}t|ƒV  q	qd S r   )rE   r   )Ú.0r   Úr©Úresolverr   r   Ú	<genexpr>+  s   €& z,resolve_dependency_groups.<locals>.<genexpr>)r   rL   )r3   rX   r   r\   r   r     s   r   z[-_.]+Únamec                 C  s   t  d| ¡ ¡ S )Nú-)Ú_NORMALIZE_PATTERNÚsubÚlower)r_   r   r   r   r>   6  s   r>   r:   r   ú,dict[str, Sequence[str | Mapping[str, str]]]c           	   
   C  s€   i }i }|   ¡ D ]\}}t|ƒ}| |g ¡ |¡ |||< q|  ¡ D ]\}}t|ƒdkr=| td|› dd |¡› d�ƒ¡ q"|S )Nr   z"Duplicate dependency group names: z (r"   r0   )Úitemsr>   Ú
setdefaultrG   ÚlenrI   r   Újoin)	r3   r:   Úoriginal_namesÚnormalized_groupsÚ
group_nameÚvalueÚnormed_group_nameÚnormed_nameÚnamesr   r   r   r5   :  s&   
ÿÿÿÿ€r5   )r   r   )r3   r4   rX   r   r   rY   )r_   r   r   r   )r3   r4   r:   r   r   rd   )Ú
__future__r   ÚreÚcollections.abcr   r   r:   r   Úrequirementsr   r   r   r   Ú
ValueErrorr   r	   r   r
   r   r   Úcompilera   r>   r5   r   r   r   r   Ú<module>   s"    

	 
;

