a
    <Bìj  ã                   @  sd  d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZmZmZmZmZ edƒZedƒZedƒZee	e eg e	e f f ZerÌdd	lmZ G d
d„ deeeef ƒZG dd„ deeeeef ƒZnedddgƒZedg d¢ƒZG dd„ dee ƒZG dd„ deee
e f eeeef ƒZG dd„ de	e ƒZG dd„ de	e ƒZdddœdd„Ze	ZdS )é    )ÚannotationsN)Ú
namedtuple)
ÚTYPE_CHECKINGÚCallableÚGenericÚIterableÚIteratorÚMappingÚ
NamedTupleÚSequenceÚTypeVarÚUnionÚKTÚRTÚCTé   )Ú	Criterionc                   @  s   e Zd ZU ded< ded< dS )ÚRequirementInformationr   Úrequirementz	CT | NoneÚparentN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__© r   r   ú]/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/structs.pyr      s   
r   c                   @  s*   e Zd ZU dZded< ded< ded< dS )	ÚStatezResolution state in a round.zdict[KT, CT]Úmappingzdict[KT, Criterion[RT, CT]]Úcriteriaz$list[RequirementInformation[RT, CT]]Úbacktrack_causesN)r   r   r   Ú__doc__r   r   r   r   r   r      s   
r   r   r   )r   r   r   c                   @  sÊ   e Zd ZdZddœdd„Zddœdd„Zd	dœd
d„Zdddœdd„Zddœdd„Zdddœdd„Z	dddœdd„Z
ddddœdd„Zddddœdd„Zddœdd„Zdddœd d!„Zdddœd"d#„Zd$S )%ÚDirectedGraphz&A graph structure with directed edges.ÚNone©Úreturnc                 C  s   t ƒ | _i | _i | _d S ©N)ÚsetÚ	_verticesÚ	_forwardsÚ
_backwards©Úselfr   r   r   Ú__init__0   s    zDirectedGraph.__init__úIterator[KT]c                 C  s
   t | jƒS r%   )Úiterr'   r*   r   r   r   Ú__iter__5   s    zDirectedGraph.__iter__Úintc                 C  s
   t | jƒS r%   )Úlenr'   r*   r   r   r   Ú__len__8   s    zDirectedGraph.__len__r   Úbool©Úkeyr$   c                 C  s
   || j v S r%   )r'   ©r+   r5   r   r   r   Ú__contains__;   s    zDirectedGraph.__contains__zDirectedGraph[KT]c                 C  sF   t | ƒƒ }t| jƒ|_dd„ | j ¡ D ƒ|_dd„ | j ¡ D ƒ|_|S )z$Return a shallow copy of this graph.c                 S  s   i | ]\}}|t |ƒ“qS r   ©r&   ©Ú.0ÚkÚvr   r   r   Ú
<dictcomp>B   ó    z&DirectedGraph.copy.<locals>.<dictcomp>c                 S  s   i | ]\}}|t |ƒ“qS r   r8   r9   r   r   r   r=   C   r>   )Útyper&   r'   r(   Úitemsr)   )r+   Úotherr   r   r   Úcopy>   s
    
zDirectedGraph.copyc                 C  s:   || j v rtdƒ‚| j  |¡ tƒ | j|< tƒ | j|< dS )zAdd a new vertex to the graph.zvertex existsN)r'   Ú
ValueErrorÚaddr&   r(   r)   r6   r   r   r   rD   F   s
    
zDirectedGraph.addc                 C  sT   | j  |¡ | j |¡D ]}| j|  |¡ q| j |¡D ]}| j|  |¡ q:dS )zCRemove a vertex from the graph, disconnecting all edges from/to it.N)r'   Úremover(   Úpopr)   )r+   r5   ÚfÚtr   r   r   rE   N   s
    zDirectedGraph.remove)rG   rH   r$   c                 C  s   || j | v o|| j| v S r%   )r)   r(   ©r+   rG   rH   r   r   r   Ú	connectedV   s    zDirectedGraph.connectedc                 C  s6   || j vrt|ƒ‚| j|  |¡ | j|  |¡ dS )zgConnect two existing vertices.

        Nothing happens if the vertices are already connected.
        N)r'   ÚKeyErrorr(   rD   r)   rI   r   r   r   ÚconnectY   s    
zDirectedGraph.connectzIterator[tuple[KT, KT]]c                 c  s,   | j  ¡ D ]\}}|D ]}||fV  qq
d S r%   )r(   r@   )r+   rG   ÚchildrenrH   r   r   r   Ú
iter_edgesc   s    zDirectedGraph.iter_edgesc                 C  s   t | j| ƒS r%   )r.   r(   r6   r   r   r   Úiter_childrenh   s    zDirectedGraph.iter_childrenc                 C  s   t | j| ƒS r%   )r.   r)   r6   r   r   r   Úiter_parentsk   s    zDirectedGraph.iter_parentsN)r   r   r   r    r,   r/   r2   r7   rB   rD   rE   rJ   rL   rN   rO   rP   r   r   r   r   r!   -   s   
r!   c                   @  sz   e Zd Zddddddœdd„Zd	d
œdd„Zdd
œdd„Zdddœdd„Zdddœdd„Zdd
œdd„Zdd
œdd„Z	dS ) ÚIteratorMappingNzMapping[KT, RT]zCallable[[RT], Iterable[CT]]z Mapping[KT, Iterable[CT]] | Noner"   )r   ÚaccessorÚappendsr$   c                 C  s   || _ || _|pi | _d S r%   )Ú_mappingÚ	_accessorÚ_appends)r+   r   rR   rS   r   r   r   r,   p   s    zIteratorMapping.__init__Ústrr#   c                 C  s   d  | j| j| j¡S )Nz!IteratorMapping({!r}, {!r}, {!r}))ÚformatrT   rU   rV   r*   r   r   r   Ú__repr__z   s
    ýzIteratorMapping.__repr__r3   c                 C  s   t | jp| jƒS r%   )r3   rT   rV   r*   r   r   r   Ú__bool__�   s    zIteratorMapping.__bool__Úobjectr4   c                 C  s   || j v p|| jv S r%   )rT   rV   r6   r   r   r   r7   „   s    zIteratorMapping.__contains__r   zIterator[CT])r;   r$   c                 C  sL   z| j | }W n  ty.   t| j| ƒ Y S 0 t |  |¡| j |d¡¡S )Nr   )rT   rK   r.   rV   Ú	itertoolsÚchainrU   Úget)r+   r;   r<   r   r   r   Ú__getitem__‡   s
    zIteratorMapping.__getitem__r-   c                   s"   ‡ fdd„ˆ j D ƒ}t ˆ j|¡S )Nc                 3  s   | ]}|ˆ j vr|V  qd S r%   ©rT   ©r:   r;   r*   r   r   Ú	<genexpr>�   r>   z+IteratorMapping.__iter__.<locals>.<genexpr>)rV   r\   r]   rT   ©r+   Zmorer   r*   r   r/   Ž   s    zIteratorMapping.__iter__r0   c                   s&   t ‡ fdd„ˆ jD ƒƒ}tˆ jƒ| S )Nc                 3  s   | ]}|ˆ j vrd V  qdS )r   Nr`   ra   r*   r   r   rb   “   r>   z*IteratorMapping.__len__.<locals>.<genexpr>)ÚsumrV   r1   rT   rc   r   r*   r   r2   ’   s    zIteratorMapping.__len__)N)
r   r   r   r,   rY   rZ   r7   r_   r/   r2   r   r   r   r   rQ   o   s    ü
rQ   c                   @  sJ   e Zd ZdZdddœdd„Zddœd	d
„Zddœdd„Zddœdd„ZdS )Ú_FactoryIterableViewa:  Wrap an iterator factory returned by `find_matches()`.

    Calling `iter()` on this class would invoke the underlying iterator
    factory, making it a "collection with ordering" that can be iterated
    through multiple times, but lacks random access methods presented in
    built-in Python sequence types.
    zCallable[[], Iterable[RT]]r"   )Úfactoryr$   c                 C  s   || _ d | _d S r%   )Ú_factoryÚ	_iterable)r+   rf   r   r   r   r,       s    z_FactoryIterableView.__init__rW   r#   c                 C  s   t | ƒj› dt| ƒ› d�S ©Nú(ú))r?   r   Úlistr*   r   r   r   rY   ¤   s    z_FactoryIterableView.__repr__r3   c                 C  s*   zt t| ƒƒ W n ty$   Y dS 0 dS )NFT)Únextr.   ÚStopIterationr*   r   r   r   rZ   §   s
    z_FactoryIterableView.__bool__úIterator[RT]c                 C  s,   | j d u r|  ¡ n| j }t |¡\| _ }|S r%   )rh   rg   r\   Útee)r+   ÚiterableÚcurrentr   r   r   r/   ®   s    z_FactoryIterableView.__iter__N©r   r   r   r    r,   rY   rZ   r/   r   r   r   r   re   —   s
   re   c                   @  sH   e Zd ZdZddœdd„Zddœdd	„Zd
dœdd„Zddœdd„ZdS )Ú_SequenceIterableViewz²Wrap an iterable returned by find_matches().

    This is essentially just a proxy to the underlying sequence that provides
    the same interface as `_FactoryIterableView`.
    zSequence[RT])Úsequencec                 C  s
   || _ d S r%   )Ú	_sequence)r+   ru   r   r   r   r,   »   s    z_SequenceIterableView.__init__rW   r#   c                 C  s   t | ƒj› d| j› d�S ri   )r?   r   rv   r*   r   r   r   rY   ¾   s    z_SequenceIterableView.__repr__r3   c                 C  s
   t | jƒS r%   )r3   rv   r*   r   r   r   rZ   Á   s    z_SequenceIterableView.__bool__ro   c                 C  s
   t | jƒS r%   )r.   rv   r*   r   r   r   r/   Ä   s    z_SequenceIterableView.__iter__Nrs   r   r   r   r   rt   ´   s
   rt   zMatches[CT]zIterable[CT])Úmatchesr$   c                 C  s*   t | ƒrt| ƒS t| tƒs"t| ƒ} t| ƒS )zCBuild an iterable view from the value returned by `find_matches()`.)Úcallablere   Ú
isinstancer   rl   rt   )rw   r   r   r   Úbuild_iter_viewÈ   s
    
rz   )Ú
__future__r   r\   Úcollectionsr   Útypingr   r   r   r   r   r	   r
   r   r   r   r   r   r   ZMatchesZresolvers.criterionr   r   r   r!   rQ   re   rt   rz   ZIterableViewr   r   r   r   Ú<module>   s*   0ÿB((	