ó
Đ˛Ebc           @   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 d d d g 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
    t   _parsed_urlt   _urlt
   comes_fromt   requires_pythont   yanked_reasont   cache_link_parsingc         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   urlsplitR   R   R   t   NoneR   R   t   superR   t   __init__R   (   t   selft   urlR   R   R   R   (    (    s6   /tmp/pip-build-UPPWic/pip/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(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyt   __str__T   s    		c         C   s   d j  |   S(   Ns	   <Link {}>(   R!   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyt   __repr__`   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyR   d   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(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyt   filenamei   s    	c         C   s   t  |  j  S(   N(   R   R   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyt	   file_pathy   s    c         C   s
   |  j  j S(   N(   R   t   scheme(   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyR3   ~   s    c         C   s
   |  j  j S(   s4   
        This can contain auth information.
        (   R   R+   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyR+      s    c         C   s   t  j |  j j  S(   N(   R   R,   R   R'   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyR'      s    c         C   s   t  t j |  j j d    S(   NR&   (   R   R)   R*   R'   R(   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyR      s    c         C   s   |  j    d S(   Ni   (   R   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/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(    (    s6   /tmp/pip-build-UPPWic/pip/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(    (    s6   /tmp/pip-build-UPPWic/pip/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<   (    (    s6   /tmp/pip-build-UPPWic/pip/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<   (    (    s6   /tmp/pip-build-UPPWic/pip/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<   (    (    s6   /tmp/pip-build-UPPWic/pip/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   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyt   show_urlÇ   s    c         C   s   |  j  d k S(   Nt   file(   R3   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/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   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyt   is_existing_dirŃ   s    c         C   s   |  j  t k S(   N(   R4   R   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/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   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyt   is_vcsÚ   s    c         C   s   |  j  d  k	 S(   N(   R   R   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyt	   is_yankedá   s    c         C   s   |  j  d  k	 S(   N(   RB   R   (   R   (    (    s6   /tmp/pip-build-UPPWic/pip/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(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyRU   ë   s
    N($   t   __name__t
   __module__t   __doc__t	   __slots__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   (    (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyR      sL   	)					(   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   (    (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_internal/models/link.pyt   <module>   s   "