a
    Œ�éi�  ã                   @   sš   d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZmZ d dlmZ er|d dlmZ e e¡ZG d	d
„ d
eƒZdS )é    N)Úcanonicalize_name)Úparse)ÚPyPI)Úhas_tls)Únormalize_pathÚredact_auth_from_url)ÚMYPY_CHECK_RUNNING)ÚListc                   @   s<   e Zd ZdZddgZedd„ ƒZdd„ Zdd	„ Zd
d„ Z	dS )ÚSearchScopezF
    Encapsulates the locations that pip is configured to search.
    Ú
find_linksÚ
index_urlsc                 C   s€   g }|D ]0}|  d¡r.t|ƒ}tj |¡r.|}| |¡ qtƒ stt ||¡D ]&}t	 
|¡}|jdkrLt d¡  qtqL| ||d�S )zQ
        Create a SearchScope object after normalizing the `find_links`.
        ú~Úhttpszipip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.©r   r   )Ú
startswithr   ÚosÚpathÚexistsÚappendr   Ú	itertoolsÚchainÚurllib_parseÚurlparseÚschemeÚloggerÚwarning)Úclsr   r   Úbuilt_find_linksÚlinkÚnew_linkÚparsed© r!   úQ/home/Claro/venv/lib/python3.9/site-packages/pip/_internal/models/search_scope.pyÚcreate   s&    


ÿþzSearchScope.createc                 C   s   || _ || _d S ©Nr   )Úselfr   r   r!   r!   r"   Ú__init__F   s    zSearchScope.__init__c                 C   s¤   g }g }| j rr| j tjgkrr| j D ]8}t|ƒ}t |¡}|jsP|jsPt 	d|¡ | 
|¡ q"| 
d d |¡¡¡ | jrš| 
d d dd„ | jD ƒ¡¡¡ d |¡S )Nz:The index url "%s" seems invalid, please provide a scheme.zLooking in indexes: {}z, zLooking in links: {}c                 s   s   | ]}t |ƒV  qd S r$   )r   ©Ú.0Úurlr!   r!   r"   Ú	<genexpr>l   s   z6SearchScope.get_formatted_locations.<locals>.<genexpr>Ú
)r   r   Ú
simple_urlr   r   Úurlsplitr   Únetlocr   r   r   ÚformatÚjoinr   )r%   ÚlinesÚredacted_index_urlsr)   Úredacted_index_urlÚpurlr!   r!   r"   Úget_formatted_locationsO   s,    

þÿÿÿz#SearchScope.get_formatted_locationsc                    s    ‡fdd„‰ ‡ fdd„| j D ƒS )z²Returns the locations found via self.index_urls

        Checks the url_name on the main (first in the list) index and
        use this url_name to produce all locations
        c                    s,   t  | t tˆ ƒ¡¡}| d¡s(|d }|S )Nú/)Ú	posixpathr0   r   Úquoter   Úendswith)r)   Úloc)Úproject_namer!   r"   Úmkurl_pypi_urly   s    þ
z<SearchScope.get_index_urls_locations.<locals>.mkurl_pypi_urlc                    s   g | ]}ˆ |ƒ‘qS r!   r!   r'   )r<   r!   r"   Ú
<listcomp>‡   ó    z8SearchScope.get_index_urls_locations.<locals>.<listcomp>)r   )r%   r;   r!   )r<   r;   r"   Úget_index_urls_locationsq   s    z$SearchScope.get_index_urls_locationsN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Úclassmethodr#   r&   r5   r?   r!   r!   r!   r"   r
      s   
(	"r
   )r   Úloggingr   r7   Úpip._vendor.packaging.utilsr   Zpip._vendor.six.moves.urllibr   r   Úpip._internal.models.indexr   Úpip._internal.utils.compatr   Úpip._internal.utils.miscr   r   Úpip._internal.utils.typingr   Útypingr	   Ú	getLoggerr@   r   Úobjectr
   r!   r!   r!   r"   Ú<module>   s   
