U
    cUh                     @   s   d Z ddl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 ddlmZ ddlmZ ddlmZ eeZeeeg e
e f f Zeree ZneZe	e e	e d	d
dZee	e e	e dddZee	e e	e dddZG dd deZdS )a  Utilities to lazily create and visit candidates found.

Creating and visiting a candidate is a *very* costly operation. It involves
fetching, extracting, potentially building modules from source, and verifying
distribution metadata. It is therefore crucial for performance to keep
everything here lazy all the way down, so we only touch candidates that we
absolutely need, and not "download the world" when we only need one version of
something.
    N)Sequence)TYPE_CHECKINGAnyCallableIteratorOptionalSetTuple)_BaseVersion)MetadataInvalid   )	Candidate)infosreturnc                 c   s   t  }| D ]x\}}||krq
z
| }W n@ tk
rf } z"td||jj| || W 5 d}~X Y q
X |dkrrq
|V  || q
dS )zIterator for ``FoundCandidates``.

    This iterator is used when the package is not already installed. Candidates
    from index come later in their normal ordering.
    zpIgnoring version %s of %s since it has invalid metadata:
%s
Please use pip<24.1 if you need to use this version.N)setr   loggerwarningireqnameadd)r   versions_foundversionfunc	candidatee r   t/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py_iter_built*   s$    

r   )	installedr   r   c                 c   sJ   | V  | j h}|D ]2\}}||kr$q| }|dkr4q|V  || qdS )aK  Iterator for ``FoundCandidates``.

    This iterator is used when the resolver prefers the already-installed
    candidate and NOT to upgrade. The installed candidate is therefore
    always yielded first, and candidates from index come later in their
    normal ordering, except skipped when the version is already installed.
    N)r   r   r   r   r   r   r   r   r   r   r   _iter_built_with_prependedI   s    
r    c                 c   sn   t  }|D ]N\}}||krq
| j|kr8| V  || j | }|dkrHq
|V  || q
| j|krj| V  dS )a  Iterator for ``FoundCandidates``.

    This iterator is used when the resolver prefers to upgrade an
    already-installed package. Candidates from index are returned in their
    normal ordering, except replaced when the version is already installed.

    The implementation iterates through and yields other candidates, inserting
    the installed candidate exactly once before we start yielding older or
    equivalent candidates, or after all other candidates if they are all newer.
    N)r   r   r   r   r   r   r   _iter_built_with_inserted_   s    

r!   c                   @   s   e Zd ZdZeg ee f ee e	e
e dddZeedddZee dd	d
ZedddZejdde	dddZdS )FoundCandidatesac  A lazy sequence to provide candidates to the resolver.

    The intended usage is to return this from `find_matches()` so the resolver
    can iterate through the sequence multiple times, but only access the index
    page when remote packages are actually needed. This improve performances
    when suitable candidates are already installed on disk.
    )	get_infosr   prefers_installedincompatible_idsc                 C   s   || _ || _|| _|| _d S N)
_get_infos
_installed_prefers_installed_incompatible_ids)selfr#   r   r$   r%   r   r   r   __init__   s    zFoundCandidates.__init__)indexr   c                 C   s   t dd S Nzdon't do thisNotImplementedError)r+   r-   r   r   r   __getitem__   s    zFoundCandidates.__getitem__)r   c                    sJ      } jst|}n  jr,t j|}nt j|} fdd|D S )Nc                 3   s    | ]}t | jkr|V  qd S r&   )idr*   ).0cr+   r   r   	<genexpr>   s      z+FoundCandidates.__iter__.<locals>.<genexpr>)r'   r(   r   r)   r    r!   )r+   r   iteratorr   r5   r   __iter__   s    
zFoundCandidates.__iter__c                 C   s   t dd S r.   r/   r5   r   r   r   __len__   s    zFoundCandidates.__len__r   )maxsizec                 C   s   | j r| jrdS t| S )NT)r)   r(   anyr5   r   r   r   __bool__   s    zFoundCandidates.__bool__N)__name__
__module____qualname____doc__r   r   IndexCandidateInfor   r   boolr   intr,   r   r1   r8   r9   	functools	lru_cacher<   r   r   r   r   r"      s   


r"   )r@   rD   loggingcollections.abcr   typingr   r   r   r   r   r   r	   pip._vendor.packaging.versionr
   pip._internal.exceptionsr   baser   	getLoggerr=   r   rA   ZSequenceCandidater   r    r!   r"   r   r   r   r   <module>   s,   
$

    