ó
^\kdc           @   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 m	 Z	 d d l
 m Z m Z m Z m Z 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 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' m( Z( m) Z) m* Z* m+ Z+ m, Z, m- Z- d d	 l m. Z. d d
 l/ m0 Z0 d d l1 m2 Z2 d d l3 m4 Z4 e j5 d ƒ Z6 e j5 d e j7 ƒ Z8 e j5 d ƒ Z9 e j5 d e j7 ƒ j: Z; d j< ƒ  Z= d d d d g Z> d Z? d „  Z@ d „  ZA eB d „ ZC eB d „ ZD eB d „ ZE eB e eB d „ ZF eB d „ ZG d „  ZH e j5 d e j7 ƒ ZI eH d  „  ƒ ZJ d! e jK d"  e d# ƒ d$ jK f ZL d% eM f d& „  ƒ  YZN d' eN f d( „  ƒ  YZO d e f d) „  ƒ  YZP e j5 d* ƒ jQ ZR d+ „  ZS d, „  ZT d- „  ZU d d. „ ZV d/ „  ZW d0 eM f d1 „  ƒ  YZX d2 e- j- f d3 „  ƒ  YZY e jZ d4 „ Z[ eV e? ƒ e[ ƒ Z[ d5 „  Z\ d6 „  Z] d S(7   s#   PyPI and direct package downloadingiÿÿÿÿN(   t   wraps(   t   CHECKOUT_DISTt   Distributiont   BINARY_DISTt   normalize_patht   SOURCE_DISTt   requiret   Environmentt   find_distributionst	   safe_namet   safe_versiont   to_filenamet   Requirementt   DEVELOP_DIST(   t   ssl_support(   t   log(   t   DistutilsError(   t   urllib2t   httplibt   StringIOt	   HTTPErrort   urlparset
   urlunparset   unquotet	   splitusert   url2pathnamet   name2codepointt   unichrt   urljoint   urlsplitt
   urlunsplitt   ConfigParser(   t   filterfalse(   t	   translate(   t   strip_fragment(   t   get_all_headerss   ^egg=([-A-Za-z0-9_.]+)$s   href\s*=\s*['"]?([^'"> ]+)s�   <a href="([^"#]+)">([^<]+)</a>
\s+\(<a (?:title="MD5 hash"
\s+)href="[^?]+\?:action=show_md5&amp;digest=([0-9a-f]{32})">md5</a>\)s   ([-+.a-z0-9]{2,}):s   .tar.gz .tar.bz2 .tar .zip .tgzt   PackageIndext   distros_for_urlt   parse_bdist_wininstt   interpret_distro_namei   c         C   sâ   |  j  ƒ  } d \ } } } | j d ƒ rÕ | j d ƒ rL |  d  } d } qÕ | j d d ƒ r~ |  d d !} |  d  } d } qÕ | j d	 ƒ r  |  d
  } d } qÕ | j d d ƒ rÕ |  d d !} |  d  } d } qÕ n  | | | f S(   s=   Return (base,pyversion) or (None,None) for possible .exe names   .exes
   .win32.exeiöÿÿÿt   win32s	   .win32-pyiðÿÿÿiùÿÿÿiüÿÿÿs   .win-amd64.exeiòÿÿÿs	   win-amd64s   .win-amd64-pyiìÿÿÿN(   NNN(   t   lowert   Nonet   endswitht
   startswith(   t   nameR)   t   baset   py_vert   plat(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR&   .   s$    
	
	
	
c         C   sœ   t  |  ƒ \ } } } } } } t | j d ƒ d ƒ } | d k rk | d k rk t | j d ƒ d ƒ } n  d | k r’ | j d d ƒ \ } } n  | | f S(   Nt   /iÿÿÿÿs   sourceforge.nett   downloadiþÿÿÿt   #i   (   R   R   t   split(   t   urlt   schemet   servert   patht
   parameterst   queryt   fragmentR.   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   egg_info_for_urlF   s     c         c   sŠ   t  |  ƒ \ } } x t |  | | ƒ D] } | Vq% W| r† t j | ƒ } | r† x1 t |  | j d ƒ | d t ƒD] } | Vqq Wq† n  d S(   sE   Yield egg or source distribution objects that might be found at a URLi   t
   precedenceN(   R<   t   distros_for_locationt   EGG_FRAGMENTt   matchR'   t   groupR   (   R5   t   metadataR.   R;   t   distR@   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR%   N   s     	"c         C   sÞ   | j  d ƒ r | d  } n  | j  d ƒ rM d | k rM t j |  | | ƒ g S| j  d ƒ r™ t | ƒ \ } } } | d k	 r™ t |  | | | t | ƒ Sn  x> t D]6 } | j  | ƒ r  | t | ƒ  } t |  | | ƒ Sq  Wg  S(   s:   Yield egg or source distribution objects based on basenames   .egg.zipiüÿÿÿs   .eggt   -s   .exeN(	   R+   R   t   from_locationR&   R*   R'   R   t
   EXTENSIONSt   len(   t   locationt   basenameRB   t   win_baseR/   t   platformt   ext(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR>   Z   s    c         C   s"   t  t |  ƒ t j j |  ƒ | ƒ S(   sE   Yield possible egg or source distribution objects based on a filename(   R>   R   t   osR8   RI   (   t   filenameRB   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   distros_for_filenameo   s    c   	      c   sÆ   | j  d ƒ } | s^ xF t | d ƒ D]1 \ } } t | ƒ d k r& | j d ƒ r& d Sq& Wn  xa t d t | ƒ d ƒ D]F } t |  | d j | |  ƒ d j | | ƒ d | d | d	 | ƒVqx Wd S(
   sØ   Generate alternative interpretations of a source distro name

    Note: if `location` is a filesystem filename, you should call
    ``pkg_resources.normalize_path()`` on it before passing it to this
    routine!
    RD   i   i   s   py2.Ni   t
   py_versionR=   RK   (   R4   t	   enumerateRG   R,   t   rangeR   t   join(	   RH   RI   RB   RP   R=   RK   t   partst   it   p(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR'   v   s    ! )c         c   sŒ   t  ƒ  } | j } | d k rM xg t | j |  ƒ D] } | | ƒ | Vq1 Wn; x8 |  D]0 } | | ƒ } | | k rT | | ƒ | VqT qT Wd S(   sH   List unique elements, preserving order. Remember all elements ever seen.N(   t   sett   addR*   R    t   __contains__(   t   iterablet   keyt   seent   seen_addt   elementt   k(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   unique_everseenš   s    		

c            s   t  ˆ  ƒ ‡  f d †  ƒ } | S(   ss   
    Wrap a function returning an iterable such that the resulting iterable
    only ever yields unique items.
    c             s   t  ˆ  |  | Ž  ƒ S(   N(   R`   (   t   argst   kwargs(   t   func(    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   wrapper°   s    (   R    (   Rc   Rd   (    (   Rc   sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   unique_values«   s    s(   <([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>c         c   s  x¢ t  j | ƒ D]‘ } | j ƒ  \ } } t t t j | j ƒ  j d ƒ ƒ ƒ } d | k sg d | k r x7 t	 j | ƒ D]# } t
 |  t | j d ƒ ƒ ƒ Vqw Wq q Wxd d	 D]\ } | j | ƒ } | d k r¬ t	 j | | ƒ } | rt
 |  t | j d ƒ ƒ ƒ Vqq¬ q¬ Wd S(
   sE   Find rel="homepage" and rel="download" links in `page`, yielding URLst   ,t   homepageR2   i   s   <th>Home Pages   <th>Download URLiÿÿÿÿN(   s   <th>Home Pages   <th>Download URL(   t   RELt   finditert   groupsRW   t   mapt   strt   stripR)   R4   t   HREFR   t
   htmldecodeRA   t   findt   search(   R5   t   pageR@   t   tagt   relt   relst   pos(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   find_external_links¸   s    '(s   Python-urllib/%s setuptools/%si   t
   setuptoolsi    t   ContentCheckerc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sP   
    A null content checker that defines the interface for checking content
    c         C   s   d S(   s3   
        Feed a block of data to the hash.
        N(    (   t   selft   block(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   feedÒ   s    c         C   s   t  S(   sC   
        Check the hash. Return False if validation fails.
        (   t   True(   Rz   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   is_validØ   s    c         C   s   d S(   su   
        Call reporter with information about the checker (hash name)
        substituted into the template.
        N(    (   Rz   t   reportert   template(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   reportÞ   s    (   t   __name__t
   __module__t   __doc__R|   R~   R�   (    (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRy   Î   s   		t   HashCheckerc           B   sJ   e  Z e j d  ƒ Z d „  Z e d „  ƒ Z d „  Z d „  Z	 d „  Z
 RS(   sK   (?P<hash_name>sha1|sha224|sha384|sha256|sha512|md5)=(?P<expected>[a-f0-9]+)c         C   s(   | |  _  t j | ƒ |  _ | |  _ d  S(   N(   t	   hash_namet   hashlibt   newt   hasht   expected(   Rz   R†   RŠ   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   __init__ë   s    	c         C   sL   t  | ƒ d } | s t ƒ  S|  j j | ƒ } | s< t ƒ  S|  | j ƒ  �  S(   s5   Construct a (possibly null) ContentChecker from a URLiÿÿÿÿ(   R   Ry   t   patternRq   t	   groupdict(   t   clsR5   R;   R@   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   from_urlð   s    c         C   s   |  j  j | ƒ d  S(   N(   R‰   t   update(   Rz   R{   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR|   û   s    c         C   s   |  j  j ƒ  |  j k S(   N(   R‰   t	   hexdigestRŠ   (   Rz   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR~   þ   s    c         C   s   | |  j  } | | ƒ S(   N(   R†   (   Rz   R   R€   t   msg(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR�     s    (   R‚   Rƒ   t   ret   compileRŒ   R‹   t   classmethodR�   R|   R~   R�   (    (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR…   å   s   				c           B   sv  e  Z d  Z d d% d& e d „ Z e d „ Z e d „ Z e d „ Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d& d „ Z d „  Z d& d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z e e e d& d „ Z e e d „ Z d „  Z d Z d „  Z d „  Z d& d „ Z d „  Z d „  Z d „  Z d „  Z  d „  Z! e" e d „ ƒ Z# d  „  Z$ d! „  Z% d" „  Z& d# „  Z' d$ „  Z( RS('   s;   A distribution index that scans web pages for download URLss   https://pypi.python.org/simplet   *c         O   s¿   t  j |  | | Ž | d | j d ƒ  |  _ i  |  _ i  |  _ i  |  _ t j d j	 t
 t | ƒ ƒ ƒ j |  _ g  |  _ | r¯ t j r¯ | sš t j ƒ  r¯ t j | ƒ |  _ n t j |  _ d  S(   NR1   t   |(   R   R‹   R+   t	   index_urlt   scanned_urlst   fetched_urlst   package_pagesR“   R”   RS   Rk   R!   R@   t   allowst   to_scanR   t   is_availablet   find_ca_bundlet
   opener_fort   openerR   t   urlopen(   Rz   R˜   t   hostst	   ca_bundlet
   verify_sslRa   t   kw(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR‹   	  s    			'	!c   
   
   C   sU  | |  j  k r | r d St |  j  | <t | ƒ sD |  j | ƒ d St t | ƒ ƒ } | r‚ |  j | ƒ so d S|  j d | ƒ n  | sž | sž | |  j k r¸ t t	 |  j
 | ƒ ƒ d S|  j | ƒ sØ t |  j | <d S|  j d | ƒ t |  j | <|  j | d | ƒ } | d k rd St |  j | j <d | j j d d ƒ j ƒ  k rZ| j ƒ  d S| j } | j ƒ  } t | t ƒ sÃt | t ƒ r–d } n | j j d	 ƒ p«d } | j | d
 ƒ } n  | j ƒ  xB t j | ƒ D]1 } t | t | j d ƒ ƒ ƒ }	 |  j |	 ƒ qÝW| j |  j  ƒ rQt! | d d ƒ d k rQ|  j" | | ƒ } n  d S(   s<   Evaluate a URL as a possible download, and maybe retrieve itNs   Found link: %ss
   Reading %ss<   Download error on %s: %%s -- Some packages may not be found!t   htmls   content-typet    s   latin-1t   charsett   ignorei   t   codei”  (#   R™   R}   t
   URL_SCHEMEt   process_filenamet   listR%   t   url_okt   debugRš   Rk   RX   t   infot   open_urlR*   R5   t   headerst   getR)   t   closet   readt
   isinstanceRl   R   t	   get_paramt   decodeRn   Ri   R   Ro   RA   t   process_urlR,   R˜   t   getattrt   process_index(
   Rz   R5   t   retrievet   distst   fR.   Rr   R©   R@   t   link(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRº     sN     !
		
*c         C   sÌ   t  j j | ƒ s& |  j d | ƒ d  St  j j | ƒ r� | r� t  j j | ƒ } x9 t  j | ƒ D]% } |  j t  j j | | ƒ t	 ƒ qa Wn  t
 | ƒ } | rÈ |  j d | ƒ t t |  j | ƒ ƒ n  d  S(   Ns   Not found: %ss	   Found: %s(   RM   R8   t   existst   warnt   isdirt   realpatht   listdirR­   RS   R}   RO   R°   R®   Rk   RX   (   Rz   t   fnt   nestedR8   t   itemR¾   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR­   H  s    &c         C   s}   t  | ƒ } | r- | j d ƒ j ƒ  d k sF |  j t | ƒ d ƒ rJ t Sd } | ri t | | ƒ ‚ n |  j | | ƒ d  S(   Ni   t   filesN   
Note: Bypassing %s (disallowed host; see http://bit.ly/1dg9ijs for details).
(   R¬   RA   R)   Rœ   R   R}   R   RÂ   (   Rz   R5   t   fatalt   sR’   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR¯   X  s    :c         C   sf   x_ | D]W } t  j j | ƒ r x< t  j | ƒ D]( } | j d ƒ r/ |  j | | ƒ q/ q/ Wq q Wd  S(   Ns	   .egg-link(   RM   R8   RÃ   RÅ   R+   t   scan_egg_link(   Rz   t   search_pathRÈ   t   entry(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   scan_egg_linksc  s
    c         C   s±   g  t  t j t t j j | | ƒ ƒ ƒ D] } | r( | ^ q( } t | ƒ d k r­ xX t t j j | | d ƒ ƒ D]4 } t j j | | Œ | _	 t
 | _ |  j | ƒ qr Wn  d  S(   Ni   i    (   Rk   Rl   Rm   t   openRM   R8   RS   RG   R   RH   R   R=   RX   (   Rz   R8   RÎ   t   _ft   linesRC   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRÌ   j  s    4&	c   
         s  ‡  f d †  } xQ t  j | ƒ D]@ } y& | t | t | j d ƒ ƒ ƒ ƒ Wq t k
 r^ q Xq W| | ƒ \ } } | r
xy t | | ƒ D]h } t | ƒ \ } }	 | j d ƒ ræ |	 ræ | rÖ | d | | f 7} qæ ˆ  j	 | ƒ n  ˆ  j
 | ƒ q‹ Wt j d „  | ƒ Sd Sd S(   s#   Process the contents of a PyPI pagec            s»   |  j  ˆ  j ƒ r· t t t |  t ˆ  j ƒ j d ƒ ƒ ƒ } t | ƒ d k r· d | d k r· t | d ƒ } t | d ƒ } t	 ˆ  j
 j | j ƒ  i  ƒ |  <t | ƒ t | ƒ f Sn  d S(   NR1   i   R3   i   i    (   NN(   R,   R˜   R®   Rk   R   RG   R4   R	   R
   R}   R›   t
   setdefaultR)   R   R*   (   RÀ   RT   t   pkgt   ver(   Rz   (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   scanu  s    %"i   s   .pys
   #egg=%s-%sc         S   s   d |  j  d d d ƒ S(   Ns   <a href="%s#md5=%s">%s</a>i   i   i   (   RA   (   t   m(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   <lambda>˜  s    R¨   N(   Rn   Ri   R   Ro   RA   t
   ValueErrorRw   R<   R+   t   need_version_infot   scan_urlt   PYPI_MD5t   sub(
   Rz   R5   Rr   RÖ   R@   RÔ   RÕ   t   new_urlR.   t   frag(    (   Rz   sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR¼   s  s$    &c         C   s   |  j  d | ƒ d  S(   NsP   Page at %s links to .py file(s) without version info; an index scan is required.(   t   scan_all(   Rz   R5   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRÚ   �  s    c         G   sO   |  j  |  j k r; | r+ |  j | | Œ n  |  j d ƒ n  |  j |  j  ƒ d  S(   Ns6   Scanning index of all packages (this may take a while)(   R˜   Rš   RÂ   R±   RÛ   (   Rz   R’   Ra   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRà   £  s     
c         C   s­   |  j  |  j | j d ƒ |  j j | j ƒ sN |  j  |  j | j d ƒ n  |  j j | j ƒ ss |  j | ƒ n  x3 t |  j j | j d ƒ ƒ D] } |  j  | ƒ q’ Wd  S(   NR1   (    (	   RÛ   R˜   t   unsafe_nameR›   R´   R[   t   project_namet   not_found_in_indexR®   (   Rz   t   requirementR5   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   find_packages«  s    %c         C   sk   |  j  ƒ  |  j | ƒ x8 |  | j D]) } | | k r; | S|  j d | | ƒ q% Wt t |  ƒ j | | ƒ S(   Ns   %s does not match %s(   t   prescanRå   R[   R°   t   superR$   t   obtain(   Rz   Rä   t	   installerRC   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRè   º  s    
c         C   si   | j  |  j d | ƒ | j ƒ  se | j ƒ  t j | ƒ t d | j j t j	 j
 | ƒ f ƒ ‚ n  d S(   s-   
        checker is a ContentChecker
        s   Validating %%s checksum for %ss7   %s validation failed for %s; possible download problem?N(   R�   R°   R~   Rµ   RM   t   unlinkR   R‰   R-   R8   RI   (   Rz   t   checkerRN   t   tfp(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt
   check_hashÃ  s    
c         C   sr   xk | D]c } |  j  d k sJ t | ƒ sJ | j d ƒ sJ t t | ƒ ƒ rZ |  j | ƒ q |  j  j | ƒ q Wd S(   s;   Add `urls` to the list that will be prescanned for searchess   file:N(   R�   R*   R¬   R,   R®   R%   RÛ   t   append(   Rz   t   urlsR5   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   add_find_linksÒ  s    c         C   s2   |  j  r% t t |  j |  j  ƒ ƒ n  d |  _  d S(   s7   Scan urls scheduled for prescanning (e.g. --find-links)N(   R�   R®   Rk   RÛ   R*   (   Rz   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRæ   á  s    	c         C   sN   |  | j  r  |  j d } } n |  j d } } | | | j ƒ |  j ƒ  d  S(   Ns#   Couldn't retrieve index page for %rs3   Couldn't find index page for %r (maybe misspelled?)(   R[   R±   RÂ   Rá   Rà   (   Rz   Rä   t   methR’   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRã   ç  s    
c         C   së   t  | t ƒ sÏ t | ƒ } | r| |  j | j d ƒ | | ƒ } t | ƒ \ } } | j d ƒ rx |  j | | | ƒ } n  | St j	 j
 | ƒ r’ | Sy t j | ƒ } WqÏ t k
 rË t d | f ƒ ‚ qÏ Xn  t |  j | | ƒ d d ƒ S(   s  Locate and/or download `spec` to `tmpdir`, returning a local path

        `spec` may be a ``Requirement`` object, or a string containing a URL,
        an existing local filename, or a project/version requirement spec
        (i.e. the string form of a ``Requirement`` object).  If it is the URL
        of a .py file with an unambiguous ``#egg=name-version`` tag (i.e., one
        that escapes ``-`` as ``_`` throughout), a trivial ``setup.py`` is
        automatically created alongside the downloaded file.

        If `spec` is a ``Requirement`` object or a string containing a
        project/version requirement spec, this method returns the location of
        a matching distribution (possibly after downloading it to `tmpdir`).
        If `spec` is a locally existing file or directory name, it is simply
        returned unchanged.  If `spec` is a URL, it is downloaded to a subpath
        of `tmpdir`, and the local filename is returned.  Various errors may be
        raised if a problem occurs during downloading.
        i   s   .pys1   Not a URL, existing file, or requirement spec: %rRH   N(   R·   R   R¬   t   _download_urlRA   R<   R+   t	   gen_setupRM   R8   RÁ   t   parseRÙ   R   R»   t   fetch_distributionR*   (   Rz   t   spect   tmpdirR6   t   foundR.   R;   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR2   ð  s"    c   	         sN  ˆ j  d | ƒ i  ‰ d } d ‡  ‡ ‡ ‡ f d † } | rc ˆ j ƒ  ˆ j | ƒ | | ƒ } n  | d k	 r‡ | p� | | | ƒ } n  | d k r¾ ˆ j d k	 r¯ ˆ j ƒ  n  | | ƒ } n  | d k rí | rí ˆ j | ƒ | | ƒ } n  | d k rˆ j d ˆ rd pd | ƒ n/ ˆ j  d | ƒ | j d ˆ j | j | ƒ ƒ Sd S(	   s|  Obtain a distribution suitable for fulfilling `requirement`

        `requirement` must be a ``pkg_resources.Requirement`` instance.
        If necessary, or if the `force_scan` flag is set, the requirement is
        searched for in the (online) package index as well as the locally
        installed packages.  If a distribution matching `requirement` is found,
        the returned distribution's ``location`` is the value you would have
        gotten from calling the ``download()`` method with the matching
        distribution's URL or filename.  If no matching distribution is found,
        ``None`` is returned.

        If the `source` flag is set, only source distributions and source
        checkout links will be considered.  Unless the `develop_ok` flag is
        set, development and system eggs (i.e., those using the ``.egg-info``
        format) will be ignored.
        s   Searching for %sc            sœ   | d  k r ˆ } n  x€ | |  j D]q } | j t k rn ˆ  rn | ˆ k r# ˆ j d | ƒ d ˆ | <q# q# n  | |  k r# | j t k s� ˆ r# | Sq# Wd  S(   Ns&   Skipping development or system egg: %si   (   R*   R[   R=   R   RÂ   R   (   t   reqt   envRC   (   t
   develop_okRz   t   skippedt   source(    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRp   1  s    	"s2   No local packages or download links found for %s%ss   a source distribution of R¨   s   Best match: %sRH   N(	   R±   R*   Ræ   Rå   R�   RÂ   t   cloneR2   RH   (	   Rz   Rä   R÷   t
   force_scanRý   Rû   t   local_indexRC   Rp   (    (   Rû   Rz   Rü   Rý   sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRõ     s0    

c         C   s/   |  j  | | | | ƒ } | d k	 r+ | j Sd S(   s3  Obtain a file suitable for fulfilling `requirement`

        DEPRECATED; use the ``fetch_distribution()`` method now instead.  For
        backward compatibility, this routine is identical but returns the
        ``location`` of the downloaded distribution instead of a distribution
        object.
        N(   Rõ   R*   RH   (   Rz   Rä   R÷   Rÿ   Rý   RC   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   fetch\  s    c         C   sq  t  j | ƒ } | rL g  t | | j d ƒ d  ƒ D] } | j r1 | ^ q1 pO g  } t | ƒ d k rBt j j	 | ƒ } t j j
 | ƒ | k rÞ t j j | | ƒ } d d l m }	 |	 | | ƒ sÞ t j | | ƒ | } qÞ n  t t j j | d ƒ d ƒ }
 |
 j d | d j | d j t j j | ƒ d f ƒ |
 j ƒ  | S| rat d | | f ƒ ‚ n t d	 ƒ ‚ d  S(
   Ni   iÿÿÿÿ(   t   samefiles   setup.pyt   wsI   from setuptools import setup
setup(name=%r, version=%r, py_modules=[%r])
i    s†   Can't unambiguously interpret project/version identifier %r; any dashes in the name or version should be escaped using underscores. %rsp   Can't process plain .py files without an '#egg=name-version' suffix to enable automatic setup script generation.(   R?   R@   R'   RA   R*   t   versionRG   RM   R8   RI   t   dirnameRS   t   setuptools.command.easy_installR  t   shutilt   copy2RÐ   t   writeRâ   t   splitextRµ   R   (   Rz   RN   R;   R÷   R@   t   dR¾   RI   t   dstR  RÉ   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRó   i  s4    4
i    c         C   sœ  |  j  d | ƒ d	 \ } } } zOt j | ƒ } |  j t | ƒ ƒ } t | t ƒ rw t d | | j	 | j
 f ƒ ‚ n  | j  ƒ  } d } |  j }	 d }
 d | k rä t | d ƒ } t t t | ƒ ƒ }
 |  j | | | |	 |
 ƒ n  t | d ƒ } x` t rU| j |	 ƒ } | rQ| j | ƒ | j | ƒ | d 7} |  j | | | |	 |
 ƒ qö Pqö W|  j | | | ƒ | SWd  | r„| j ƒ  n  | r—| j ƒ  n  Xd  S(
   Ns   Downloading %ss   Can't download %s: %s %si    iÿÿÿÿs   content-lengths   Content-Lengtht   wbi   (   NNN(   R±   R*   R…   R�   R²   R"   R·   R   R   R«   R’   t   dl_blocksizeR#   t   maxRk   t   intt
   reporthookRÐ   R}   R¶   R|   R	  Rí   Rµ   (   Rz   R5   RN   t   fpRì   R±   Rë   R³   t   blocknumt   bst   sizet   sizesR{   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   _download_to”  s>    		
  c         C   s   d  S(   N(    (   Rz   R5   RN   R  t   blksizeR  (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR  ¸  s    c         C   sÞ  | j  d ƒ r t | ƒ Sy t | |  j ƒ SWnªt t j f k
 r³ t j ƒ  d } d j	 g  | j
 D] } t | ƒ ^ qf ƒ } | rš |  j | | ƒ qÚt d | | f ƒ ‚ n't j k
 r× t j ƒ  d } | St j k
 r/t j ƒ  d } | r|  j | | j ƒ qÚt d | | j f ƒ ‚ n« t j k
 r‡t j ƒ  d } | rk|  j | | j ƒ qÚt d | | j f ƒ ‚ nS t j k
 rÙt j ƒ  d } | rÀ|  j | | ƒ qÚt d | | f ƒ ‚ n Xd  S(   Ns   file:i   t    s   %s %ss   Download error for %s: %ss;   %s returned a bad status line. The server might be down, %s(   R,   t
   local_opent   open_with_authR¡   RÙ   R   t
   InvalidURLt   syst   exc_infoRS   Ra   Rl   RÂ   R   R   R   t   URLErrort   reasont   BadStatusLinet   linet   HTTPException(   Rz   R5   t   warningt   vt   argR’   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR²   »  s@    
+c         C   s<  t  | ƒ \ } } | rL x7 d | k rH | j d d ƒ j d d ƒ } q Wn d } | j d ƒ rn | d  } n  t j j | | ƒ } | d k sž | j d	 ƒ r® |  j | | ƒ S| d
 k sÉ | j d ƒ rÙ |  j | | ƒ S| j d ƒ rø |  j	 | | ƒ S| d k rt
 t | ƒ d ƒ S|  j | t ƒ |  j | | ƒ Sd  S(   Ns   ..t   .s   \t   _t   __downloaded__s   .egg.zipiüÿÿÿt   svns   svn+t   gits   git+s   hg+RÉ   i   (   R<   t   replaceR+   RM   R8   RS   R,   t   _download_svnt   _download_gitt   _download_hgR   R   R¯   R}   t   _attempt_download(   Rz   R6   R5   R÷   R-   R;   RN   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRò   ã  s$    %c         C   s   |  j  | t ƒ d  S(   N(   Rº   R}   (   Rz   R5   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRÛ      s    c         C   sK   |  j  | | ƒ } d | j d d ƒ j ƒ  k rC |  j | | | ƒ S| Sd  S(   NR§   s   content-typeR¨   (   R  R´   R)   t   _download_html(   Rz   R5   RN   R³   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR0    s    c         C   s‘   t  | ƒ } xW | D]O } | j ƒ  r t j d | ƒ r^ | j ƒ  t j | ƒ |  j | | ƒ SPq q W| j ƒ  t j | ƒ t d | ƒ ‚ d  S(   Ns    <title>([^- ]+ - )?Revision \d+:s   Unexpected HTML page found at (	   RÐ   Rm   R“   Rq   Rµ   RM   Rê   R-  R   (   Rz   R5   R³   RN   RÉ   R"  (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR1  
  s    

c      
   C   sT  | j  d d ƒ d } d } | j ƒ  j d ƒ r#d | k r#t | ƒ \ } } } } } }	 | r#| j d ƒ r#d | d	 k r#| d	 j  d d ƒ \ } } t | ƒ \ }
 } |
 r d
 |
 k rì |
 j  d
 d ƒ \ } } d | | f } n
 d |
 } | } t | | | | | |	 f ƒ } q q#n  |  j d | | ƒ t j d | | | f ƒ | S(   NR3   i   i    R¨   s   svn:t   @s   //R1   i   t   :s    --username=%s --password=%ss    --username=s'   Doing subversion checkout from %s to %ss   svn checkout%s -q %s %s(	   R4   R)   R,   R   R   R   R±   RM   t   system(   Rz   R5   RN   t   credsR6   t   netlocR8   RV   t   qR¿   t   autht   hostt   usert   pw(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR-    s"    !&
'c         C   s™   t  |  ƒ \ } } } } } | j d d ƒ d } | j d d ƒ d } d  } d | k rt | j d d ƒ \ } } n  t | | | | d f ƒ }  |  | f S(   Nt   +i   iÿÿÿÿR3   i    R2  R¨   (   R   R4   R*   t   rsplitR   (   R5   t
   pop_prefixR6   R6  R8   R:   Rß   t   rev(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   _vcs_split_rev_from_url-  s    c         C   s•   | j  d d ƒ d } |  j | d t ƒ\ } } |  j d | | ƒ t j d | | f ƒ | d  k	 r‘ |  j d | ƒ t j d | | f ƒ n  | S(	   NR3   i   i    R>  s   Doing git clone from %s to %ss   git clone --quiet %s %ss   Checking out %ss"   (cd %s && git checkout --quiet %s)(   R4   R@  R}   R±   RM   R4  R*   (   Rz   R5   RN   R?  (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR.  ?  s    	c         C   s•   | j  d d ƒ d } |  j | d t ƒ\ } } |  j d | | ƒ t j d | | f ƒ | d  k	 r‘ |  j d | ƒ t j d | | f ƒ n  | S(	   NR3   i   i    R>  s   Doing hg clone from %s to %ss   hg clone --quiet %s %ss   Updating to %ss   (cd %s && hg up -C -r %s >&-)(   R4   R@  R}   R±   RM   R4  R*   (   Rz   R5   RN   R?  (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR/  O  s    	c         G   s   t  j | | Œ d  S(   N(   R   R°   (   Rz   R’   Ra   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR°   _  s    c         G   s   t  j | | Œ d  S(   N(   R   R±   (   Rz   R’   Ra   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR±   b  s    c         G   s   t  j | | Œ d  S(   N(   R   RÂ   (   Rz   R’   Ra   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRÂ   e  s    (   R–   N()   R‚   Rƒ   R„   R*   R}   R‹   t   FalseRº   R­   R¯   RÏ   RÌ   R¼   RÚ   Rà   Rå   Rè   Rí   Rð   Ræ   Rã   R2   Rõ   R  Ró   R  R  R  R²   Rò   RÛ   R0  R1  R-  t   staticmethodR@  R.  R/  R°   R±   RÂ   (    (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR$     sL   0				*									)B	*	$	(									s!   &(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?c         C   s3   t  |  t ƒ s |  S|  d k r) t |  ƒ St |  ƒ S(   Niÿ   (   R·   R  R   t   chr(   t   c(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   uchrl  s
     
c         C   s{   |  j  d ƒ } | j d ƒ r4 t | d d ƒ } n= | j d ƒ rV t | d ƒ } n t j | |  j  d ƒ ƒ } t | ƒ S(   Ni   s   #xi   i   R3   i    (   RA   R,   R  R   R´   RE  (   R@   t   what(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   decode_entityr  s    c         C   s   t  t |  ƒ S(   s'   Decode HTML entities in the given text.(   t
   entity_subRG  (   t   text(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRo   |  s    c            s   ‡  f d †  } | S(   Nc            s   ‡  ‡ f d †  } | S(   Nc             s?   t  j ƒ  } t  j ˆ ƒ z ˆ  |  | Ž  SWd  t  j | ƒ Xd  S(   N(   t   sockett   getdefaulttimeoutt   setdefaulttimeout(   Ra   Rb   t   old_timeout(   Rc   t   timeout(    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   _socket_timeout‚  s
    (    (   Rc   RO  (   RN  (   Rc   sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRO  �  s    (    (   RN  RO  (    (   RN  sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   socket_timeout€  s    	c         C   sC   t  |  ƒ } | j ƒ  } t j | ƒ } | j ƒ  } | j d d ƒ S(   sq  
    A function compatible with Python 2.3-3.3 that will encode
    auth from a URL suitable for an HTTP header.
    >>> str(_encode_auth('username%3Apassword'))
    'dXNlcm5hbWU6cGFzc3dvcmQ='

    Long auth strings should not cause a newline to be inserted.
    >>> long_auth = 'username:' + 'password'*10
    >>> chr(10) in str(_encode_auth(long_auth))
    False
    s   
R¨   (   R   t   encodet   base64t   encodestringR¹   R,  (   R8  t   auth_st
   auth_bytest   encoded_bytest   encoded(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   _encode_authŒ  s
    t
   Credentialc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s:   
    A username/password pair. Use like a namedtuple.
    c         C   s   | |  _  | |  _ d  S(   N(   t   usernamet   password(   Rz   RZ  R[  (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR‹   ¦  s    	c         c   s   |  j  V|  j Vd  S(   N(   RZ  R[  (   Rz   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   __iter__ª  s    c         C   s   d t  |  ƒ S(   Ns   %(username)s:%(password)s(   t   vars(   Rz   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   __str__®  s    (   R‚   Rƒ   R„   R‹   R\  R^  (    (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRY  ¢  s   		t
   PyPIConfigc           B   s2   e  Z d  „  Z e d „  ƒ Z d „  Z d „  Z RS(   c         C   su   t  j d d d g d ƒ } t j j |  | ƒ t j j t j j d ƒ d ƒ } t j j | ƒ rq |  j	 | ƒ n  d S(   s%   
        Load from ~/.pypirc
        RZ  R[  t
   repositoryR¨   t   ~s   .pypircN(
   t   dictt   fromkeysR   R‹   RM   R8   RS   t
   expanduserRÁ   R¶   (   Rz   t   defaultst   rc(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR‹   ³  s
    !c         C   sM   g  |  j  ƒ  D]$ } |  j | d ƒ j ƒ  r | ^ q } t t |  j | ƒ ƒ S(   NR`  (   t   sectionsR´   Rm   Rb  Rk   t   _get_repo_cred(   Rz   t   sectiont   sections_with_repositories(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   creds_by_repository¾  s    $c         C   sO   |  j  | d ƒ j ƒ  } | t |  j  | d ƒ j ƒ  |  j  | d ƒ j ƒ  ƒ f S(   NR`  RZ  R[  (   R´   Rm   RY  (   Rz   Ri  t   repo(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyRh  Ç  s    c         C   s7   x0 |  j  j ƒ  D] \ } } | j | ƒ r | Sq Wd S(   sŒ   
        If the URL indicated appears to be a repository defined in this
        config, return the credential for that repository.
        N(   Rk  t   itemsR,   (   Rz   R5   R`  t   cred(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   find_credentialÎ  s    (   R‚   Rƒ   R‹   t   propertyRk  Rh  Ro  (    (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR_  ±  s   			c         C   s¡  t  |  ƒ \ } } } } } } | j d ƒ r? t j d ƒ ‚ n  | d	 k r` t | ƒ \ } }	 n d
 } | s¶ t ƒ  j |  ƒ }
 |
 r¶ t |
 ƒ } |
 j	 |  f } t
 j d | ƒ q¶ n  | rd t | ƒ } t | |	 | | | | f ƒ } t j | ƒ } | j d | ƒ n t j |  ƒ } | j d t ƒ | | ƒ } | r�t  | j ƒ \ } } } } } } | | k r�| |	 k r�t | | | | | | f ƒ | _ q�n  | S(   s4   Open a urllib2 request, handling HTTP authenticationR3  s   nonnumeric port: ''t   httpt   httpss*   Authenticating as %s for %s (from .pypirc)s   Basic t   Authorizations
   User-Agent(   s   https   httpsN(   R   R+   R   R  R   R*   R_  Ro  Rl   RZ  R   R±   RX  R   R   t   Requestt
   add_headert
   user_agentR5   (   R5   R¡   R6   R6  R8   t   paramsR:   Rß   R8  R9  Rn  R±   RÞ   t   requestR  t   s2t   h2t   path2t   param2t   query2t   frag2(    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR  Ø  s2    !'c         C   s   |  S(   N(    (   R5   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt
   fix_sf_url  s    c         C   su  t  |  ƒ \ } } } } } } t | ƒ } t j j | ƒ rI t j |  ƒ S| j d ƒ r=t j j | ƒ r=g  } x» t j	 | ƒ D]� }	 |	 d k rÊ t
 t j j | |	 ƒ d ƒ }
 |
 j ƒ  } |
 j ƒ  Pn. t j j t j j | |	 ƒ ƒ rø |	 d 7}	 n  | j d |	 |	 f ƒ q€ Wd |  d d j | ƒ } d \ } } n d \ } } } i d d 6} t |  | | | t | ƒ ƒ S(   s7   Read a local path, with special support for directoriesR1   s
   index.htmlt   rs   <a href=%r>%s</a>s   <html><head><title>%s</title>s   </head><body>%s</body></html>s   
iÈ   t   OKi”  s   Path not founds	   Not founds	   text/htmls   content-type(   iÈ   s   OK(   i”  s   Path not founds	   Not found(   R   R   RM   R8   t   isfileR   R¢   R+   RÃ   RÅ   RÐ   RS   R¶   Rµ   Rî   R   R   (   R5   R6   R7   R8   t   paramR:   Rß   RN   t   filesR¿   R  t   bodyt   statust   messageR³   (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyR  	  s*    !
!(^   R„   R  RM   R“   R  RJ  RR  R‡   t	   functoolsR    t   pkg_resourcesR   R   R   R   R   R   R   R   R	   R
   R   R   R   Rx   R   t	   distutilsR   t   distutils.errorsR   t   setuptools.compatR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R    t   fnmatchR!   t   setuptools.py26compatR"   t   setuptools.py27compatR#   R”   R?   t   IRn   RÜ   R@   R¬   R4   RF   t   __all__t   _SOCKET_TIMEOUTR&   R<   R*   R%   R>   RO   R'   R`   Re   Rh   Rw   R  Rv  t   objectRy   R…   R$   RÝ   RH  RE  RG  Ro   RP  RX  RY  R_  R¢   R  R  R  (    (    (    sF   /var/www/testScraper/venv/build/setuptools/setuptools/package_index.pyt   <module>   sp   Xd					"	
!!ÿ ÿ f		
		'+	