U
    @vg:                     @   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                   @   s4   e Zd Zd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.
    c                 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.
find_links
index_urls)
startswithr   ospathexistsappendr   	itertoolschainurllib_parseurlparseschemeloggerwarning)clsr   r   built_find_linkslinknew_linkparsed r!   E/tmp/pip-unpacked-wheel-gw11q0wt/pip/_internal/models/search_scope.pycreate   s&    


zSearchScope.createc                 C   s   || _ || _d S Nr   )selfr   r   r!   r!   r"   __init__D   s    zSearchScope.__init__c                 C   sl   g }| j r:| j tjgkr:|dddd | j D  | jrb|dddd | jD  d|S )NzLooking in indexes: {}z, c                 s   s   | ]}t |V  qd S r$   r   .0urlr!   r!   r"   	<genexpr>R   s    z6SearchScope.get_formatted_locations.<locals>.<genexpr>zLooking in links: {}c                 s   s   | ]}t |V  qd S r$   r'   r(   r!   r!   r"   r+   W   s    
)r   r   
simple_urlr   formatjoinr   )r%   linesr!   r!   r"   get_formatted_locationsM   s    z#SearchScope.get_formatted_locationsc                    s    fdd  fdd| j D S )zReturns 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/)	posixpathr/   r   quoter   endswith)r*   loc)project_namer!   r"   mkurl_pypi_urld   s    
z<SearchScope.get_index_urls_locations.<locals>.mkurl_pypi_urlc                    s   g | ]} |qS r!   r!   r(   )r8   r!   r"   
<listcomp>r   s     z8SearchScope.get_index_urls_locations.<locals>.<listcomp>)r   )r%   r7   r!   )r8   r7   r"   get_index_urls_locations\   s    z$SearchScope.get_index_urls_locationsN)	__name__
__module____qualname____doc__classmethodr#   r&   r1   r:   r!   r!   r!   r"   r
      s   
(	r
   )r   loggingr   r3   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   
