a
    0f                     @   s   d dl Z 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 d dlmZmZ eeZedd	G d
d dZdS )    N)	dataclass)List)canonicalize_name)PyPI)has_tls)normalize_pathredact_auth_from_urlT)frozenc                   @   s|   e Zd ZU dZg dZee ed< ee ed< eed< e	ee ee ed dddZ
ed	d
dZeee dddZdS )SearchScopezF
    Encapsulates the locations that pip is configured to search.
    
find_links
index_urlsno_indexr   r   r   )r   r   r   returnc                 C   s   g }|D ]0}| dr.t|}tj|r.|}|| qt svt||D ](}t	j
|}|jdkrLtd  qvqL| |||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   )
startswithr   ospathexistsappendr   	itertoolschainurllibparseurlparseschemeloggerwarning)clsr   r   r   built_find_linkslinknew_linkparsed r$   Z/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pip/_internal/models/search_scope.pycreate   s(    

zSearchScope.create)r   c                 C   s   g }g }| j rt| j tjgkrt| j D ]:}t|}tj|}|jsR|jsRt	
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 )N)r   .0urlr$   r$   r%   	<genexpr>f       z6SearchScope.get_formatted_locations.<locals>.<genexpr>
)r   r   
simple_urlr   r   r   urlsplitr   netlocr   r   r   formatjoinr   )selflinesredacted_index_urlsr)   redacted_index_urlpurlr$   r$   r%   get_formatted_locationsH   s,    
z#SearchScope.get_formatted_locations)project_namer   c                    s(   t t d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
        )r)   r   c                    s.   t | tjt }|ds*|d }|S )N/)	posixpathr1   r   r   quoter   endswith)r)   loc)r8   r$   r%   mkurl_pypi_urlr   s    
z<SearchScope.get_index_urls_locations.<locals>.mkurl_pypi_urlc                    s   g | ]} |qS r$   r$   r'   )r>   r$   r%   
<listcomp>   r+   z8SearchScope.get_index_urls_locations.<locals>.<listcomp>)strr   )r2   r8   r$   )r>   r8   r%   get_index_urls_locationsk   s    z$SearchScope.get_index_urls_locationsN)__name__
__module____qualname____doc__	__slots__r   r@   __annotations__boolclassmethodr&   r7   rA   r$   r$   r$   r%   r
      s   
)#r
   )r   loggingr   r:   urllib.parser   dataclassesr   typingr   Zpip._vendor.packaging.utilsr   pip._internal.models.indexr   pip._internal.utils.compatr   pip._internal.utils.miscr   r   	getLoggerrB   r   r
   r$   r$   r$   r%   <module>   s   
