
9Vc           @@  s  d  Z  d d l m Z d d l Z d d l 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 m Z d d l m Z d d l m Z d d l m Z m Z m Z 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# m$ Z$ m% Z% d d l& m' Z' m( Z( m) Z) d d l* m+ Z+ d d l, m- Z- m. Z. d d l/ m0 Z0 m1 Z1 m2 Z2 d d l3 m4 Z4 m5 Z5 m6 Z6 m7 Z7 d d l8 m Z9 d d l: m; Z; d d d g Z< d d d f d d d f d d d f d d d f d d e= f g Z> e j? e@  ZA d eB f d     YZC d eB f d     YZD e
 jE d e
 jF  d  ZG d  eB f d!     YZH d" eB f d#     YZI eI e  ZJ e d d$  ZK d%   ZL d&   ZM d'   ZN d(   ZO e d) d*  ZP d S(+   s!   Routines related to PyPI, indexesi    (   t   absolute_importN(   t
   namedtuple(   t   parse(   t   request(   t	   ipaddress(   t   Inft   cached_propertyt   normalize_namet   splitextt   normalize_patht   ARCHIVE_EXTENSIONSt   SUPPORTED_EXTENSIONS(   t   RemovedInPip8Warning(   t
   indent_log(   t   DistributionNotFoundt   BestVersionAlreadyInstalledt   InvalidWheelFilenamet   UnsupportedWheel(   t   HAS_TLSt   url_to_patht   path_to_url(   t   PyPI(   t   Wheelt	   wheel_ext(   t   supported_tagst   supported_tags_noarcht   get_platform(   t   html5libt   requestst   pkg_resourcest   six(   t   SSLErrort   FormatControlt   fmt_ctl_handle_mutual_excludet   PackageFindert   httpst   *t	   localhosts   127.0.0.0/8s   ::1/128t   filet   InstallationCandidatec           B@  sb   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   c         C@  s@   | |  _  t |  |  _ | |  _ |  j  |  j |  j f |  _ d  S(   N(   t   projectt   parse_versiont   versiont   locationt   _key(   t   selfR(   R*   R+   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __init__8   s    		c         C@  s   d j  |  j |  j |  j  S(   Ns,   <InstallationCandidate({0!r}, {1!r}, {2!r})>(   t   formatR(   R*   R+   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __repr__>   s    c         C@  s   t  |  j  S(   N(   t   hashR,   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __hash__C   s    c         C@  s   |  j  | d    S(   Nc         S@  s
   |  | k  S(   N(    (   t   st   o(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   <lambda>G   s    (   t   _compare(   R-   t   other(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __lt__F   s    c         C@  s   |  j  | d    S(   Nc         S@  s
   |  | k S(   N(    (   R3   R4   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR5   J   s    (   R6   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __le__I   s    c         C@  s   |  j  | d    S(   Nc         S@  s
   |  | k S(   N(    (   R3   R4   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR5   M   s    (   R6   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __eq__L   s    c         C@  s   |  j  | d    S(   Nc         S@  s
   |  | k S(   N(    (   R3   R4   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR5   P   s    (   R6   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __ge__O   s    c         C@  s   |  j  | d    S(   Nc         S@  s
   |  | k S(   N(    (   R3   R4   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR5   S   s    (   R6   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __gt__R   s    c         C@  s   |  j  | d    S(   Nc         S@  s
   |  | k S(   N(    (   R3   R4   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR5   V   s    (   R6   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __ne__U   s    c         C@  s&   t  | t  s t S| |  j | j  S(   N(   t
   isinstanceR'   t   NotImplementedR,   (   R-   R7   t   method(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR6   X   s    (   t   __name__t
   __module__R.   R0   R2   R8   R9   R:   R;   R<   R=   R6   (    (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR'   6   s   									c        	   B@  s   e  Z d  Z d d e e d e d d d  Z d   Z e e d   Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z e j d  Z d   Z d   Z d   Z d   Z d   Z RS(   s   This finds packages.

    This is meant to match easy_install's technique for looking for
    packages, by reading pages and looking for appropriate links.
    c         C@  s  |	 d k r t d   n  g  |  _ xW | D]O } | j d  rj t |  } t j j |  rj | } qj n  |  j j |  q+ W| |  _	 g  |  _
 t   |  _ |
 p t t   t    |  _ t d   | D  |  _ t d   | D  |  _ |  j |  j O_ | |  _ g  | r| n g  D] } d | d f ^ q|  _ t |  _ t |  _ | |  _ | |  _ |	 |  _ t sxR t j |  j	 |  j  D]5 } t j |  } | j d k rt j  d  PqqWn  d S(	   s   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.
        s>   PackageFinder() missing 1 required keyword argument: 'session't   ~c         s@  s   |  ] } t  |  Vq d  S(   N(   R   (   t   .0t   n(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>   s    c         s@  s   |  ] } t  |  Vq d  S(   N(   R   (   RD   RE   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>   s    R$   R#   si   pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.N(!   t   Nonet	   TypeErrort
   find_linkst
   startswithR	   t   ost   patht   existst   appendt
   index_urlst   dependency_linkst   sett   logged_linksR    t   format_controlt   allow_externalt   allow_unverifiedt   allow_all_externalt   secure_originst   Falset   need_warn_externalt   need_warn_unverifiedt   allow_all_prereleasest   process_dependency_linkst   sessionR   t	   itertoolst   chaint   urllib_parset   urlparset   schemet   loggert   warning(   R-   RH   RN   RS   RT   RU   RZ   t   trusted_hostsR[   R\   RR   t   linkt   new_linkt   hostt   parsed(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR.   f   sB    					.					c         C@  s0   |  j  r, t j d t  |  j j |  n  d  S(   NsX   Dependency Links processing has been deprecated and will be removed in a future release.(   R[   t   warningst   warnR   RO   t   extend(   R-   t   links(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   add_dependency_links   s
    	c         @  s)  g    g      f d   } x |  D] } t  j j |  } | j d  } | sX | r| rg | } n t |  } t  j j |  r | r t  j j |  } xI t  j |  D] } | t  j j | |   q Wq| r j	 |  qqt  j j
 |  r| |  qq%  j	 |  q% W   f S(   st   
        Sort locations into "files" (archives) and "urls", and return
        a pair of lists (files,urls)
        c         @  sL   t  |   } t j | d t d d k r;  j |  n   j |  d  S(   Nt   stricti    s	   text/html(   R   t	   mimetypest
   guess_typeRW   RM   (   RK   t   url(   t   filest   urls(    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt	   sort_path   s    s   file:(   RJ   RK   RL   RI   R   t   isdirt   realpatht   listdirt   joinRM   t   isfile(   t	   locationst
   expand_dirRt   Rq   t   is_local_patht   is_file_urlRK   t   item(    (   Rr   Rs   s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   _sort_locations   s*    	 c         C@  s   t  t  } | j t k r$ d } nW | j j rt t | j j  } | j   sd t d | j   n  | j	   } n | } | j
 | f S(   sL  
        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()
          3. source archives
        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
        i   sB   %s is not a supported wheel for this platform. It can't be sorted.(   t   lenR   R+   t   INSTALLED_VERSIONt   is_wheelR   t   filenamet	   supportedR   t   support_index_minR*   (   R-   t	   candidatet   support_numt   prit   wheel(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   _candidate_sort_key   s    	c         C@  s   t  | d |  j d t S(   s   
        Bring the latest version (and wheels) to the front, but maintain the
        existing ordering as secondary. See the docstring for `_link_sort_key`
        for details. This function is isolated for easier unit testing.
        t   keyt   reverse(   t   sortedR   t   True(   R-   t   applicable_versions(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   _sort_versions  s    	c         C@  s  t  j t |   } | j | j | j f } xVt |  j D]G} | d | d k rk | d d k rk q; n  y t j	 t
 | d t j  s | d d  k r | d n | d j d   } t j t
 | d t j  r | d n | d j d   } Wn; t k
 r4| d | d k rG| d d k rGq; qGn X| | k rGq; n  | d | d k r| d d k r| d d  k	 rq; n  t SW| j d | j | j  t S(   Ni    R$   i   t   utf8i   s   The repository located at %s is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host %s'.(   R_   R`   t   strRa   t   hostnamet   portt   SECURE_ORIGINSRV   R   t
   ip_addressR>   R   t	   text_typeRF   t   decodet
   ip_networkt
   ValueErrorR   Rc   RW   (   R-   Rb   R+   Rh   t   origint   secure_origint   addrt   network(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   _validate_secure_origin  s8    $ $

c         @  s     f d   } t  j | j      |  j r t | |  j d  d t } |  j |  } | d k r t j	 t
 |  k r t j d | | f t  |  j t |  j d d t    p     q n    d k	 r g  |  j D] } | |  ^ q Sg  S(   s   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         @  s2   t  j |     } | j d  s. | d } n  | S(   Nt   /(   t	   posixpathRx   t   endswith(   Rq   t   loc(   t   project_url_name(    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   mkurl_pypi_urld  s    i    t   trustedsy   Failed to find %r at %s. It is suggested to upgrade your index to support normalized names as the name in /simple/{name}.N(   R_   t   quotet   lowerRN   t   LinkR   t	   _get_pageRF   R   t   netlocR   Ri   Rj   R   t   _find_url_name(   R-   t   project_nameR   t   main_index_urlt   pageRq   (    (   R   s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   _get_index_urls_locations]  s&    		!
	 c      	   C@  s  |  j  |  } |  j |  \ } } |  j |  j d t \ } } |  j |  j  \ } } d   t j | | |  D }	 g  t j d   | D d   | D d   | D  D] }
 |  j t |
  r |
 ^ q } t j	 d t
 |  |  x | D] } t j	 d |  q Wt j |  j   } t |  j |  } t | j   | |  } |  j d   |  j D |  } g  } xY |  j | |  D]E } t j	 d	 | j  t   ! | j |  j | j |   Wd
 QXqW|  j d   |  j D |  } | r%t j	 d d j g  | D] } | j j ^ q  n  |  j |	 |  } | r| j d t  t j	 d d j g  | D] } t | j j  ^ qc  n  | | | | S(   s   Find all available versions for project_name

        This checks index_urls, find_links and dependency_links
        All versions found are returned

        See _link_package_versions for details on which files are accepted
        R{   c         s@  s   |  ] } t  |  Vq d  S(   N(   R   (   RD   Rq   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>  s    c         s@  s!   |  ] } t  | d  t Vq d S(   R   N(   R   R   (   RD   Rq   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>  s    c         s@  s!   |  ] } t  | d  t Vq d S(   R   N(   R   R   (   RD   Rq   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>  s    c         s@  s   |  ] } t  |  Vq d  S(   N(   R   (   RD   Rq   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>  s    s,   %d location(s) to search for versions of %s:s   * %sc         s@  s$   |  ] } t  | d  d t Vq d S(   s   -fR   N(   R   R   (   RD   Rq   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>  s    s   Analyzing links from page %sNc         s@  s   |  ] } t  |  Vq d  S(   N(   R   (   RD   Rq   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>  s    s   dependency_links found: %ss   , R   s   Local files found: %s(   R   R   RH   R   RO   R]   R^   R   Rb   t   debugR   R   t	   safe_nameR   t   fmt_ctl_formatsRR   t   Searcht   _package_versionst
   _get_pagesRq   R   Rk   Rl   Rx   R+   t   sortR   (   R-   R   t   index_locationst   index_file_loct   index_url_loct   fl_file_loct
   fl_url_loct   dep_file_loct   dep_url_loct   file_locationsRe   t   url_locationsR+   t   canonical_namet   formatst   searcht   find_links_versionst   page_versionsR   t   dependency_versionsR*   t   file_versionsR   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   _find_all_versions  sZ    			
 &)c   	   	   C@  s  |  j  | j  } t | j j g  | D] } t | j  ^ q% d |  j rR |  j n d  } g  | D]! } t | j  | k re | ^ qe } | j	 d k	 r | j
 d t | j | j	 j t   t } n t } |  j |  } | r<| r<| d j t k rt j d | j	 j  n! t j d | j	 j | d d  d S| st j d | d j t t d   | D  d	 t   |  j rt j d
 | j  n  |  j rt j d | j  n  t d |   n  | d j t k rt j d | j	 j d j d   | d D  pd  t  n  t |  d k r_t j d | d j d j d   | D   n  | d j } | j d k	 r| j rt j d | j  n  | S(   s   Try to find an InstallationCandidate for req

        Expects req, an InstallRequirement and upgrade, a boolean
        Returns an InstallationCandidate or None
        May raise DistributionNotFound or BestVersionAlreadyInstalled
        t   prereleasesi    sL   Existing installed version (%s) is most up-to-date and satisfies requirementsU   Existing installed version (%s) satisfies requirement (most up-to-date version is %s)i   sN   Could not find a version that satisfies the requirement %s (from versions: %s)s   , c         s@  s   |  ] } t  | j  Vq d  S(   N(   R   R*   (   RD   t   i(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>%  s    R   sq   Some externally hosted files were ignored as access to them may be unreliable (use --allow-external %s to allow).sW   Some insecure and unverifiable files were ignored (use --allow-unverified %s to allow).s%   No matching distribution found for %ss=   Installed version (%s) is most up-to-date (past versions: %s)c         s@  s   |  ] } t  | j  Vq d  S(   N(   R   R*   (   RD   R   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>D  s    i   t   nones)   Using version %s (newest of versions: %s)c         s@  s   |  ] } t  | j  Vq d  S(   N(   R   R*   (   RD   R   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pys	   <genexpr>M  s    s,   %s is potentially insecure and unverifiable.N(   R   t   nameRP   t	   specifiert   filterR   R*   RZ   RF   t   satisfied_byt   insertR'   R   R   RW   R   R+   Rb   R   t   criticalRx   R   R)   RX   Rc   RY   R   R   R   t
   verifiable(	   R-   t   reqt   upgradet   all_versionst   xt	   _versionsR   t   existing_applicablet   selected_version(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   find_requirement  s|    	".	
						

c         C@  s   | j  j d  s$ | j  d 7_  n  |  j |  } | d k rS t j d |  d St |  } xU | j D]J } t j	 | j
 j d   } | t |  k ri t j d | |  | Sqi Wd S(   s   
        Finds the true URL name of a package, when the given name isn't quite
        correct.
        This is usually used to implement case-insensitivity.
        R   s   Cannot fetch index base URL %sNs!   Real name of requirement %s is %s(   Rq   R   R   RF   Rb   R   R   Rl   R   t   basenameRK   t   rstripR   (   R-   t	   index_urlt   url_nameR   t	   norm_nameRe   t   base(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   Z  s    c   	      c@  s)  t  |  } t   } t |  } x| r$| j d  } | | k rK q$ n  | j |  |  j |  } | d k ry q$ n  | Vx | j   D] } | |  j k r |  j	 r t
 |  _ t j d |  q n  | j d k	 r| j r| |  j k rt j d |  t
 |  _ q n  | j |  q Wq$ Wd S(   s   
        Yields (page, page_url) from the given locations, skipping
        locations that have errors, and adding download/homepage links
        i    s@   Not searching %s for files because external urls are disallowed.s_   Not searching %s for urls, it is an untrusted link and cannot produce safe or verifiable files.N(   t   listRP   R   t   popt   addR   RF   t	   rel_linksRS   RU   R   RX   Rb   R   R   RT   RY   RM   (	   R-   Rz   R   t   all_locationst   seent
   normalizedR+   R   Re   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   r  s:    		
	
	s   -py([123]\.?[0-9]?)$c         C@  sq   g  g  } } t    } xP | D]H } | | k r | j |  | j rU | j |  qe | j |  q q W| | S(   s   
        Returns elements of links in order, non-egg links first, egg links
        second, while eliminating duplicates
        (   RP   R   t   egg_fragmentRM   (   R-   Rl   t   eggst   no_eggsR   Re   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   _sort_links  s    		c         C@  sR   g  } xE |  j  |  D]4 } |  j | |  } | d  k	 r | j |  q q W| S(   N(   R   t   _link_package_versionsRF   RM   (   R-   Rl   R   t   resultRe   t   v(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR     s    c         C@  s9   | |  j  k r5 t j d | |  |  j  j |  n  d  S(   Ns   Skipping link %s; %s(   RQ   Rb   R   R   (   R-   Re   t   reason(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   _log_skipped_link  s    c         C@  s  t    } d } | j r- | j } | j } n| j   \ } } | sY |  j | d  d S| t k r} |  j | d |  d Sd | j k r | t k r |  j | d | j	  d Sd | j
 k r | d k r |  j | d  d S| t k r#y t | j  } Wn" t k
 r%|  j | d	  d SXt j | j  j   | j k rb|  j | d
 | j	  d S| j   s|  j | d  d St | d d  } | j d  r| j d  r| d k r| d k	 rt j | j  j j t j  r| j d t  s|  j | d  d Sn  | j } n  d | j k rY| t k rY|  j | d | j	  d S| swt | | j	 |  } n  | d k r|  j | d
 | j	  d S| j d k	 r| j rt  | j	  j   |  j! k r|  j" r|  j | d  t# |  _$ d S| j% d k	 rP| j% rPt  | j	  j   |  j& k rP|  j | d  t# |  _' d S|  j( j) |  }	 |	 r| |	 j*    } |	 j+ d  }
 |
 t, j d  k r|  j | d  d Sn  t- j. d | |  t/ | j	 | |  S(   s'   Return an InstallationCandidate or Nones
   not a fileNs   unsupported archive format: %st   binarys   No binaries permitted for %st   macosx10s   .zips   macosx10 ones   invalid wheel filenames   wrong project name (not %s)s%   it is not compatible with this Pythont
   comes_fromt   wint   macosxt   clit   tagss;   it is a pypi-hosted binary Wheel on an unsupported platformt   sources   No sources permitted for %ss   it is externally hosteds'   it is an insecure and unverifiable filei   i   s   Python version is incorrects   Found link %s, version: %s(0   R   RF   R   t   extR   R   R   R   R   t   suppliedRK   R   R   R   R   R   R   R   t	   canonicalR   t   getattrRI   R_   R`   Rq   R   R   R   R   R*   t   egg_info_matchest   internalR   RS   RU   R   RX   R   RT   RY   t   _py_version_reR   t   startt   groupt   sysRb   R   R'   (   R-   Re   R   t   platformR*   t   egg_infoR   R   R   t   matcht
   py_version(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR     s    			


	

	
c         C@  s   t  j | d |  j S(   NR\   (   t   HTMLPaget   get_pageR\   (   R-   Re   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   1  s    (    (    N(   RA   RB   t   __doc__RW   RF   R.   Rm   t   staticmethodR   R   R   R   R   R   R   R   R   t   ret   compileR   R   R   R   R   R   (    (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR"   _   s,   T	(			@	/	S	{		/				qs   ([a-z0-9_.]+)-([a-z0-9_.!+-]+)c         C@  s   | j  |   } | s) t j d |  d S| d k rU | j d  } | | j d  S| j d  j   } | j d d  } | j   d } | j |  r | j d  t	 |  Sd Sd S(   sx  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.
    s%   Could not parse version from link: %si    t   -t   _N(
   R   Rb   R   RF   R  t   indexR   t   replaceRI   R   (   R  t   search_nameRe   t   _egg_info_reR  t
   full_matchR   t   look_for(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   5  s    R  c           B@  s   e  Z d  Z d d d  Z d   Z e e d d   Z e	 d d d   Z
 e	 d    Z e d    Z e d    Z e d	    Z d d  Z e j d e j  Z d   Z RS(   s'   Represents one page, along with its URLc         C@  s   d  } | rM d | k rM t j | d  \ } } d | k rM | d } qM n  | |  _ t j |  j d | d t |  _ | |  _ | |  _	 | |  _
 d  S(   Ns   Content-Typet   charsett   encodingt   namespaceHTMLElements(   RF   t   cgit   parse_headert   contentR   R   RW   Rh   Rq   t   headersR   (   R-   R  Rq   R  R   R  t   content_typet   params(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR.   U  s    				c         C@  s   |  j  S(   N(   Rq   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   __str__h  s    c         C@  s1  | d  k r t d   n  | j } | j d d  d } d d l m } xS | j D]H } | j   j |  rT | t	 |  d k rT t
 j d | |  d  SqT Wy| r| j } xh t D]] } | j |  r |  j | d | }	 |	 j   j d	  r Pqt
 j d
 | |	  d  Sq q Wn  t
 j d |  t j |  \ } }
 } } } } | d k rt j j t j |   r| j d  s| d 7} n  t j | d  } t
 j d |  n  | j | d i d	 d 6d d 6} | j   | j j d d  }	 |	 j   j d	  s$t
 j d
 | |	  d  S|  | j | j | j d | j } Wn t j k
 r} | j j  d k rvd n d } |  j! | | | d | n t j" k
 r} |  j! | d | |  ni t j# k
 r|  j! | d |  nC t$ k
 r(} d | } |  j! | | | d d d t
 j% n X| Sd  S(   Ns9   get_page() missing 1 required keyword argument: 'session't   #i   i    (   t
   VcsSupports   +:s   Cannot look at %s URL %sR\   s	   text/htmls,   Skipping page %s because of Content-Type: %ss   Getting page %sR&   R   s
   index.htmls#    file: URL is directory, getting %sR  t   Accepts   max-age=600s   Cache-Controls   Content-Typet   unknownR   i  i   t   levels   connection error: %ss	   timed outs6   There was a problem confirming the ssl certificate: %st   meth(&   RF   RG   Rq   t   splitt   pip.vcsR   t   schemesR   RI   R   Rb   R   R   R
   R   t   _get_content_typeR_   R`   RJ   RK   Ru   t   urllib_requestt   url2pathnamet   urljoint   gett   raise_for_statusR  R  R   R   t	   HTTPErrort   responset   status_codet   _handle_failt   ConnectionErrort   TimeoutR   t   info(   t   clsRe   t   skip_archivesR\   Rq   R   Ra   R   t   bad_extR  R   RK   R  t   queryt   fragmentt   respt   instt   excR#  R   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR  k  sx    	+	!
&i   c         C@  s,   | d  k r t j } n  | d |  |  d  S(   Ns%   Could not fetch URL %s: %s - skipping(   RF   Rb   R   (   Re   R   Rq   R#  R$  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR1    s    c         C@  s`   t  j |   \ } } } } } | d k r. d S| j |  d t } | j   | j j d d  S(   s;   Get the Content-Type of the given url, using a HEAD requestt   httpR#   t    t   allow_redirectss   Content-Type(   s   https   https(   R_   t   urlsplitt   headR   R-  R  R,  (   Rq   R\   Ra   R   RK   R8  R9  R:  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR(    s    
c         C@  s   g  |  j  j d  D]* } | j d d  j   d k r | ^ q } | r y t | d j d d    SWq t t f k
 r q Xn  d  S(   Ns   .//metaR   R>  s   api-versioni    t   value(   Rh   t   findallR,  R   t   intRF   RG   R   (   R-   R   t   metas(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   api_version  s    *c         C@  so   g  |  j  j d  D]! } | j d  d  k	 r | ^ q } | rd | d j d  rd | d j d  S|  j Sd  S(   Ns   .//baset   hrefi    (   Rh   RC  R,  RF   Rq   (   R-   R   t   bases(    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   base_url  s
    !c         c@  s   x |  j  j d  D] } | j d  r | j d  } |  j t j |  j |   } d } |  j r |  j d k r t	 | j d  o d | j d  j
   k  } n  t | |  d | Vq q Wd S(   s   Yields all links in the pages   .//aRG  i   t   relR   N(   Rh   RC  R,  t
   clean_linkR_   R+  RI  RF   RF  t   boolR%  R   (   R-   t   anchorRG  Rq   R   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyRl     s    !t   homepaget   downloadc         c@  s   t  |  } x |  j j d  D] } | j d  r | j d  r t  | j d  j    } | | @r | j d  } |  j t j |  j |   } t	 | |  d t
 Vq q q Wd S(   s)   Yields all links with the given relationss   .//aRJ  RG  R   N(   RP   Rh   RC  R,  R%  RK  R_   R+  RI  R   RW   (   R-   t   relsRM  t
   found_relsRG  Rq   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR     s    
s   [^a-z0-9$&+,/:;=?@.#%_\\|-]c         C@  s   |  j  j d   |  S(   s   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  |  j d   S(   Ns   %%%2xi    (   t   ordR  (   R  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR5   "  s    (   t	   _clean_ret   sub(   R-   Rq   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyRK    s    	N(   s   homepages   download(   RA   RB   R	  RF   R.   R  t   classmethodR   R  R
  R1  R(  R   RF  RI  t   propertyRl   R   R  R  t   IRS  RK  (    (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR  R  s   	YR   c           B@  sU  e  Z d d d d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z 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 d    Z e d    Z e d    Z e d    Z e d    Z RS(   c         C@  sR   | t  k r* | j d  r* t |  } n  | |  _ | |  _ | |  _ | |  _ d  S(   Ns   \\(   R   RI   R   Rq   R   R   R   (   R-   Rq   R   R   R   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR.   '  s    			c         C@  s.   |  j  r d |  j |  j  f St |  j  Sd  S(   Ns   %s (from %s)(   R   Rq   R   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR  2  s    	c         C@  s   d |  S(   Ns	   <Link %s>(    (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR0   8  s    c         C@  s#   t  | t  s t S|  j | j k S(   N(   R>   R   R?   Rq   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR:   ;  s    c         C@  s#   t  | t  s t S|  j | j k S(   N(   R>   R   R?   Rq   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR=   @  s    c         C@  s#   t  | t  s t S|  j | j k  S(   N(   R>   R   R?   Rq   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR8   E  s    c         C@  s#   t  | t  s t S|  j | j k S(   N(   R>   R   R?   Rq   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR9   J  s    c         C@  s#   t  | t  s t S|  j | j k S(   N(   R>   R   R?   Rq   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR<   O  s    c         C@  s#   t  | t  s t S|  j | j k S(   N(   R>   R   R?   Rq   (   R-   R7   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR;   T  s    c         C@  s   t  |  j  S(   N(   R1   Rq   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR2   Y  s    c         C@  sk   t  j |  j  \ } } } } } t j | j d   p< | } t  j |  } | sg t d |  j   | S(   NR   s   URL %r produced no filename(   R_   R@  Rq   R   R   R   t   unquotet   AssertionError(   R-   R  R   RK   R   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   \  s
    !c         C@  s   t  j |  j  d S(   Ni    (   R_   R@  Rq   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyRa   d  s    c         C@  s   t  j |  j  d S(   Ni   (   R_   R@  Rq   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   h  s    c         C@  s   t  j t  j |  j  d  S(   Ni   (   R_   RX  R@  Rq   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyRK   l  s    c         C@  s   t  t j |  j j d    S(   NR   (   R   R   R   RK   R   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   p  s    c         C@  s   |  j    d S(   Ni   (   R   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   s  s    c         C@  s=   t  j |  j  \ } } } } } t  j | | | | d  f  S(   N(   R_   R@  Rq   t
   urlunsplitRF   (   R-   Ra   R   RK   R8  R9  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   url_without_fragmentw  s    !s   #egg=([^&]*)c         C@  s,   |  j  j |  j  } | s d  S| j d  S(   Ni   (   t   _egg_fragment_reR   Rq   RF   R  (   R-   R  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   ~  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   Rq   R  RF   (   R-   R  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR1     s    c         C@  s,   |  j  j |  j  } | r( | j d  Sd  S(   Ni   (   R]  R   Rq   R  RF   (   R-   R  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt	   hash_name  s    c         C@  s0   t  j |  j j d d  d j d d  d  S(   NR  i   i    t   ?(   R   R   Rq   R%  (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   show_url  s    c         C@  s   |  j  p t |  j d d  } | d k	 r | r y% t |  j d d  } t |  } Wn t t f k
 rt d } n X| d k s | d k r d S|  j r t St	 Sn | d k	 r t	 Sd S(   s   
        Returns True if this link can be verified after download, False if it
        cannot, and None if we cannot determine.
        R   RF  i   N(
   R   R   R   RF   RD  R   RG   R1   R   RW   (   R-   R   RF  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR     s    
	c         C@  s   |  j  t k S(   N(   R   R   (   R-   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR     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(   R&  Ra  Ra   t   all_schemesRW   R   (   R-   Ra  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   is_artifact  s    N(    RA   RB   RF   R.   R  R0   R:   R=   R8   R9   R<   R;   R2   RV  R   Ra   R   RK   R   R   R[  R  R  R\  R   R]  R1   R^  R`  R   R   Rc  (    (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR   %  s6   											#s   no_binary only_binaryc         C@  s   |  j  d  } xU d | k rf | j   | j   | j d  | | j d  d 4d | k r d  Sq WxY | D]Q } | d k r | j   qn n  t j |  j   } | j |  | j |  qn Wd  S(   Nt   ,s   :all:i   s   :none:(   R%  t   clearR   R  R   R   R   t   discard(   RB  t   targetR7   t   newR   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR!     s    


c         C@  s   t  d d g  } | |  j k r1 | j d  n] | |  j k rP | j d  n> d |  j k ro | j d  n d |  j k r | j d  n  t |  S(   NR   R   s   :all:(   RP   t   only_binaryRf  t	   no_binaryt	   frozenset(   t   fmt_ctlR   R   (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyR     s    c         C@  s   t  d |  j |  j  d  S(   Ns   :all:(   R!   Rj  Ri  (   Rl  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   fmt_ctl_no_binary  s    c         C@  s$   t  |   t j d t d d d  S(   Nsf   --no-use-wheel is deprecated and will be removed in the future.  Please use --no-binary :all: instead.t
   stackleveli   (   Rm  Ri   Rj   t   DeprecationWarning(   Rl  (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   fmt_ctl_no_use_wheel  s
    
R   s   supplied canonical formats(Q   R	  t
   __future__R    t   loggingR  t   collectionsR   R]   R  RJ   R  Ro   R   Ri   t   pip._vendor.six.moves.urllibR   R_   R   R)  t
   pip.compatR   t	   pip.utilsR   R   R   R   R	   R
   R   t   pip.utils.deprecationR   t   pip.utils.loggingR   t   pip.exceptionsR   R   R   R   t   pip.downloadR   R   R   t
   pip.modelsR   t	   pip.wheelR   R   t   pip.pep425tagsR   R   R   t   pip._vendorR   R   R   R   t   pip._vendor.packaging.versionR)   t   pip._vendor.requests.exceptionsR   t   __all__RF   R   t	   getLoggerRA   Rb   t   objectR'   R"   R  RW  R   R  R   R   R    R!   R   Rm  Rp  R   (    (    (    s&   /tmp/pip-build-5Z5nTX/pip/pip/index.pyt   <module>   s^   4"")  
				