o
    Ñ­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	 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)ÚRequirement)ÚCyclicDependencyGroupÚDependencyGroupIncludeÚDependencyGroupResolverÚDuplicateGroupNamesÚInvalidDependencyGroupObjectÚresolve_dependency_groupsÚreturnú	list[str]c                   C  s   t S ©N)Ú__all__© r   r   úX/var/www/html/CropPilot/venv/lib/python3.10/site-packages/packaging/dependency_groups.pyÚ__dir__   s   r   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      ó    r   c                      s"   e Zd ZdZd
‡ fdd	„Z‡  ZS )r   z5
    The dependency group includes form a cycle.
    Ú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__)r   r   r   r   r   r   r   r    )r   r   r   r   r#   Ú__classcell__r   r   r&   r   r   "   s    r   c                   @  r   )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   r   r   c                   @  s$   e Zd ZdZddd„Zddd	„Zd
S )r	   ©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#   H   s   
zDependencyGroupInclude.__init__c                 C  s   | j j› d| j›d�S )Nú(ú))r'   r   r   )r$   r   r   r   Ú__repr__P   s   zDependencyGroupInclude.__repr__N)r   r   r   r    )r   r   )r   r   r   Ú	__slots__r#   r,   r   r   r   r   r	   E   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
   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                 C  s2   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.   Úerrorsr   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   r5   r   r   r   Úlookups   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
        r7   r8   N)r9   r   r:   Ú_resolver<   r   r   r   Úresolve�   s   
ÿ$ýzDependencyGroupResolver.resolver   r5   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: )r3   r;   Ú
isinstancer   Úappendr	   r9   r   r2   ÚgetÚerrorr   Úextendr?   ÚNotImplementedErrorr5   Útuple)r$   r   r   r5   ÚparsedÚresolved_groupÚitemr   r   r   r   r?   Ž   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 ]>}t|tƒrX| t	|ƒ¡ qIt|t
ƒr}t| ¡ ƒdkrp| td|›�ƒ¡ qI|d	 }| t|d
�¡ qI| td|›�ƒ¡ qIt|ƒ| 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: rK   r)   )r1   r.   rD   ÚLookupErrorrA   r   Ú	TypeErrorr   rB   r   r   rG   Úkeysr   r	   )r$   r   r5   Ú	raw_groupÚelementsrJ   r   r   r   r   r;   È   sD   





ÿÿ
ÿ

ÿÿ
z$DependencyGroupResolver._parse_groupN)r.   r/   r   r    )r   r   r   r6   )r   r   r   r>   )r   r   r   r   r5   r   r   r>   )r   r   r5   r   r   r6   )	r   r   r   r   r#   r=   r@   r?   r;   r   r   r   r   r
   T   s    



:r
   r.   r/   Úgroupsr   útuple[str, ...]c                  s   t | ƒ‰ t‡ fd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  s(   � | ]}ˆ   |¡D ]}t|ƒV  q	qd S r   )r@   r   )Ú.0r   Úr©Úresolverr   r   Ú	<genexpr>
  s   €& z,resolve_dependency_groups.<locals>.<genexpr>)r
   rG   )r.   rQ   r   rU   r   r   ÿ   s   
r   z[-_.]+Únamec                 C  s   t  d| ¡ ¡ S )Nú-)Ú_NORMALIZE_PATTERNÚsubÚlower)rX   r   r   r   r9     s   r9   r5   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!   r+   )Úitemsr9   Ú
setdefaultrB   ÚlenrD   r   Újoin)	r.   r5   Úoriginal_namesÚnormalized_groupsÚ
group_nameÚvalueÚnormed_group_nameÚnormed_nameÚnamesr   r   r   r0     s&   
ÿÿÿÿ€r0   )r   r   )r.   r/   rQ   r   r   rR   )rX   r   r   r   )r.   r/   r5   r   r   r]   )Ú
__future__r   ÚreÚcollections.abcr   r   r5   r   Úrequirementsr   r   r   Ú
ValueErrorr   r   r   r	   r
   r   ÚcompilerZ   r9   r0   r   r   r   r   Ú<module>   s"    

	 
,

