a
    b3j'                     @  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
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)Requirement)CyclicDependencyGroupDependencyGroupIncludeDependencyGroupResolverDuplicateGroupNamesInvalidDependencyGroupObjectresolve_dependency_groupsz	list[str]returnc                   C  s   t S N)__all__ r   r   x/www/wwwroot/dpstar/app/297b3aabda72fedb274352021c2dd8b5_venv/lib/python3.9/site-packages/packaging/dependency_groups.py__dir__   s    r   c                   @  s   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   c                      s,   e Zd ZdZddddd fddZ  ZS )r   z5
    The dependency group includes form a cycle.
    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__)r   r   r   r   r!   __classcell__r   r   r$   r   r   "   s   r   c                   @  s   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   c                   @  s.   e Zd ZdZdddddZd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__r   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   	__slots__r!   r*   r   r   r   r   r	   E   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
   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]``.
    /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_namesr-   _parsed_groups_include_graph_ancestors_resolve_cachefinalize)r"   r-   errorsr   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   r3   r   r   r   lookups   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
        r4   r5   N)r6   r   r7   _resolver9   r   r   r   resolve   s    
zDependencyGroupResolver.resolver   )r   r   r3   r   c                 C  s   || j v r| j | S | ||}g }|D ]}t|trB|| q(t|trt|j}|| j	|dv r~|
t|||j qg | j	|d|R | j|< || ||| q(td| q(|jrd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: )r1   r8   
isinstancer   appendr	   r6   r   r0   geterrorr   extendr;   NotImplementedErrorr3   tuple)r"   r   r   r3   parsedZresolved_groupitemr   r   r   r   r;      s<    




z DependencyGroupResolver._resolve)r   r3   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	| qt|t
rt| dkr|td| n|d	 }|t|d
 q|td| qt|| 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: rF   r'   )r/   r-   r@   LookupErrorr=   r   	TypeErrorr   r>   r   r   rC   keysr   r	   )r"   r   r3   Z	raw_groupelementsrE   r   r   r   r   r8      sD    








z$DependencyGroupResolver._parse_groupN)	r   r   r   r   r!   r:   r<   r;   r8   r   r   r   r   r
   T   s   :r
   r,   r   ztuple[str, ...])r-   groupsr   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>
      z,resolve_dependency_groups.<locals>.<genexpr>)r
   rC   )r-   rK   r   rN   r   r      s    
r   z[-_.]+)namer   c                 C  s   t d|  S )N-)_NORMALIZE_PATTERNsublower)rR   r   r   r   r6     s    r6   r   z,dict[str, Sequence[str | Mapping[str, str]]])r-   r3   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)   )itemsr6   
setdefaultr>   lenr@   r   join)	r-   r3   original_namesZnormalized_groupsZ
group_namevalueZnormed_group_nameZnormed_namenamesr   r   r   r.     s$    
r.   )
__future__r   recollections.abcr   r   r3   r   requirementsr   r   r   
ValueErrorr   r   r   r	   r
   r   compilerT   r6   r.   r   r   r   r   <module>   s    
	 ,
