
0c@_                 @   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 j e  Z Gd	 d
   d
 e  Z d S)    N)canonicalize_name)parse)PyPI)has_tls)normalize_pathredact_auth_from_url)MYPY_CHECK_RUNNING)Listc               @   sX   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  } xN | D]F } | j  d  rF t |  } t j j |  rF | } | j |  q Wt   s xF t j | |  D]2 } t	 j
 |  } | j d k rs t j d  Pqs W|  d | 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   Zbuilt_find_linkslinknew_linkparsed r   @/tmp/pip-build-jynh7p1z/pip/pip/_internal/models/search_scope.pycreate   s"    	zSearchScope.createc             C   s   | |  _  | |  _ d  S)N)r   r   )selfr   r   r   r   r    __init__F   s    	zSearchScope.__init__c             C   s   g  } g  } |  j  r |  j  t j g k r x] |  j  D]R } t |  } t j |  } | j ry | j ry t j	 d |  | j
 |  q4 W| j
 d j d j |    |  j r | j
 d j d j d d   |  j D    d j |  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)N)r   ).0urlr   r   r    	<genexpr>m   s    z6SearchScope.get_formatted_locations.<locals>.<genexpr>
)r   r   
simple_urlr   r   urlsplitr   netlocr   r   r   formatjoinr   )r"   linesZredacted_index_urlsr%   Zredacted_index_urlZpurlr   r   r    get_formatted_locationsO   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  j |  t j t      } | j d  s: | d } | S)N/)	posixpathr,   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 Sr   r   )r$   r%   )r5   r   r    
<listcomp>   s   	 z8SearchScope.get_index_urls_locations.<locals>.<listcomp>)r   )r"   r4   r   )r5   r4   r    get_index_urls_locationsq   s    z$SearchScope.get_index_urls_locationsN)
__name__
__module____qualname____doc__	__slots__classmethodr!   r#   r.   r7   r   r   r   r    r
      s   )	"r
   )r   loggingr   r0   pip._vendor.packaging.utilsr   Zpip._vendor.six.moves.urllibr   r   Zpip._internal.models.indexr   Zpip._internal.utils.compatr   Zpip._internal.utils.miscr   r   Zpip._internal.utils.typingr   Ztypingr	   	getLoggerr8   r   objectr
   r   r   r   r    <module>   s   