a
    ç´«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
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dœdd„Ze d¡Zdddœdd„Zdd d!d"œd#d$„ZdS )%é    )ÚannotationsN)ÚMappingÚSequenceé   )Ú_ErrorCollector)ÚInvalidRequirementÚRequirement)ÚCyclicDependencyGroupÚDependencyGroupIncludeÚDependencyGroupResolverÚDuplicateGroupNamesÚInvalidDependencyGroupObjectÚresolve_dependency_groupsz	list[str]©Úreturnc                   C  s   t S ©N)Ú__all__© r   r   úZ/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/packaging/dependency_groups.pyÚ__dir__   s    r   c                   @  s   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   c                      s:   e Zd ZdZdddddœ‡ fdd„Zddœd	d
„Z‡  ZS )r	   zQ
    The dependency group includes form a cycle.

    .. versionadded:: 26.1
    ÚstrÚNone)Úrequested_groupÚgroupÚinclude_groupr   c                   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__z8tuple[type[CyclicDependencyGroup], tuple[str, str, str]]r   c                 C  s   | j | j| j| jffS r   )r&   r   r   r   ©r#   r   r   r   Ú
__reduce__:   s    z CyclicDependencyGroup.__reduce__)r   r   r   r   r"   r(   Ú__classcell__r   r   r%   r   r	   $   s   r	   c                   @  s   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   c                   @  s2   e Zd ZdZdZdddœdd„Zd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__r   c                 C  s   | j j› d| j›d�S )Nú(ú))r&   r   r   r'   r   r   r   Ú__repr__`   s    zDependencyGroupInclude.__repr__N)r   r   r   r   Ú	__slots__r"   r-   r   r   r   r   r
   O   s   r
   c                   @  sf   e Zd ZdZdddœdd„Zddd	œd
d„Zddd	œdd„Zdddddœdd„Zddd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
    ú/Mapping[str, Sequence[str | Mapping[str, str]]]r   )Údependency_groupsr   c                 C  s2   t ƒ }t||ƒ| _i | _i | _i | _| d¡ d S )Nz$[dependency-groups] data was invalid)r   Ú_normalize_group_namesr0   Ú_parsed_groupsÚ_include_graph_ancestorsÚ_resolve_cacheÚfinalize)r#   r0   Úerrorsr   r   r   r"   r   s    þz DependencyGroupResolver.__init__r   z0tuple[Requirement | DependencyGroupInclude, ...])r   r   c                 C  sL   t |ƒ}tƒ  d|›d�¡�}|  ||¡W  d  ƒ S 1 s>0    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   r6   r   r   r   Úlookup…   s    
ÿzDependencyGroupResolver.lookupztuple[Requirement, ...]c                 C  sN   t |ƒ}tƒ  d|›d�¡�}|  |||¡W  d  ƒ S 1 s@0    Y  dS )z
        Resolve a dependency group to a list of requirements.

        :param group: the name of the group to resolve
        r7   r8   N)r9   r   r:   Ú_resolver<   r   r   r   Úresolve“   s    
ÿzDependencyGroupResolver.resolver   )r   r   r6   r   c                 C  sä   || j v r| j | S |  ||¡}g }|D ]˜}t|tƒrB| |¡ q(t|tƒr²t|jƒ}|| j 	|d¡v r~| 
t|||jƒ¡ qÀg | j 	|d¡¢|‘R | j|< | |  |||¡¡ q(td|› �ƒ‚q(|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: )r4   r;   Ú
isinstancer   Úappendr
   r9   r   r3   ÚgetÚerrorr	   Úextendr>   ÚNotImplementedErrorr6   Útuple)r#   r   r   r6   ÚparsedZresolved_groupÚitemr   r   r   r   r>       s<    




ÿÿÿþÿÿz DependencyGroupResolver._resolve)r   r6   r   c              	   C  sˆ  || j v r| j | S || jvr8| td|› d�ƒ¡ dS | j| }t|tƒrf| td|›d�ƒ¡ dS t|tƒsŠ| td|›d�ƒ¡ dS g }|D ]Ð}t|tƒrÚ| t	¡� | 
t|ƒ¡ W d   ƒ n1 sÎ0    Y  q’t|tƒ�rNt| ¡ ƒdk�r| td|›�ƒ¡ n>|d	 }t|tƒ�s<d
|›�}| t|ƒ¡ n| 
t|d�¡ q’| td|›�ƒ¡ q’|j�rpd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: rI   z6Dependency group include-group value is not a string: r*   )r2   r0   rC   ÚLookupErrorr@   r   Ú	TypeErrorr   Zcollectr   rA   r   r   rF   Úkeysr   r
   r6   )r#   r   r6   Z	raw_groupÚelementsrH   r   Úmsgr   r   r   r;   Ú   sZ    





ÿÿ
ÿ
.ÿÿÿÿÿz$DependencyGroupResolver._parse_groupN)	r   r   r   r   r"   r=   r?   r>   r;   r   r   r   r   r   d   s   :r   r/   r   ztuple[str, ...])r0   Úgroupsr   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   )r?   r   )Ú.0r   Úr©Úresolverr   r   Ú	<genexpr>+  ó    z,resolve_dependency_groups.<locals>.<genexpr>)r   rF   )r0   rO   r   rR   r   r     s    r   z[-_.]+)Únamer   c                 C  s   t  d| ¡ ¡ S )Nú-)Ú_NORMALIZE_PATTERNÚsubÚlower)rV   r   r   r   r9   6  s    r9   r   z,dict[str, Sequence[str | Mapping[str, str]]])r0   r6   r   c           	   
   C  s€   i }i }|   ¡ D ]*\}}t|ƒ}| |g ¡ |¡ |||< q|  ¡ D ]6\}}t|ƒdkrD| td|› dd |¡› d�ƒ¡ qD|S )Nr   z"Duplicate dependency group names: z (r    r,   )Úitemsr9   Ú
setdefaultrA   ÚlenrC   r   Újoin)	r0   r6   Úoriginal_namesZnormalized_groupsÚ
group_nameÚvalueZnormed_group_nameZnormed_nameÚnamesr   r   r   r1   :  s$    
ÿÿÿÿr1   )Ú
__future__r   ÚreÚcollections.abcr   r   r6   r   Úrequirementsr   r   r   r   Ú
ValueErrorr   r	   r   r
   r   r   ÚcompilerX   r9   r1   r   r   r   r   Ú<module>   s    
	 ;
