B
    ãUvgç‡  ã               @   s4  d Z ddlmZ ddlZddlZddlZ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mZ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 dd	lmZ ddlmZ  ddl!m"Z"m#Z#m$Z$m%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/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z<m=Z=m>Z>m?Z? ddl@mAZA ddlBmCZCmDZD ddgZEdddddd gZFe GeH¡ZId!d"„ ZJd6d#d$„ZKd7d%d&„ZLG d'd„ deMƒZNe	 Od(e	jP¡fd)d*„ZQd+d,„ ZRd-d.„ ZSe	 Od/e	jP¡ZTd0d1„ ZUG d2d3„ d3eMƒZVed4d5ƒZWdS )8z!Routines related to PyPI, indexesé    )Úabsolute_importN)Ú
namedtuple)Úhtml5libÚrequestsÚsix)Úunescape)Ú
specifiers)Úcanonicalize_name)Úparse)Ú	HTTPErrorÚSSLError)Úrequest)ÚHAS_TLSÚis_urlÚpath_to_urlÚurl_to_path)ÚBestVersionAlreadyInstalledÚDistributionNotFoundÚInvalidWheelFilenameÚUnsupportedWheel)ÚInstallationCandidate)ÚFormatControl)ÚPyPI)ÚLink)Úget_supported)Ú	ipaddress)Ú
deprecated)Ú
indent_log)ÚARCHIVE_EXTENSIONSÚSUPPORTED_EXTENSIONSÚnormalize_pathÚremove_auth_from_url)Úcheck_requires_python)ÚWheelÚ	wheel_extr   ÚPackageFinder)ÚhttpsÚ*r'   )r'   Ú	localhostr'   )r'   z127.0.0.0/8r'   )r'   z::1/128r'   )Úfiler'   N)Ússhr'   r'   c             C   sD   t  | ¡\}}}}}|dkr dS |j| dd�}| ¡  |j dd¡S )z;Get the Content-Type of the given url, using a HEAD request>   r&   ÚhttpÚ T)Úallow_redirectszContent-Type)Úurllib_parseÚurlsplitÚheadÚraise_for_statusÚheadersÚget)ÚurlÚsessionÚschemeÚnetlocÚpathÚqueryÚfragmentÚresp© r<   ú4/tmp/pip-install-r_9ig3yj/pip/pip/_internal/index.pyÚ_get_content_type>   s    r>   c             C   s   |d krt j}|d| |ƒ d S )Nz%Could not fetch URL %s: %s - skipping)ÚloggerÚdebug)ÚlinkÚreasonr4   Úmethr<   r<   r=   Ú_handle_get_page_failL   s    rD   c          
   C   sd  |d krt dƒ‚| j}| dd¡d }ddlm} x>|jD ]4}| ¡  |¡r:|t|ƒ dkr:t	 
d|| ¡ d S q:W �y| j}xFtD ]>}| |¡r‚t||d�}| ¡  d	¡r®P q‚t	 
d
| |¡ d S q‚W t	 
d|¡ t |¡\}}}	}
}}|dk�r0tj t |	¡¡�r0| d¡�s|d7 }t |d¡}t	 
d|¡ |j|d	ddœd�}| ¡  |j dd¡}| ¡  d	¡�s|t	 
d
| |¡ d S t|j|j|jƒ}W nÊ tk
�rÀ } zt| ||ƒ W d d }~X Y n  tk
�r } z&d}|t|ƒ7 }t| ||t	j d� W d d }~X Y n\ t!j"k
�r8 } zt| d| |ƒ W d d }~X Y n( t!j#k
�rZ   t| d|ƒ Y nX |S d S )Nz?_get_html_page() missing 1 required keyword argument: 'session'ú#é   r   )Ú
VcsSupportz+:zCannot look at %s URL %s)r5   z	text/htmlz,Skipping page %s because of Content-Type: %szGetting page %sr)   ú/z
index.htmlz# file: URL is directory, getting %sz	max-age=0)ÚAcceptzCache-Control)r2   zContent-TypeÚunknownz4There was a problem confirming the ssl certificate: )rC   zconnection error: %sz	timed out)$Ú	TypeErrorr4   ÚsplitÚpip._internal.vcsrG   ÚschemesÚlowerÚ
startswithÚlenr?   r@   Úfilenamer   Úendswithr>   r.   ÚurlparseÚosr8   ÚisdirÚurllib_requestÚurl2pathnameÚurljoinr3   r1   r2   ÚHTMLPageÚcontentr   rD   r   ÚstrÚinfor   ÚConnectionErrorÚTimeout)rA   r5   r4   rG   r6   rR   Úbad_extÚcontent_typer7   r8   Úparamsr9   r:   r;   ÚinstÚexcrB   r<   r<   r=   Ú_get_html_pageR   sl    


" re   c            
   @   sš   e Zd ZdZd#dd„Zdd„ Zdd	„ Zed$d
d„ƒZdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Ze d¡Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ ZdS )%r%   z This finds packages.

    This is meant to match easy_install's technique for looking for
    packages, by reading pages and looking for appropriate links.
    FNc             C   sþ   |dkrt dƒ‚g | _x:|D ]2}| d¡rBt|ƒ}tj |¡rB|}| j |¡ qW || _g | _	t
ƒ | _|pvtt
ƒ t
ƒ ƒ| _dd„ |rˆ|ng D ƒ| _|| _|| _|| _t|	||
|d�| _|| _tsúx8t | j| j¡D ]$}t |¡}|jdkrÒt d¡ P qÒW dS )	a¯  Create a PackageFinder.

        :param format_control: A FormatControl object or None. Used to control
            the selection of source packages / binary packages when consulting
            the index and links.
        :param platform: A string or None. If None, searches for packages
            that are supported by the current system. Otherwise, will find
            packages that can be built on the platform passed in. These
            packages will only be downloaded for distribution: they will
            not be built locally.
        :param versions: A list of strings or None. This is passed directly
            to pep425tags.py in the get_supported() method.
        :param abi: A string or None. This is passed directly
            to pep425tags.py in the get_supported() method.
        :param implementation: A string or None. This is passed directly
            to pep425tags.py in the get_supported() method.
        Nz>PackageFinder() missing 1 required keyword argument: 'session'ú~c             S   s   g | ]}d |d f‘qS )r'   r<   )Ú.0Úhostr<   r<   r=   ú
<listcomp>ì   s   z*PackageFinder.__init__.<locals>.<listcomp>)ÚversionsÚplatformÚabiÚimplr&   zipip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.)rK   Ú
find_linksrP   r    rU   r8   ÚexistsÚappendÚ
index_urlsÚdependency_linksÚsetÚlogged_linksr   Úformat_controlÚsecure_originsÚallow_all_prereleasesÚprocess_dependency_linksr5   r   Ú
valid_tagsÚprefer_binaryr   Ú	itertoolsÚchainr.   rT   r6   r?   Úwarning)Úselfrn   rq   rw   Útrusted_hostsrx   r5   ru   rk   rj   rl   Úimplementationrz   rA   Únew_linkÚparsedr<   r<   r=   Ú__init__¹   s@    	




zPackageFinder.__init__c             C   sb   g }| j r:| j tjgkr:| d d dd„ | j D ƒ¡¡¡ | jrX| d d | j¡¡¡ d |¡S )NzLooking in indexes: {}z, c             s   s   | ]}t |ƒV  qd S )N)r!   )rg   r4   r<   r<   r=   ú	<genexpr>  s    z8PackageFinder.get_formatted_locations.<locals>.<genexpr>zLooking in links: {}Ú
)rq   r   Ú
simple_urlrp   ÚformatÚjoinrn   )r~   Úlinesr<   r<   r=   Úget_formatted_locations  s    z%PackageFinder.get_formatted_locationsc             C   s&   | j r"tddddd� | j |¡ d S )NzXDependency Links processing has been deprecated and will be removed in a future release.zPEP 508 URL dependenciesz18.2i[  )ÚreplacementÚgone_inÚissue)rx   r   rr   Úextend)r~   Úlinksr<   r<   r=   Úadd_dependency_links  s    z"PackageFinder.add_dependency_linksc                sô   g ‰ g ‰‡ ‡fdd„}xÔ| D ]Ì}t j |¡}| d¡}|s>|rÈ|rH|}nt|ƒ}t j |¡r¤|r”t j |¡}x4t  |¡D ]}|t j ||¡ƒ qxW qÆ|rÆˆ 	|¡ qèt j 
|¡rº||ƒ qèt d|¡ qt|ƒrÜˆ 	|¡ qt d|¡ qW ˆ ˆfS )zt
        Sort locations into "files" (archives) and "urls", and return
        a pair of lists (files,urls)
        c                s8   t | ƒ}tj|dd�d dkr*ˆ |¡ n
ˆ  |¡ d S )NF)Ústrictr   z	text/html)r   Ú	mimetypesÚ
guess_typerp   )r8   r4   )ÚfilesÚurlsr<   r=   Ú	sort_path7  s    z0PackageFinder._sort_locations.<locals>.sort_pathzfile:z:Url '%s' is ignored: it is neither a file nor a directory.zQUrl '%s' is ignored. It is either a non-existing path or lacks a specific scheme.)rU   r8   ro   rP   r   rV   ÚrealpathÚlistdirrˆ   rp   Úisfiler?   r}   r   )Ú	locationsÚ
expand_dirr–   r4   Úis_local_pathÚis_file_urlr8   Úitemr<   )r”   r•   r=   Ú_sort_locations-  s8    



zPackageFinder._sort_locationsc       	      C   s¤   t | jƒ}tƒ }d}|jjr�t|jjƒ}| | j¡sBtd|j ƒ‚| j	rLd}| 
| j¡ }|jdk	r–t d|j¡}| ¡ }t|d ƒ|d f}n| }||j||fS )a§  
        Function used to generate link sort key for link tuples.
        The greater the return value, the more preferred it is.
        If not finding wheels, then sorted by version only.
        If finding wheels, then the sort order is by version, then:
          1. existing installs
          2. wheels ordered via Wheel.support_index_min(self.valid_tags)
          3. source archives
        If prefer_binary was set, then all wheels are sorted above sources.
        Note: it was considered to embed this logic into the Link
              comparison operators, but then different sdist links
              with the same version, would have to be considered equal
        r   zB%s is not a supported wheel for this platform. It can't be sorted.rF   Nz^(\d+)(.*)$)rQ   ry   ÚtupleÚlocationÚis_wheelr#   rR   Ú	supportedr   rz   Úsupport_index_minÚ	build_tagÚreÚmatchÚgroupsÚintÚversion)	r~   Ú	candidateÚsupport_numr¥   Úbinary_preferenceÚwheelÚprir§   Úbuild_tag_groupsr<   r<   r=   Ú_candidate_sort_keya  s$    


z!PackageFinder._candidate_sort_keyc       	   	   C   sl  t  t|ƒ¡}|j|j|jf}|d  dd¡d }�x t| j D �]}||d kr`|d dkr`q@yht	 
t|d tjƒs‚|d d krŠ|d n|d  d¡¡}t	 t|d tjƒr¶|d n|d  d¡¡}W nJ tk
�r   |d �r|d  ¡ |d  ¡ k�r|d dk�rw@Y nX ||k�r q@|d |d k�rP|d dk�rP|d d k	�rPq@dS W | d	|j|j¡ d
S )Nr   ú+rF   éÿÿÿÿr'   Úutf8é   TzõThe repository located at %s is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host %s'.F)r.   rT   r\   r6   ÚhostnameÚportÚrsplitÚSECURE_ORIGINSrv   r   Ú
ip_addressÚ
isinstancer   Ú	text_typeÚdecodeÚ
ip_networkÚ
ValueErrorrO   r}   )	r~   r?   r¡   r‚   ÚoriginÚprotocolÚsecure_originÚaddrÚnetworkr<   r<   r=   Ú_validate_secure_origin…  s>    

z%PackageFinder._validate_secure_originc                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 )NrH   )Ú	posixpathrˆ   r.   Úquoter	   rS   )r4   Úloc)Úproject_namer<   r=   Úmkurl_pypi_urlÓ  s    
z?PackageFinder._get_index_urls_locations.<locals>.mkurl_pypi_urlc                s   g | ]}ˆ |ƒ‘qS r<   r<   )rg   r4   )rÊ   r<   r=   ri   à  s    z;PackageFinder._get_index_urls_locations.<locals>.<listcomp>)rq   )r~   rÉ   r<   )rÊ   rÉ   r=   Ú_get_index_urls_locationsÌ  s    z'PackageFinder._get_index_urls_locationsc          
      sÈ  ˆ   |¡}ˆ  |¡\}}ˆ jˆ jdd�\}}ˆ  ˆ j¡\}}dd„ t |||¡D ƒ}	‡ fdd„t dd„ |D ƒdd„ |D ƒd	d„ |D ƒ¡D ƒ}
t d
t|
ƒ|¡ x|
D ]}t d|¡ q¦W t	|ƒ}ˆ j
 |¡}t|||ƒ}ˆ  dd„ ˆ jD ƒ|¡}g }xLˆ  |
|¡D ]<}t d|j¡ tƒ � | ˆ  | ¡ |¡¡ W dQ R X �qW ˆ  dd„ ˆ jD ƒ|¡}|�r~t dd dd„ |D ƒ¡¡ ˆ  |	|¡}|�r¸|jdd� t dd dd„ |D ƒ¡¡ || | | S )a  Find all available InstallationCandidate for project_name

        This checks index_urls, find_links and dependency_links.
        All versions found are returned as an InstallationCandidate list.

        See _link_package_versions for details on which files are accepted
        T)r›   c             s   s   | ]}t |ƒV  qd S )N)r   )rg   r4   r<   r<   r=   r„   ñ  s    z4PackageFinder.find_all_candidates.<locals>.<genexpr>c                s   g | ]}ˆ   t|¡r|‘qS r<   )rÅ   r?   )rg   rA   )r~   r<   r=   ri   ú  s    z5PackageFinder.find_all_candidates.<locals>.<listcomp>c             s   s   | ]}t |ƒV  qd S )N)r   )rg   r4   r<   r<   r=   r„   û  s    c             s   s   | ]}t |ƒV  qd S )N)r   )rg   r4   r<   r<   r=   r„   ü  s    c             s   s   | ]}t |ƒV  qd S )N)r   )rg   r4   r<   r<   r=   r„   ý  s    z,%d location(s) to search for versions of %s:z* %sc             s   s   | ]}t |d ƒV  qdS )z-fN)r   )rg   r4   r<   r<   r=   r„     s    zAnalyzing links from page %sNc             s   s   | ]}t |ƒV  qd S )N)r   )rg   r4   r<   r<   r=   r„     s    zdependency_links found: %sz, c             S   s   g | ]}|j j‘qS r<   )r¡   r4   )rg   rª   r<   r<   r=   ri      s    )ÚreversezLocal files found: %sc             S   s   g | ]}t |jjƒ‘qS r<   )r   r¡   r4   )rg   r«   r<   r<   r=   ri   *  s   )rË   rŸ   rn   rr   r{   r|   r?   r@   rQ   r	   ru   Úget_allowed_formatsÚSearchÚ_package_versionsÚ
_get_pagesr4   r   rŽ   Ú
iter_linksrˆ   Úsort)r~   rÉ   Úindex_locationsÚindex_file_locÚindex_url_locÚfl_file_locÚ
fl_url_locÚdep_file_locÚdep_url_locÚfile_locationsÚurl_locationsr¡   Úcanonical_nameÚformatsÚsearchÚfind_links_versionsÚpage_versionsÚpageÚdependency_versionsÚfile_versionsr<   )r~   r=   Úfind_all_candidatesâ  sX    


"
z!PackageFinder.find_all_candidatesc          
      sb  |   |j¡}t|jjdd„ |D ƒ| jr,| jndd�ƒ‰ ‡ fdd„|D ƒ}|r\t|| jd�}nd}|jdk	rxt	|jj
ƒ}nd}|dkr¾|dkr¾t d|d td	d
„ |D ƒt	d�¡¡ td| ƒ‚d}|rÜ|dksØ|j
|krÜd}|�s|dk	�r|rþt d|¡ nt d||j
¡ dS |�r>t d|d tˆ t	d�¡�p6d¡ t‚t d|j
d tˆ t	d�¡¡ |jS )zÙTry to find a Link matching req

        Expects req, an InstallRequirement and upgrade, a boolean
        Returns a Link if found,
        Raises DistributionNotFound or BestVersionAlreadyInstalled otherwise
        c             S   s   g | ]}t |jƒ‘qS r<   )r\   rª   )rg   Úcr<   r<   r=   ri   H  s    z2PackageFinder.find_requirement.<locals>.<listcomp>N)Úprereleasesc                s   g | ]}t |jƒˆ kr|‘qS r<   )r\   rª   )rg   rå   )Úcompatible_versionsr<   r=   ri   Q  s    )ÚkeyzNCould not find a version that satisfies the requirement %s (from versions: %s)z, c             S   s   h | ]}t |jƒ’qS r<   )r\   rª   )rg   rå   r<   r<   r=   ú	<setcomp>f  s    z1PackageFinder.find_requirement.<locals>.<setcomp>z%No matching distribution found for %sFTzLExisting installed version (%s) is most up-to-date and satisfies requirementzUExisting installed version (%s) satisfies requirement (most up-to-date version is %s)z=Installed version (%s) is most up-to-date (past versions: %s)Únonez)Using version %s (newest of versions: %s))rä   Únamers   Ú	specifierÚfilterrw   Úmaxr±   Úsatisfied_byÚparse_versionrª   r?   Úcriticalrˆ   Úsortedr   r@   r   r¡   )r~   ÚreqÚupgradeÚall_candidatesÚapplicable_candidatesÚbest_candidateÚinstalled_versionÚbest_installedr<   )rç   r=   Úfind_requirement5  sd    


zPackageFinder.find_requirementc             c   sF   t ƒ }x:|D ]2}||krq| |¡ |  |¡}|dkr8q|V  qW dS )zp
        Yields (page, page_url) from the given locations, skipping
        locations that have errors.
        N)rs   ÚaddÚ	_get_page)r~   rš   rÉ   Úseenr¡   rá   r<   r<   r=   rÐ   ˜  s    


zPackageFinder._get_pagesz-py([123]\.?[0-9]?)$c             C   sT   g g  }}t ƒ }x:|D ]2}||kr| |¡ |jr>| |¡ q| |¡ qW || S )z�
        Returns elements of links in order, non-egg links first, egg links
        second, while eliminating duplicates
        )rs   rû   Úegg_fragmentrp   )r~   r�   ÚeggsÚno_eggsrý   rA   r<   r<   r=   Ú_sort_links«  s    


zPackageFinder._sort_linksc             C   s:   g }x0|   |¡D ]"}|  ||¡}|d k	r| |¡ qW |S )N)r  Ú_link_package_versionsrp   )r~   r�   rÞ   ÚresultrA   Úvr<   r<   r=   rÏ   »  s    zPackageFinder._package_versionsc             C   s(   || j kr$t d||¡ | j  |¡ d S )NzSkipping link %s; %s)rt   r?   r@   rû   )r~   rA   rB   r<   r<   r=   Ú_log_skipped_linkÃ  s    
zPackageFinder._log_skipped_linkc       
      C   sJ  d}|j r|j }|j}�n| ¡ \}}|s:|  |d¡ dS |tkrV|  |d| ¡ dS d|jkr~|tkr~|  |d|j ¡ dS d|jkr |dkr |  |d¡ dS |tk�r&yt	|j
ƒ}W n  tk
rØ   |  |d	¡ dS X t|jƒ|jk�r|  |d
|j ¡ dS | | j¡�s |  |d¡ dS |j}d|jk�rR|tk�rR|  |d|j ¡ dS |�sft||j|ƒ}|dk�r†|  |d|j ¡ dS | j |¡}|�rÖ|d| ¡ … }| d¡}|tjdd… k�rÖ|  |d¡ dS yt|jƒ}	W n. tjk
�r   t d|j
|j¡ d}	Y nX |	�s.t d||j¡ dS t d||¡ t|j||ƒS )z'Return an InstallationCandidate or NoneNz
not a filezunsupported archive format: %sÚbinaryzNo binaries permitted for %sÚmacosx10z.zipzmacosx10 onezinvalid wheel filenamezwrong project name (not %s)z%it is not compatible with this PythonÚsourcezNo sources permitted for %szMissing project version for %srF   é   zPython version is incorrectz3Package %s has an invalid Requires-Python entry: %sTz_The package %s is incompatible with the pythonversion in use. Acceptable python versions are:%szFound link %s, version: %s)rþ   ÚextÚsplitextr  r   rÝ   r$   Úsuppliedr8   r#   rR   r   r	   rë   Ú	canonicalr£   ry   rª   Úegg_info_matchesÚ_py_version_rerÞ   ÚstartÚgroupÚsysr"   Úrequires_pythonr   ÚInvalidSpecifierr?   r@   r   )
r~   rA   rÞ   rª   Úegg_infor
  r®   r§   Ú
py_versionÚsupport_this_pythonr<   r<   r=   r  È  s€    





z$PackageFinder._link_package_versionsc             C   s   t || jd�S )N)r5   )re   r5   )r~   rA   r<   r<   r=   rü     s    zPackageFinder._get_page)
FNFNNNNNNF)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rƒ   rŠ   r�   ÚstaticmethodrŸ   r±   rÅ   rË   rä   rú   rÐ   r¦   Úcompiler  r  rÏ   r  r  rü   r<   r<   r<   r=   r%   ²   s,       
T3$GSc
Pz([a-z0-9_.]+)-([a-z0-9_.!+-]+)c             C   sŽ   |  | ¡}|st d|¡ dS |dkr@| d¡}| dd¡d S | d¡ ¡ }| dd¡}| ¡ d }| |¡r†| d¡t|ƒd… S dS dS )ax  Pull the version part out of a string.

    :param egg_info: The string to parse. E.g. foo-2.1
    :param search_name: The name of the package this belongs to. None to
        infer the name. Note that this cannot unambiguously parse strings
        like foo-2-2 which might be foo, 2-2 or foo-2, 2.
    :param link: The link the string came from, for logging on failure.
    z%Could not parse version from link: %sNr   ú-rF   r³   Ú_)	rÞ   r?   r@   r  rL   rO   ÚreplacerP   rQ   )r  Úsearch_namerA   Ú_egg_info_rer§   Ú
full_matchrë   Úlook_forr<   r<   r=   r    s    


r  c             C   s.   x(|   d¡D ]}| d¡}|dk	r|S qW |S )aö  Determine the HTML document's base URL.

    This looks for a ``<base>`` tag in the HTML document. If present, its href
    attribute denotes the base URL of anchor tags in the document. If there is
    no such tag (or if it does not have a valid href attribute), the HTML
    file's URL is used as the base URL.

    :param document: An HTML document representation. The current
        implementation expects the result of ``html5lib.parse()``.
    :param page_url: The URL of the HTML document.
    z.//baseÚhrefN)Úfindallr3   )ÚdocumentÚpage_urlÚbaser%  r<   r<   r=   Ú_determine_base_url9  s
    
r*  c             C   s2   | r.d| kr.t  | d ¡\}}d|kr.|d S dS )zBDetermine if we have any encoding information in our headers.
    zContent-TypeÚcharsetN)ÚcgiÚparse_header)r2   ra   rb   r<   r<   r=   Ú_get_encoding_from_headersL  s
    r.  z[^a-z0-9$&+,/:;=?@.#%_\\|-]c             C   s   t  dd„ | ¡S )z Makes sure a link is fully encoded.  That is, if a ' ' shows up in
    the link, it will be rewritten to %20 (while not over-quoting
    % or other characters).c             S   s   dt |  d¡ƒ S )Nz%%%2xr   )Úordr  )r§   r<   r<   r=   Ú<lambda>]  ó    z_clean_link.<locals>.<lambda>)Ú_CLEAN_LINK_REÚsub)r4   r<   r<   r=   Ú_clean_linkY  s    r4  c               @   s*   e Zd ZdZd	dd„Zdd„ Zdd„ ZdS )
rZ   z'Represents one page, along with its URLNc             C   s   || _ || _|| _d S )N)r[   r4   r2   )r~   r[   r4   r2   r<   r<   r=   rƒ   c  s    zHTMLPage.__init__c             C   s   | j S )N)r4   )r~   r<   r<   r=   Ú__str__h  s    zHTMLPage.__str__c             c   sŒ   t j| jt| jƒdd�}t|| jƒ}xb| d¡D ]T}| d¡r0| d¡}t	t
 ||¡ƒ}| d¡}|rnt|ƒnd}t|| j|d�V  q0W dS )zYields all links in the pageF)Útransport_encodingÚnamespaceHTMLElementsz.//ar%  zdata-requires-pythonN)r  )r   r
   r[   r.  r2   r*  r4   r&  r3   r4  r.   rY   r   r   )r~   r'  Úbase_urlÚanchorr%  r4   Ú	pyrequirer<   r<   r=   rÑ   k  s    


zHTMLPage.iter_links)N)r  r  r  r  rƒ   r5  rÑ   r<   r<   r<   r=   rZ   `  s   
rZ   rÎ   zsupplied canonical formats)N)N)Xr  Ú
__future__r   r,  r{   Úloggingr’   rU   rÆ   r¦   r  Úcollectionsr   Úpip._vendorr   r   r   Úpip._vendor.distlib.compatr   Zpip._vendor.packagingr   Úpip._vendor.packaging.utilsr	   Zpip._vendor.packaging.versionr
   rð   Zpip._vendor.requests.exceptionsr   r   Zpip._vendor.six.moves.urllibr.   r   rW   Úpip._internal.downloadr   r   r   r   Úpip._internal.exceptionsr   r   r   r   Úpip._internal.models.candidater   Ú#pip._internal.models.format_controlr   Úpip._internal.models.indexr   Úpip._internal.models.linkr   Zpip._internal.pep425tagsr   Úpip._internal.utils.compatr   Úpip._internal.utils.deprecationr   Úpip._internal.utils.loggingr   Úpip._internal.utils.miscr   r   r    r!   Úpip._internal.utils.packagingr"   Úpip._internal.wheelr#   r$   Ú__all__r¹   Ú	getLoggerr  r?   r>   rD   re   Úobjectr%   r  ÚIr  r*  r.  r2  r4  rZ   rÎ   r<   r<   r<   r=   Ú<module>   sn   


`    p

