ó
j·Ã^c           @   sû   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	 m
 Z
 m Z d  d l m Z d  d l m Z d  d l m Z m Z e rá d  d l m Z m Z m Z m Z d  d	 l m Z d  d
 l m Z n  d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   parse(   t   WHEEL_EXTENSION(   t   redact_auth_from_urlt   split_auth_from_netloct   splitext(   t   KeyBasedCompareMixin(   t   MYPY_CHECK_RUNNING(   t   path_to_urlt   url_to_path(   t   Optionalt   Textt   Tuplet   Union(   t   HTMLPage(   t   Hashest   Linkc           B   s‹  e  Z d  Z d d d e d „ Z d „  Z d „  Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d	 „  ƒ Z d
 „  Z e d „  ƒ Z e d „  ƒ Z e j d ƒ Z e d „  ƒ Z e j d ƒ Z e d „  ƒ Z e j d ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z  e d „  ƒ Z! d „  Z" RS(   s?   Represents a parsed link from a Package Index's simple URL
    c         C   sŒ   | j  d ƒ r t | ƒ } n  t j | ƒ |  _ | |  _ | |  _ | rN | n d |  _ | |  _	 t
 t |  ƒ j d | d t ƒ | |  _ d S(   s½  
        :param url: url of the resource pointed to (href of the link)
        :param comes_from: instance of HTMLPage where the link was found,
            or string.
        :param requires_python: String containing the `Requires-Python`
            metadata field, specified in PEP 345. This may be specified by
            a data-requires-python attribute in the HTML link tag, as
            described in PEP 503.
        :param yanked_reason: the reason the file has been yanked, if the
            file has been yanked, or None if the file hasn't been yanked.
            This is the value of the "data-yanked" attribute, if present, in
            a simple repository HTML link. If the file has been yanked but
            no reason was provided, this should be the empty string. See
            PEP 592 for more information and the specification.
        :param cache_link_parsing: A flag that is used elsewhere to determine
                                   whether resources retrieved from this link
                                   should be cached. PyPI index urls should
                                   generally have this set to False, for
                                   example.
        s   \\t   keyt   defining_classN(   t
   startswithR   t   urllib_parset   urlsplitt   _parsed_urlt   _urlt
   comes_fromt   Nonet   requires_pythont   yanked_reasont   superR   t   __init__t   cache_link_parsing(   t   selft   urlR   R   R   R   (    (    s*   site-packages/pip/_internal/models/link.pyR      s    			c         C   sc   |  j  r d j |  j  ƒ } n d } |  j rL d j t |  j ƒ |  j | ƒ St t |  j ƒ ƒ Sd  S(   Ns    (requires-python:{})t    s   {} (from {}){}(   R   t   formatR   R   R   t   str(   R   t   rp(    (    s*   site-packages/pip/_internal/models/link.pyt   __str__J   s    		c         C   s   d j  |  ƒ S(   Ns	   <Link {}>(   R!   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyt   __repr__V   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyR   Z   s    c         C   sq   |  j  j d ƒ } t j | ƒ } | s@ t |  j ƒ \ } } | St j | ƒ } | sm t d j	 t
 ƒ    ƒ ‚ | S(   Nt   /s&   URL {self._url!r} produced no filename(   t   patht   rstript	   posixpatht   basenameR   t   netlocR   t   unquotet   AssertionErrorR!   t   locals(   R   R'   t   nameR+   t	   user_pass(    (    s*   site-packages/pip/_internal/models/link.pyt   filename_   s    	c         C   s   t  |  j ƒ S(   N(   R   R   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyt	   file_patho   s    c         C   s
   |  j  j S(   N(   R   t   scheme(   R   (    (    s*   site-packages/pip/_internal/models/link.pyR3   t   s    c         C   s
   |  j  j S(   s4   
        This can contain auth information.
        (   R   R+   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyR+   y   s    c         C   s   t  j |  j j ƒ S(   N(   R   R,   R   R'   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyR'      s    c         C   s   t  t j |  j j d ƒ ƒ ƒ S(   NR&   (   R   R)   R*   R'   R(   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyR   †   s    c         C   s   |  j  ƒ  d S(   Ni   (   R   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyt   extŠ   s    c         C   s4   |  j  \ } } } } } t j | | | | d  f ƒ S(   N(   R   R   t
   urlunsplitR   (   R   R3   R+   R'   t   queryt   fragment(    (    s*   site-packages/pip/_internal/models/link.pyt   url_without_fragment   s    s   [#&]egg=([^&]*)c         C   s,   |  j  j |  j ƒ } | s d  S| j d ƒ S(   Ni   (   t   _egg_fragment_ret   searchR   R   t   group(   R   t   match(    (    s*   site-packages/pip/_internal/models/link.pyt   egg_fragment—   s    s   [#&]subdirectory=([^&]*)c         C   s,   |  j  j |  j ƒ } | s d  S| j d ƒ S(   Ni   (   t   _subdirectory_fragment_reR:   R   R   R;   (   R   R<   (    (    s*   site-packages/pip/_internal/models/link.pyt   subdirectory_fragment¡   s    s2   (sha1|sha224|sha384|sha256|sha512|md5)=([a-f0-9]+)c         C   s,   |  j  j |  j ƒ } | r( | j d ƒ Sd  S(   Ni   (   t   _hash_reR:   R   R;   R   (   R   R<   (    (    s*   site-packages/pip/_internal/models/link.pyt   hash­   s    c         C   s,   |  j  j |  j ƒ } | r( | j d ƒ Sd  S(   Ni   (   R@   R:   R   R;   R   (   R   R<   (    (    s*   site-packages/pip/_internal/models/link.pyt	   hash_nameµ   s    c         C   s0   t  j |  j j d d ƒ d j d d ƒ d ƒ S(   Nt   #i   i    t   ?(   R)   R*   R   t   split(   R   (    (    s*   site-packages/pip/_internal/models/link.pyt   show_url½   s    c         C   s   |  j  d k S(   Nt   file(   R3   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyt   is_fileÂ   s    c         C   s   |  j  o t j j |  j ƒ S(   N(   RH   t   osR'   t   isdirR2   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyt   is_existing_dirÇ   s    c         C   s   |  j  t k S(   N(   R4   R   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyt   is_wheelË   s    c         C   s    d d l  m } |  j | j k S(   Niÿÿÿÿ(   t   vcs(   t   pip._internal.vcsRM   R3   t   all_schemes(   R   RM   (    (    s*   site-packages/pip/_internal/models/link.pyt   is_vcsÐ   s    c         C   s   |  j  d  k	 S(   N(   R   R   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyt	   is_yanked×   s    c         C   s   |  j  d  k	 S(   N(   RB   R   (   R   (    (    s*   site-packages/pip/_internal/models/link.pyt   has_hashÜ   s    c         C   s]   | d k s |  j r t S|  j d k	 s/ t ‚ |  j d k	 sD t ‚ | j |  j d |  j ƒS(   sG   
        Return True if the link has a hash and it is allowed.
        t
   hex_digestN(   R   RR   t   FalseRB   R-   RA   t   is_hash_allowed(   R   t   hashes(    (    s*   site-packages/pip/_internal/models/link.pyRU   á   s
    N(#   t   __name__t
   __module__t   __doc__R   t   TrueR   R$   R%   t   propertyR   R1   R2   R3   R+   R'   R   R4   R8   t   ret   compileR9   R=   R>   R?   R@   RA   RB   RF   RH   RK   RL   RP   RQ   RR   RU   (    (    (    s*   site-packages/pip/_internal/models/link.pyR      s@   )					(   RI   R)   R\   t   pip._vendor.six.moves.urllibR    R   t   pip._internal.utils.filetypesR   t   pip._internal.utils.miscR   R   R   t   pip._internal.utils.modelsR   t   pip._internal.utils.typingR   t   pip._internal.utils.urlsR   R   t   typingR	   R
   R   R   t   pip._internal.index.collectorR   t   pip._internal.utils.hashesR   R   (    (    (    s*   site-packages/pip/_internal/models/link.pyt   <module>   s   "