3
g              	   @   s0  d dl Z d dlZd dlZd dlZd dlmZmZmZ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 jeZee
 Zee Zeegee
 f Zeegef ZG dd dZeed	d
dZG dd deZG dd deZG dd deZG dd deZ eeeeeeee ee f dddZ!dS )    N)CallableIterableOptionalTuple)InstallationCandidate)Link)path_to_urlurl_to_path)is_urlc               @   s>   e Zd Zeee dddZedddZe	dddZ
dS )	
LinkSource)returnc             C   s
   t  dS )z,Returns the underlying link, if there's one.N)NotImplementedError)self r   Y/var/www/tester-filtro-web/env/lib/python3.6/site-packages/pip/_internal/index/sources.pylink   s    zLinkSource.linkc             C   s
   t  dS )z9Candidates found by parsing an archive listing HTML file.N)r   )r   r   r   r   page_candidates   s    zLinkSource.page_candidatesc             C   s
   t  dS )z,Links found by specifying archives directly.N)r   )r   r   r   r   
file_links   s    zLinkSource.file_linksN)__name__
__module____qualname__propertyr   r   r   FoundCandidatesr   
FoundLinksr   r   r   r   r   r      s   r   )file_urlr   c             C   s   t j| ddd dkS )NF)strictr   z	text/html)	mimetypes
guess_type)r   r   r   r   _is_html_file#   s    r   c               @   sT   e Zd ZdZeeddddZeee	 dddZ
edd	d
ZedddZdS )_FlatDirectorySourcezLink source specified by ``--find-links=<path-to-dir>``.

    This looks the content of the directory, and returns:

    * ``page_candidates``: Links listed on each HTML file in the directory.
    * ``file_candidates``: Archives in the directory.
    N)candidates_from_pagepathr   c             C   s   || _ tjtjj|| _d S )N)_candidates_from_pagepathlibPathosr!   realpath_path)r   r    r!   r   r   r   __init__0   s    z_FlatDirectorySource.__init__)r   c             C   s   d S )Nr   )r   r   r   r   r   8   s    z_FlatDirectorySource.linkc             c   sB   x<| j j D ].}tt|}t|s&q| jt|E d H  qW d S )N)r'   iterdirr   strr   r"   r   )r   r!   urlr   r   r   r   <   s
    z$_FlatDirectorySource.page_candidatesc             c   s8   x2| j j D ]$}tt|}t|r&qt|V  qW d S )N)r'   r)   r   r*   r   r   )r   r!   r+   r   r   r   r   C   s
    z_FlatDirectorySource.file_links)r   r   r   __doc__CandidatesFromPager*   r(   r   r   r   r   r   r   r   r   r   r   r   r   r   '   s   r   c               @   sT   e Zd ZdZeeddddZeee dddZ	e
dd	d
ZedddZdS )_LocalFileSourceaC  ``--find-links=<path-or-url>`` or ``--[extra-]index-url=<path-or-url>``.

    If a URL is supplied, it must be a ``file:`` URL. If a path is supplied to
    the option, it is converted to a URL first. This returns:

    * ``page_candidates``: Links listed on an HTML file.
    * ``file_candidates``: The non-HTML file.
    N)r    r   r   c             C   s   || _ || _d S )N)r"   _link)r   r    r   r   r   r   r(   U   s    z_LocalFileSource.__init__)r   c             C   s   | j S )N)r/   )r   r   r   r   r   ]   s    z_LocalFileSource.linkc             c   s&   t | jjsd S | j| jE d H  d S )N)r   r/   r+   r"   )r   r   r   r   r   a   s    z _LocalFileSource.page_candidatesc             c   s   t | jjrd S | jV  d S )N)r   r/   r+   )r   r   r   r   r   f   s    z_LocalFileSource.file_links)r   r   r   r,   r-   r   r(   r   r   r   r   r   r   r   r   r   r   r   r.   K   s   r.   c               @   sV   e Zd ZdZeeeddddZee	e dddZ
edd	d
ZedddZdS )_RemoteFileSourcez``--find-links=<url>`` or ``--[extra-]index-url=<url>``.

    This returns:

    * ``page_candidates``: Links listed on an HTML file.
    * ``file_candidates``: The non-HTML file.
    N)r    page_validatorr   r   c             C   s   || _ || _|| _d S )N)r"   _page_validatorr/   )r   r    r1   r   r   r   r   r(   u   s    z_RemoteFileSource.__init__)r   c             C   s   | j S )N)r/   )r   r   r   r   r      s    z_RemoteFileSource.linkc             c   s&   | j | jsd S | j| jE d H  d S )N)r2   r/   r"   )r   r   r   r   r      s    z!_RemoteFileSource.page_candidatesc             c   s   | j V  d S )N)r/   )r   r   r   r   r      s    z_RemoteFileSource.file_links)r   r   r   r,   r-   PageValidatorr   r(   r   r   r   r   r   r   r   r   r   r   r   r0   l   s   r0   c               @   sT   e Zd ZdZeeddddZeee dddZ	e
dd	d
ZedddZdS )_IndexDirectorySourcez``--[extra-]index-url=<path-to-directory>``.

    This is treated like a remote URL; ``candidates_from_page`` contains logic
    for this by appending ``index.html`` to the link.
    N)r    r   r   c             C   s   || _ || _d S )N)r"   r/   )r   r    r   r   r   r   r(      s    z_IndexDirectorySource.__init__)r   c             C   s   | j S )N)r/   )r   r   r   r   r      s    z_IndexDirectorySource.linkc             c   s   | j | jE d H  d S )N)r"   r/   )r   r   r   r   r      s    z%_IndexDirectorySource.page_candidatesc             C   s   f S )Nr   )r   r   r   r   r      s    z _IndexDirectorySource.file_links)r   r   r   r,   r-   r   r(   r   r   r   r   r   r   r   r   r   r   r   r4      s   r4   )locationr    r1   
expand_dircache_link_parsingr   c      	      C   s   d }d }t jj| r"t| }| }n$| jdr:| }t| }nt| rF| }|d krbd}tj||  dS |d krt	||t
||dd}||fS t jj|r|rt||d}nt|t
||dd}||fS t jj|rt|t
||dd}||fS tjd|  |d fS )	Nzfile:zVLocation '%s' is ignored: it is either a non-existing path or lacks a specific scheme.)r7   )r    r1   r   )r    r!   )r    r   z?Location '%s' is ignored: it is neither a file nor a directory.)NN)r%   r!   existsr   
startswithr	   r
   loggerwarningr0   r   isdirr   r4   isfiler.   )	r5   r    r1   r6   r7   r!   r+   msgsourcer   r   r   build_source   sL    	


r@   )"loggingr   r%   r#   typingr   r   r   r   Zpip._internal.models.candidater   pip._internal.models.linkr   pip._internal.utils.urlsr   r	   pip._internal.vcsr
   	getLoggerr   r:   r   r   r-   boolr3   r   r*   r   r   r.   r0   r4   r@   r   r   r   r   <module>   s2   
$! 