ó
b]c           @   sÕ   d  d l  Z  d  d l Z d  d l m Z d  d l m Z m Z m Z m	 Z	 m
 Z
 d  d l m Z d  d l 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_EXTENSIONt   path_to_urlt   redact_password_from_urlt   split_auth_from_netloct   splitext(   t   KeyBasedCompareMixin(   t   MYPY_CHECK_RUNNING(   t   Optionalt   Textt   Tuplet   Union(   t   HTMLPage(   t   Hashest   Linkc           B   sa  e  Z d  Z d d d d „ Z d „  Z 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 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.
        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   selft   urlR   R   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyR      s    			c         C   s\   |  j  r d |  j  } n d } |  j rE d t |  j ƒ |  j | f St t |  j ƒ ƒ Sd  S(   Ns    (requires-python:%s)t    s   %s (from %s)%s(   R   R   R   R   t   str(   R   t   rp(    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt   __str__>   s    		c         C   s   d |  S(   Ns	   <Link %s>(    (   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt   __repr__I   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyR   L   s    c         C   sl   |  j  j d ƒ } t j | ƒ } | s@ t |  j ƒ \ } } | St j | ƒ } | sh t d |  j	 ƒ ‚ | S(   Nt   /s   URL %r produced no filename(
   t   patht   rstript	   posixpatht   basenameR   t   netlocR   t   unquotet   AssertionErrorR   (   R   R$   t   nameR(   t	   user_pass(    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt   filenameQ   s    c         C   s
   |  j  j S(   N(   R   t   scheme(   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyR.   `   s    c         C   s
   |  j  j S(   s4   
        This can contain auth information.
        (   R   R(   (   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyR(   e   s    c         C   s   t  j |  j j ƒ S(   N(   R   R)   R   R$   (   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyR$   m   s    c         C   s   t  t j |  j j d ƒ ƒ ƒ S(   NR#   (   R   R&   R'   R$   R%   (   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyR   r   s    c         C   s   |  j  ƒ  d S(   Ni   (   R   (   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt   extv   s    c         C   s4   |  j  \ } } } } } t j | | | | d  f ƒ S(   N(   R   R   t
   urlunsplitR   (   R   R.   R(   R$   t   queryt   fragment(    (    s8   lib/python2.7/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(    (    s8   lib/python2.7/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_reR5   R   R   R6   (   R   R7   (    (    s8   lib/python2.7/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_reR5   R   R6   R   (   R   R7   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt   hash™   s    c         C   s,   |  j  j |  j ƒ } | r( | j d ƒ Sd  S(   Ni   (   R;   R5   R   R6   R   (   R   R7   (    (    s8   lib/python2.7/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   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt   show_url©   s    c         C   s   |  j  t k S(   N(   R/   R   (   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt   is_wheel®   s    c         C   s*   d d l  m } |  j | j k r& t St S(   s    
        Determines if this points to an actual artifact (e.g. a tarball) or if
        it points to an "abstract" thing like a path or a VCS location.
        iÿÿÿÿ(   t   vcs(   t   pip._internal.vcsRC   R.   t   all_schemest   Falset   True(   R   RC   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt   is_artifact³   s    c         C   s   |  j  d  k	 S(   N(   R   R   (   R   (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt	   is_yankedÁ   s    c         C   s   |  j  d  k	 S(   N(   R=   R   (   R   (    (    s8   lib/python2.7/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   RJ   RF   R=   R*   R<   t   is_hash_allowed(   R   t   hashes(    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyRL   Ê   s
    N(   t   __name__t
   __module__t   __doc__R   R   R!   R"   t   propertyR   R-   R.   R(   R$   R   R/   R3   t   ret   compileR4   R8   R9   R:   R;   R<   R=   RA   RB   RH   RI   RJ   RL   (    (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyR      s8   "				(   R&   RR   t   pip._vendor.six.moves.urllibR    R   t   pip._internal.utils.miscR   R   R   R   R   t   pip._internal.utils.modelsR   t   pip._internal.utils.typingR   t   typingR   R	   R
   R   t   pip._internal.indexR   t   pip._internal.utils.hashesR   R   (    (    (    s8   lib/python2.7/site-packages/pip/_internal/models/link.pyt   <module>   s   ("