
'Mc           @   s  d  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	 Z	 d d l
 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 m Z m Z m Z m Z m Z m Z m Z m Z d d l m Z d d	 l m  Z  m! Z! m" Z" m# Z# m$ Z$ d
 g Z% d Z& d
 e' f d     YZ( d e' f d     YZ) d e' f d     YZ* d e' f d     YZ+ d   Z, d   Z- e. d  Z/ d   Z0 d S(   s!   Routines related to PyPI, indexesiN(   t   logger(   t   Inf(   t   normalize_namet   splitext(   t   DistributionNotFound(	   t   WindowsErrort   Queuet   httplibt   urlparset   URLErrort	   HTTPErrort   ut   productt   url2pathname(   t   Empty(   t   urlopent   path_to_url2t   url_to_patht   geturlt   Urllib2HeadRequestt   PackageFinders   last.pypi.python.orgc           B   s   e  Z d  Z e d d d  Z d   Z e d    Z d   Z	 d   Z
 d   Z e j   Z d   Z e j d  Z e j d	 e j  Z e j d
  Z d   Z d   Z d   Z d   Z d   Z d d 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{   | |  _  | |  _ g  |  _ t   |  _ t   |  _ | rn |  j | |  |  _ t	 j
 d d j |  j   n	 g  |  _ d  S(   Ns   Using PyPI mirrors: %ss   , (   t
   find_linkst
   index_urlst   dependency_linkst	   PageCachet   cachet   sett   logged_linkst   _get_mirror_urlst   mirror_urlsR    t   infot   join(   t   selfR   R   t   use_mirrorst   mirrorst   main_mirror_url(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   __init__%   s    			 c         C   s   |  j  j |  d  S(   N(   R   t   extend(   R    t   links(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   add_dependency_links3   s    c            s   g    g      f d   } x |  D] } | j  d  r t |  } t j j |  r t j j |  } xR t j |  D] } | t j j | |   qz Wq 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_typet   Falset   append(   t   patht   url(   t   filest   urls(    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt	   sort_pathE   s    s   file:(
   t
   startswithR   t   osR-   t   isdirt   realpatht   listdirR   t   isfileR,   (   t	   locationsR1   R.   R-   t   item(    (   R/   R0   s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   _sort_locations:   s     c            sf  | j    d  } |  j r t t j |  j d     } |  j | |  } | d  k r |  j t |  j d    |  p} | j    q n  |  j |  j }   f d   }   d  k	 r g  | D] } | |  ^ q |  j	 } n t
 |  j	  } | j |  j  xH | j D]= }	   d  k	 r| d  k	 rt j | j |	  g | } qqW|  j |  \ }
 } g  | D] } t |  ^ q`} t j d |  x | D] } t j d |  qWg  } | j |  j g  |  j	 D] } t | d  ^ q| j j     g  } xy |  j | |  D]e } t j d | j  t j d 7_ z) | j |  j | j | j j     Wd  t j d 8_ XqWt
 |  j g  |  j D] } t |  ^ q| j j     } | rt j d d	 j g  | D] \ } } }	 | j ^ q  n  t
 |  j g  |
 D] } t |  ^ q| j j     } | rm| rm| rm| rmt j d
 |  t d |   n  | j d  k	 r| j | j j t | j j f  n  | r| j  d t!  t j d d	 j g  | D] \ } } }	 t" | j  ^ q  | | } n  | | | } g  } x | D]| \ } } }	 |	 | j# k rt j d | |	 d j g  | j# j$ D] } d j |  ^ q^ f  qn  | j | |	 f  qWt% | d d   d t! } t& g  | D] \ } }	 | t k r| ^ q } | rN| rN| d d t k r%t j d | j j  n% t j d | j j | d d f  d  S| st j d | d	 j g  | D] \ } } }	 |	 ^ qm f  t d |   n  | d d t k rt j d | j j d	 j g  | d D] \ } }	 |	 ^ q pd f  d  St' |  d k rZt j d | d d d	 j g  | D] \ } }	 |	 ^ q7 f  n  | d d S(   Ni    c            s2   t  j |     } | j d  s. | d } n  | S(   Nt   /(   t	   posixpathR   t   endswith(   R.   t   loc(   t   url_name(    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   mkurl_pypi_urli   s    s#   URLs to search for versions for %s:s   * %ss   -fs   Analyzing links from page %si   s   dependency_links found: %ss   , s<   Could not find any downloads that satisfy the requirement %ss$   No distributions at all found for %st   reverses   Local files found: %ss-   Ignoring link %s, version %s doesn't match %st   ,t    t   keyc         S   s   t  j |  d  S(   Ni   (   t   pkg_resourcest   parse_version(   t   v(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   <lambda>   s    i   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)sN   Could not find a version that satisfies the requirement %s (from versions: %s)s,   No distributions matching the version for %ss=   Installed version (%s) is most up-to-date (past versions: %s)t   nones)   Using version %s (newest of versions: %s)((   R?   t   NoneR   t   LinkR<   R   t	   _get_paget   _find_url_nameR   R   t   listR%   R   t   absolute_versionsR.   R:   R    t   debugt   _package_versionst   namet   lowert
   _get_pagest   indentR&   R   t   fatalR   t   satisfied_byR,   t   parsed_versionR   t   versiont   sortt   TrueR   t   reqt   specst   sortedt   boolt   len(   R    R\   t   upgradet   main_index_urlt   paget   all_index_urlsR@   R.   R8   RY   t   file_locationst   url_locationst   locationt   found_versionst   page_versionst   dependency_versionst   parsedt   linkt   file_versionst   all_versionst   applicable_versionsRX   t   st   existing_applicable(    (   R?   s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   find_requirementY   s    		1	&#5)	4<	1%?	<1			3	@	;c         C   s   | j  j d  s$ | j  d 7_  n  |  j | |  } | d k rW t j d |  d St | j  } xY | j D]N } t	 j
 | j j d   } | t |  k rp t j d | | f  | Sqp 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(   R.   R=   RL   RJ   R    RV   R   R?   R&   R<   t   basenameR-   t   rstript   notify(   R    t	   index_urlR?   R\   Rc   t	   norm_nameRl   t   base(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyRM      s    c   
   	   C   s   t    } x | D] } | j |  q Wg  } t   } g  } xn t t d t |    D]Q } t j d |  j d | | | | f  }	 |	 j	 t
  | j |	  |	 j   qX Wx | D] }	 |	 j   q W| S(   s   Yields (page, page_url) from the given locations, skipping
        locations that have errors, and adding download/homepage linksi
   t   targett   args(   R   t   putR   t   ranget   minR`   t	   threadingt   Threadt   _get_queued_paget	   setDaemonR[   R,   t   startR   (
   R    R8   R\   t   pending_queueRg   t   donet   seent   threadst   it   t(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyRT      s    		"'c         C   s   x y | j  t  } Wn t k
 r* d  SX| | k r= q n  | j |  |  j | |  } | d  k rn q n  | j |  x! | j   D] } | j |  q Wq d  S(   N(	   t   getR+   t
   QueueEmptyt   addRL   RJ   R,   t	   rel_linksR{   (   R    R\   R   R   R   Rg   Rc   Rl   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR      s    s   #egg=([^&]*)s   ([a-z0-9_.]+)-([a-z0-9_.-]+)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(   sg   Returns elements of links in order, non-egg links first, egg links second, while eliminating duplicates(   R   R   t   egg_fragmentR,   (   R    R&   t   eggst   no_eggsR   Rl   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   _sort_links   s    		c         c   s@   x9 |  j  |  D]( } x |  j | |  D] } | Vq) Wq Wd  S(   N(   R   t   _link_package_versions(   R    R&   t   search_nameRl   RG   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyRQ     s    c         C   s  | j  r | j  } n | j   \ } } | sd | |  j k r` t j d |  |  j j |  n  g  S| j d  r | d  } d | } n  | d k r | |  j k r t j d | | f  |  j j |  n  g  S|  j | | |  } | d k rt j d	 | | f  g  S|  j	 j
 |  } | rq| | j    } | j d
  } | t j d  k rqt j d |  g  Sn  t j d | | f  t j |  | | f g S(   s   
        Return an iterable of triples (pkg_resources_version_key,
        link, python_version) that can be extracted from the given
        link.

        Meant to be overridden by subclasses, not called by clients.
        s   Skipping link %s; not a files   .taris   .tar.gzs   .tar.bz2s   .tgzs   .zips,   Skipping link %s; unknown archive format: %ss-   Skipping link %s; wrong project name (not %s)i   i   s/   Skipping %s because Python version is incorrects   Found link %s, version: %s(   s   .tar.gzs   .tar.bz2s   .tars   .tgzs   .zipN(   R   R   R   R    RP   R   R=   t   _egg_info_matchesRJ   t   _py_version_ret   searchR   t   groupt   sysRY   RE   RF   (   R    Rl   R   t   egg_infot   extRY   t   matcht
   py_version(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR     s>    	
c         C   s   |  j  j |  } | s- t j d |  d  S| j d  j   } | j d d  } | j | j    r | j d  t	 |  j
 d  Sd  Sd  S(   Ns%   Could not parse version from link: %si    t   _t   -(   t   _egg_info_reR   R    RP   RJ   R   RS   t   replaceR2   R`   t   lstrip(   R    R   R   Rl   R   RR   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   6  s     c         C   s   t  j | | d |  j S(   NR   (   t   HTMLPaget   get_pageR   (   R    Rl   R\   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyRL   C  s    c         C   s   | s" t  |  } t j |  n  t   } x\ | D]T } d pG d pG d | k r] d | } n  | j d  sy d | } n  | j |  q2 Wt |  S(   sq   Retrieves a list of URLs from the main mirror DNS entry
        unless a list of mirror URLs are passed.
        s   http://s   https://s   file://s	   http://%ss   /simples
   %s/simple/(   t   get_mirrorst   randomt   shuffleR   R=   R   RN   (   R    R"   R#   R   t
   mirror_url(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   F  s    	N(   t   __name__t
   __module__t   __doc__R+   RJ   R$   R'   t   staticmethodR:   Rr   RM   RT   R~   t   Lockt	   _log_lockR   t   ret   compilet   _egg_fragment_ret   IR   R   R   RQ   R   R   RL   R   (    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR      s$   		f						*		R   c           B   sV   e  Z d  Z d Z d   Z d   Z d   Z d   Z e d  Z	 d   Z
 d   Z RS(	   s   Cache of HTML pagesi   c         C   s   i  |  _  i  |  _ i  |  _ d  S(   N(   t	   _failurest   _pagest	   _archives(   R    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR$   `  s    		c         C   s   |  j  j | d  |  j k S(   Ni    (   R   R   t   failure_limit(   R    R.   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   too_many_failurese  s    c         C   s   |  j  j |  S(   N(   R   R   (   R    R.   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   h  s    c         C   s   |  j  j | t  S(   N(   R   R   R+   (   R    R.   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt
   is_archivek  s    c         C   s   | |  j  | <d  S(   N(   R   (   R    R.   t   value(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   set_is_archiven  s    c         C   s$   |  j  j | d  | |  j  | <d  S(   Ni    (   R   R   (   R    R.   t   level(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   add_page_failureq  s    c         C   s"   x | D] } | |  j  | <q Wd  S(   N(   R   (   R    R0   Rc   R.   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   add_paget  s    (   R   R   R   R   R$   R   R   R   R[   R   R   R   (    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   [  s   					R   c           B   s  e  Z d  Z e j d e j  Z e j d e j  Z e j d e j  Z e j d e j e j	 B Z
 e j d e j  Z d d  Z d   Z e d e d   Z e d	    Z e d
    Z e d    Z d   Z d d  Z d   Z e j d e j  Z d   Z RS(   s'   Represents one page, along with its URLs   <th>\s*home\s*pages   <th>\s*download\s+urls&   <[^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*>s(   href=(?:"([^"]*)"|'([^']*)'|([^>\s\n]*))s!   <base\s+href\s*=\s*['"]?([^'">]+)c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   contentR.   t   headers(   R    R   R.   R   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR$     s    		c         C   s   |  j  S(   N(   R.   (   R    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   __str__  s    c      
   C   s  | j  } | j d d  d } | j |  r2 d  Sd d l m } xT | j D]I } | j   j |  rL | t	 |  d k rL t
 j d t    d  SqL W| d  k	 r | j |  } | d  k	 r | Sn  y| r| d  k	 r | j |  r d  Sn  | j }	 x d d	 d
 d d g D]w }
 |	 j |
  r|  j |  } | j   j d  rNPqt
 j d | | f  | d  k	 r| j |  n  d  SqqWn  t
 j d |  t j |  \ } } } } } } | d k r't j j t |   r'| j d  s| d 7} n  t j | d  } t
 j d |  n  t |  } t |  } | j   } |  t | j    | |  } WnMt t t  j! t  j" t# t$ f k
 rt% j&   d } t' |  } t( | t  j!  rt
 j } d } d } n t( | t  r,t
 j } t) | d  r#t( | j* t  j!  r#d } d } qkd } n? t( | t  r\| j+ d k r\t
 j } d } n t
 j } d } | d | | f  | d | j  | f  | d  k	 r| j, | |  n  d  SX| d  k	 r| j- | | g |  n  | S(   Nt   #i   i    i(   t
   VcsSupports   +:s&   Cannot look at %(scheme)s URL %(link)ss   .tars   .tar.gzs   .tar.bz2s   .tgzs   .zips	   text/htmls,   Skipping page %s because of Content-Type: %ss   Getting page %st   fileR;   s
   index.htmls#    file: URL is directory, getting %ss	   timed outt   reasoni   i  s   Could not fetch URL %s: %ss7   Will skip URL %s when looking for download links for %s(.   R.   t   splitR   RJ   t   pip.vcsR   t   schemesRS   R2   R`   R    RP   t   localsR   R   t   filenameR=   t   _get_content_typeR   R   R3   R-   R4   R   t   urljoinR   R   R   R   t   readR
   R	   t   sockett   timeoutt   errort   OSErrorR   R   t   exc_infot   strt
   isinstancet   hasattrR   t   codeR   R   (   t   clsRl   R\   R   t   skip_archivesR.   R   t   schemet   instR   t   bad_extt   content_typet   netlocR-   t   paramst   queryt   fragmentt   respt   real_urlR   t   et   desct   log_methR   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR     s    	+	!$"%			$					c         C   s   t  j |   \ } } } } } | d k r. d St |  d i | d 6} t |  } zH t | d  r | j d	 k r | d k r d S| j   j d
 d  SWd | j   Xd S(   s;   Get the Content-Type of the given url, using a HEAD requestt   httpt   httpst   ftpt   ftpsRC   R   t   HostR   i   s   content-typeN(   R   R   R   R   (   R   R   (	   R   t   urlsplitR   R   R   R   R   R   t   close(   R.   R   R   R-   R   R   R\   R   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR     s    *c         C   sU   t  |  d  sN |  j j |  j  } | r? | j d  |  _ qN |  j |  _ n  |  j S(   Nt	   _base_urli   (   R   t   _base_reR   R   R   R   R.   (   R    R   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   base_url  s    c         c   s}   xv |  j  j |  j  D]_ } | j d  pF | j d  pF | j d  } |  j t j |  j |   } t | |   Vq Wd S(   s   Yields all links in the pagei   i   i   N(	   t   _href_ret   finditerR   R   t
   clean_linkR   R   R   RK   (   R    R   R.   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR&     s    -c         c   s<   x |  j    D] } | Vq Wx |  j   D] } | Vq) Wd  S(   N(   t   explicit_rel_linkst   scraped_rel_links(   R    R.   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR      s    	t   homepaget   downloadc         c   s   x |  j  j |  j  D] } | j d  j   j   } x! | D] } | | k r> Pq> q> Wq |  j j | j d   } | s q n  | j d  p | j d  p | j d  } |  j t	 j
 |  j |   } t | |   Vq Wd S(   s)   Yields all links with the given relationsi   i    i   i   N(   t   _rel_reR   R   R   RS   R   R   R   R   R   R   R   RK   (   R    t   relsR   t
   found_relst   relR.   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR     s    -c         c   s   x |  j  |  j f D] } | j |  j  } | s7 q n  |  j j |  j d | j   } | sd q n  | j d  p | j d  p | j d  } | s q n  |  j t j	 |  j
 |   } t | |   Vq Wd  S(   Nt   posi   i   i   (   t   _homepage_ret   _download_reR   R   R   t   endR   R   R   R   R   RK   (   R    t   regexR   t
   href_matchR.   (    (    s-   /usr/lib/python2.7/dist-packages/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-   /usr/lib/python2.7/dist-packages/pip/index.pyRH   +  s    (   t	   _clean_ret   sub(   R    R.   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   &  s    	N(   R   R   (   R   R   R   R   R   R   R   R   R   t   SR   R   RJ   R$   R   t   classmethodR[   R   R   R   t   propertyR   R&   R   R   R   R   R   (    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   y  s$   	O
		RK   c           B   s   e  Z d d   Z d   Z d   Z d   Z d   Z e d    Z	 e d    Z
 e d    Z d   Z e j d	  Z e d
    Z e j d  Z e d    Z e d    Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   R.   t
   comes_from(   R    R.   R  (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR$   0  s    	c         C   s(   |  j  r d |  j |  j  f S|  j Sd  S(   Ns   %s (from %s)(   R  R.   (   R    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   4  s    	c         C   s   d |  S(   Ns	   <Link %s>(    (   R    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   __repr__:  s    c         C   s   |  j  | j  k S(   N(   R.   (   R    t   other(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   __eq__=  s    c         C   s   t  |  j  S(   N(   t   hashR.   (   R    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   __hash__@  s    c         C   sj   |  j  } | j d d  d } | j d d  d } | j d  } t j |  } | sf t d |  | S(   NR   i   i    t   ?R;   s   URL %r produced no filename(   R.   R   Rt   R<   Rs   t   AssertionError(   R    R.   RR   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   C  s    		
c         C   s   t  j |  j  d S(   Ni    (   R   R   R.   (   R    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   N  s    c         C   s   t  j |  j  d S(   Ni   (   R   R   R.   (   R    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR-   R  s    c         C   s   t  t j |  j j d    S(   NR;   (   R   R<   Rs   R-   Rt   (   R    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   V  s    s   #egg=([^&]*)c         C   s,   |  j  j |  j  } | s d  S| j d  S(   Ni   (   R   R   R.   RJ   R   (   R    R   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR   [  s    s   md5=([a-f0-9]+)c         C   s,   |  j  j |  j  } | r( | j d  Sd  S(   Ni   (   t   _md5_reR   R.   R   RJ   (   R    R   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   md5_hashd  s    c         C   s0   t  j |  j j d d  d j d d  d  S(   NR   i   i    R
  (   R<   Rs   R.   R   (   R    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   show_urlk  s    N(   R   R   RJ   R$   R   R  R  R	  R  R   R   R-   R   R   R   R   R   R  R  R  (    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyRK   .  s   					c         C   s;   t  |   } | j } | s1 t | j  d } n  t |  S(   sP   Get a requirement from the URL, if possible.  This looks for #egg
    in the URLi    (   RK   R   R   R   t   package_to_requirement(   R.   Rl   R   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   get_requirement_from_urlp  s
    	c         C   sa   t  j d |   } | r9 | j d  } | j d  } n |  } d } | rY d | | f S| Sd S(   s)   Translate a name like Foo-1.2 to Foo==1.3s   ^(.*?)-(dev|\d.*)i   i   RC   s   %s==%sN(   R   R   R   (   t   package_nameR   RR   RY   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR  z  s    c         C   s   |  d k r t }  n  y t j |   d }  Wn t j k
 rC g  SX|  j d d  } g  t | d  D] } d | | d f ^ qg S(   s7  Return the list of mirrors from the last record found on the DNS
    entry::

    >>> from pip.index import get_mirrors
    >>> get_mirrors()
    ['a.pypi.python.org', 'b.pypi.python.org', 'c.pypi.python.org',
    'd.pypi.python.org']

    Originally written for the distutils2 project by Alexis Metaireau.
    i    t   .i   s   %s.%sN(   RJ   t   DEFAULT_MIRROR_URLR   t   gethostbyname_ext   gaierrorR   t   string_range(   t   hostnamet
   end_letterRp   (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR     s    	c         c   si   xb t  t |    D]N } xE t t j d | d D]* } d j |  } | V| |  k r3 d Sq3 Wq Wd S(   s   Compute the range of string between "a" and last.

    This works for simple "a to z" lists, but also for "a to zz" lists.
    t   repeati   RC   N(   R|   R`   R   t   stringt   ascii_lowercaseR   (   t   lastt   kt   xt   result(    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyR    s     (1   R   R   R3   R   R)   R~   R<   RE   R   R   R  t   pip.logR    t   pip.utilR   R   R   t   pip.exceptionsR   t   pip.backwardcompatR   R   R   R   R	   R
   R   R   R   R   R   t   pip.downloadR   R   R   R   R   t   __all__R  t   objectR   R   R   RK   R  R  RJ   R   R  (    (    (    s-   /usr/lib/python2.7/dist-packages/pip/index.pyt   <module>   s8   @(	 >B	
	