
6Uc           @   s  d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k l	 Z	 d d k
 l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z d d k l Z d d k l Z d d k l Z d d k l Z l  Z  l! Z! l" Z" l# Z# l$ Z$ l% Z% l& Z& l' Z' l( Z( l) Z) l* Z* l+ Z+ l, Z, l- Z- d d	 k l. Z. d d
 k/ l0 Z0 d d k1 l2 Z2 d d k3 l4 Z4 e i5 d  Z6 e i5 d e i7  Z8 e i5 d  Z9 e i5 d e i7  i: Z; d i<   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 i5 d e i7  ZI eH d     ZJ d! e iK d"  e d#  d$ iK f ZL d% eM f d&     YZN d' eN f d(     YZO d e f d)     YZP e i5 d*  iQ ZR d+   ZS d,   ZT d-   ZU d d.  ZV d/   ZW d0 eM f d1     YZX d2 e- i- f d3     YZY e iZ d4  Z[ eV e?  e[  Z[ d5   Z\ d6   Z] d S(7   s#   PyPI and direct package downloadingiN(   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   |  i    } d \ } } } | i d  o | i d  o |  d  } d } q | i d d  o! |  d d !} |  d  } d } q | i d	  o |  d
  } d } q | i d d  o! |  d d !} |  d  } d } q n | | | f S(   s=   Return (base,pyversion) or (None,None) for possible .exe names   .exes
   .win32.exeit   win32s	   .win32-pyiiis   .win-amd64.exeis	   win-amd64s   .win-amd64-pyiN(   NNN(   t   lowert   Nonet   endswitht
   startswith(   t   nameR)   t   baset   py_vert   plat(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR&   .   s$    






c         C   s   t  |   \ } } } } } } t | i d  d  } | d j o* | d j o t | i d  d  } n d | j o | i d d  \ } } n | | f S(   Nt   /is   sourceforge.nett   downloadit   #i   (   R   R   t   split(   t   urlt   schemet   servert   patht
   parameterst   queryt   fragmentR.   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   egg_info_for_urlF   s     c         c   s   t  |   \ } } x t |  | |  D] } | Vq% W| oO t i |  } | o5 x2 t |  | i d  | d t D] } | Vqs 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@   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR%   N   s      	 c         C   s   | i  d  o | d  } n | i  d  o$ d | j o t i |  | |  g S| i  d  o@ t |  \ } } } | d j	 o t |  | | | t |  Sn x@ t D]8 } | i  |  o" | t |   } t |  | |  Sq Wg  S(   s:   Yield egg or source distribution objects based on basenames   .egg.zipis   .eggt   -s   .exeN(	   R+   R   t   from_locationR&   R*   R'   R   t
   EXTENSIONSt   len(   t   locationt   basenameRB   t   win_baseR/   t   platformt   ext(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR>   Z   s     c         C   s"   t  t |   t i i |   |  S(   sE   Yield possible egg or source distribution objects based on a filename(   R>   R   t   osR8   RI   (   t   filenameRB   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   distros_for_filenameo   s    c         c   s   | i  d  } | o  t d   | d D  o d Sxa t d t |  d  D]F } t |  | d i | |   d i | |  d | d | d | VqQ 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   c         s   s%   x |  ] } t  i d  |  Vq Wd S(   s	   py\d\.\d$N(   t   reR@   (   t   .0t   p(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pys	   <genexpr>   s   	 i   Ni   t
   py_versionR=   RK   (   R4   t   anyt   rangeRG   R   t   join(   RH   RI   RB   RS   R=   RK   t   partsRR   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR'   v   s    # )c         c   s   t    } | i } | d j o0 xj t | i |   D] } | |  | Vq2 Wn> x: |  D]2 } | |  } | | j o | |  | VqV qV 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(    (    s<   /usr/lib/python2.6/site-packages/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(   Ra   (   t   argst   kwargs(   t   func(    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   wrapper   s    (   R    (   Rd   Re   (    (   Rd   s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   unique_values   s    s(   <([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>c         c   s  x t  i |  D] } | i   \ } } t t t i | i   i d    } d | j p d | j o; x8 t	 i |  D]# } t
 |  t | i d    Vqy Wq q Wxh d	 D]` } | i |  } | d j o> t	 i | |  } | o! t
 |  t | i 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 URLiN(   s   <th>Home Pages   <th>Download URL(   t   RELt   finditert   groupsRX   t   mapt   strt   stripR)   R4   t   HREFR   t
   htmldecodeRA   t   findt   search(   R5   t   pageR@   t   tagt   relt   relst   pos(    (    s<   /usr/lib/python2.6/site-packages/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(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   feed   s    c         C   s   t  S(   sC   
        Check the hash. Return False if validation fails.
        (   t   True(   R{   (    (    s<   /usr/lib/python2.6/site-packages/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(    (   R{   t   reportert   template(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   report   s    (   t   __name__t
   __module__t   __doc__R}   R   R   (    (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyRz      s   		t   HashCheckerc           B   sJ   e  Z e i 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 i |  |  _ | |  _ d  S(   N(   t	   hash_namet   hashlibt   newt   hasht   expected(   R{   R   R   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   __init__   s    	c         C   sP   t  |  d } | p t   S|  i i |  } | p t   S|  | i     S(   s5   Construct a (possibly null) ContentChecker from a URLi(   R   Rz   t   patternRr   t	   groupdict(   t   clsR5   R;   R@   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   from_url   s    c         C   s   |  i  i |  d  S(   N(   R   t   update(   R{   R|   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR}      s    c         C   s   |  i  i   |  i j S(   N(   R   t	   hexdigestR   (   R{   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR      s    c         C   s   | |  i  } | |  S(   N(   R   (   R{   R   R   t   msg(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR      s    (   R   R   RP   t   compileR   R   t   classmethodR   R}   R   R   (    (    (    s<   /usr/lib/python2.6/site-packages/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  i |  | |  | d | i d   |  _ h  |  _ h  |  _ h  |  _ t i d i	 t
 t |    i |  _ g  |  _ | o4 t i o* | p t i   o t i |  |  _ n t i |  _ d  S(   NR1   t   |(   R   R   R+   t	   index_urlt   scanned_urlst   fetched_urlst   package_pagesRP   R   RV   Rl   R!   R@   t   allowst   to_scanR   t   is_availablet   find_ca_bundlet
   opener_fort   openerR   t   urlopen(   R{   R   t   hostst	   ca_bundlet
   verify_sslRb   t   kw(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s    			'	%c   
      C   sp  | |  i  j o | o d St |  i  | <t |  p |  i |  d St t |   } | o) |  i |  p d S|  i d |  n | p | p | |  i j o t t	 |  i
 |   d S|  i |  p t |  i | <d S|  i d |  t |  i | <|  i | d |  } | d j o d St |  i | i <d | i i d d  i   j o | i   d S| i } | i   } t | t  pI t | t  o
 d } n | i i d	  p d } | i | d
  } n | i   xB t i |  D]1 } t | t | i d    }	 |  i |	  qW| i |  i   o/ t! | d d  d j o |  i" | |  } 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   Rl   RY   t   infot   open_urlR*   R5   t   headerst   getR)   t   closet   readt
   isinstanceRm   R   t	   get_paramt   decodeRo   Rj   R   Rp   RA   t   process_urlR,   R   t   getattrt   process_index(
   R{   R5   t   retrievet   distst   fR.   Rs   R   R@   t   link(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     sP     "
	

 ,c         C   s   t  i i |  p |  i d |  d  St  i i |  oW | oO t  i i |  } x: t  i |  D]% } |  i t  i i | |  t	  qe Wn t
 |  } | o* |  i d |  t t |  i |   n d  S(   Ns   Not found: %ss	   Found: %s(   RM   R8   t   existst   warnt   isdirt   realpatht   listdirR   RV   R~   RO   R   R   Rl   RY   (   R{   t   fnt   nestedR8   t   itemR   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR   G  s     'c         C   s   t  |  } | o | i d  i   d j p |  i t |  d  o t Sd } | o t | |   n |  i | |  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   (   R{   R5   t   fatalt   sR   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR   W  s    =c         C   sj   xc | D][ } t  i i |  oB x? t  i |  D]* } | i d  o |  i | |  q0 q0 Wq q Wd  S(   Ns	   .egg-link(   RM   R8   R   R   R+   t   scan_egg_link(   R{   t   search_pathR   t   entry(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   scan_egg_linksb  s      c         C   s   g  } t  t i t t i i | |    D] } | o | | q, q, ~ } t |  d j o\ xY t t i i | | d   D]4 } t i i | |  | _	 t
 | _ |  i |  q Wn d  S(   Ni   i    (   Rl   Rm   Rn   t   openRM   R8   RV   RG   R   RH   R   R=   RY   (   R{   R8   R   t   _[1]t   _ft   linesRC   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR   i  s    =  	c   
         s    f d   } xS t  i |  D]B } y& | t | t | i d     Wq t j
 o q Xq W| |  \ } } | o x~ t | |  D]m } t |  \ } }	 | i d  o8 |	 o0 | o | d | | f 7} q   i	 |  n   i
 |  q Wt i d   |  Sd Sd S(   s#   Process the contents of a PyPI pagec            s   |  i    i  o t t t |  t   i  i d    } t |  d j og d | d j oV t | d  } t | d  } t	   i
 i | i   h   |  <t |  t |  f Sn d S(   NR1   i   R3   i   i    (   NN(   R,   R   R   Rl   R   RG   R4   R	   R
   R~   R   t
   setdefaultR)   R   R*   (   R   RW   t   pkgt   ver(   R{   (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   scant  s    %$i   s   .pys
   #egg=%s-%sc         S   s   d  |  i  d d d  S(   s   <a href="%s#md5=%s">%s</a>i   i   i   (   RA   (   t   m(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   <lambda>  s    R   N(   Ro   Rj   R   Rp   RA   t
   ValueErrorRx   R<   R+   t   need_version_infot   scan_urlt   PYPI_MD5t   sub(
   R{   R5   Rs   R   R@   R   R   t   new_urlR.   t   frag(    (   R{   s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR   r  s(     &	 c         C   s   |  i  d |  d  S(   NsP   Page at %s links to .py file(s) without version info; an index scan is required.(   t   scan_all(   R{   R5   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s    c         G   sS   |  i  |  i j o, | o |  i | |  n |  i d  n |  i |  i   d  S(   Ns6   Scanning index of all packages (this may take a while)(   R   R   R   R   R   (   R{   R   Rb   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s     c         C   s   |  i  |  i | i d  |  i i | i  p |  i  |  i | i d  n |  i i | i  p |  i |  n x3 t |  i i | i d   D] } |  i  |  q Wd  S(   NR1   (    (	   R   R   t   unsafe_nameR   R   R\   t   project_namet   not_found_in_indexR   (   R{   t   requirementR5   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   find_packages  s     c         C   sm   |  i    |  i |  x: |  | i D]+ } | | j o | S|  i d | |  q% Wt t |   i | |  S(   Ns   %s does not match %s(   t   prescanR   R\   R   t   superR$   t   obtain(   R{   R   t	   installerRC   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s    
 c         C   sk   | i  |  i d |  | i   pC | i   t i |  t d | i i t i	 i
 |  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   (   R{   t   checkerRN   t   tfp(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt
   check_hash  s    
c         C   sw   xp | D]h } |  i  d j p1 t |  p# | i d  p t t |   o |  i |  q |  i  i |  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(   R{   t   urlsR5   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   add_find_links  s     c         C   s4   |  i  o t t |  i |  i    n d |  _  d S(   s7   Scan urls scheduled for prescanning (e.g. --find-links)N(   R   R   Rl   R   R*   (   R{   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s    
c         C   sP   |  | i  o |  i d } } n |  i d } } | | | i  |  i   d  S(   Ns#   Couldn't retrieve index page for %rs3   Couldn't find index page for %r (maybe misspelled?)(   R\   R   R   R   R   (   R{   R   t   methR   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s    
c         C   s   t  | t  p t |  } | o^ |  i | i d  | |  } t |  \ } } | i d  o |  i | | |  } n | St i	 i
 |  o | Sy t i |  } Wq t j
 o t d | f   q Xn t |  i | |  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*   (   R{   t   spect   tmpdirR6   t   foundR.   R;   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR2     s"    c   	         s^   i  d |  h    d } d      f d  } | o'  i    i |  | |  } n | d j	 o | p | | |  } n | d j o.  i d j	 o  i   n | |  } n | d j o% | o  i |  | |  } n | d j o%  i d  o d p d |  n0  i  d |  | i d  i | i |   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  j o
  } n x | |  i D]z } | i t j o:  o2 |   j o  i d |  d   | <q% q% n | |  j o | i t j p  o | Sq% Wd  S(   Ns&   Skipping development or system egg: %si   (   R*   R\   R=   R   R   R   (   t   reqt   envRC   (   t   skippedt
   develop_okR{   t   source(    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyRq   0  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   (	   R{   R   R   t
   force_scanR   R   t   local_indexRC   Rq   (    (   R   R   R{   R   s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s0    
c         C   s1   |  i  | | | |  } | d j	 o | i Sd 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   (   R{   R   R   R   R   RC   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   fetch[  s    c         C   s  t  i |  } | oE g  } t | | i d  d   D] } | i o | | q6 q6 ~ p g  } t |  d j o t i i	 |  } t i i
 |  | j oS t i i | |  }	 d d k l }
 |
 | |	  p t i | |	  |	 } q n t t i i | d  d  i i   } zE | ~ } | i d | d i | d i t i i |  d f  Wd  QX| S| o 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   dirnameRV   t   setuptools.command.easy_installR  t   shutilt   copy2R   t   __exit__t	   __enter__t   writeR   t   splitextR   (   R{   RN   R;   R   R@   R   t   dR   RI   t   dstR  t   _[2]R   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR   h  s2    >5!i    c         C   s  |  i  d |  d	 \ } } ztt i |  } |  i t |   } t | t  o# t d | | i	 | i
 f   n | i    } d } |  i } d }	 d | j oA t | d  }
 t t t |
   }	 |  i | | | | |	  n t | d  i i   } z | ~ } xd t o\ | i |  } | oA | i |  | i |  | d 7} |  i | | | | |	  qPqW|  i | | |  Wd  QX| SWd  | o | i   n Xd  S(
   Ns   Downloading %ss   Can't download %s: %s %si    is   content-lengths   Content-Lengtht   wbi   (   NN(   R   R*   R   R   R   R"   R   R   R   R   R   t   dl_blocksizeR#   t   maxRl   t   intt
   reporthookR   R
  R  R~   R   R}   R  R   R   (   R{   R5   RN   t   fpR   R   R   t   blocknumt   bst   sizet   sizesR   R   R|   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   _download_to  s<     	& 
 c         C   s   d  S(   N(    (   R{   R5   RN   R  t   blksizeR  (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR    s    c         C   s  | i  d  o t |  Sy t | |  i  SWn~t t i f j
 om } d i g  } | i D] } | t	 |  q_ ~  } | o |  i
 | |  qt d | | f   n t i j
 o
 } | St i j
 o@ } | o |  i
 | | i  qt d | | i f   n t i j
 o@ } | o |  i
 | | i  qt d | | i f   nJ t i j
 o: } | o |  i
 | |  qt d | | f   n Xd  S(   Ns   file: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
   InvalidURLRV   Rb   Rm   R   R   R   R   t   URLErrort   reasont   BadStatusLinet   linet   HTTPException(   R{   R5   t   warningt   vR   t   argR   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s6    3c         C   sL  t  |  \ } } | o7 x: d | j o" | i d d  i d d  } q Wn d } | i d  o | d  } n t i i | |  } | d j p | i d	  o |  i | |  S| d
 j p | i d  o |  i | |  S| i d  o |  i	 | |  S| d j o t
 t |  d  S|  i | t  |  i | |  Sd  S(   Ns   ..t   .s   \t   _t   __downloaded__s   .egg.zipit   svns   svn+t   gits   git+s   hg+R   i   (   R<   t   replaceR+   RM   R8   RV   R,   t   _download_svnt   _download_gitt   _download_hgR   R   R   R~   t   _attempt_download(   R{   R6   R5   R   R-   R;   RN   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s&     'c         C   s   |  i  | t  d  S(   N(   R   R~   (   R{   R5   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s    c         C   sM   |  i  | |  } d | i d d  i   j o |  i | | |  S| Sd  S(   NR   s   content-typeR   (   R  R   R)   t   _download_html(   R{   R5   RN   R   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR2    s    c         C   s   t  |  } x[ | D]S } | i   o@ t i d |  o( | i   t i |  |  i | |  SPq q W| i   t i |  t d |   d  S(   Ns    <title>([^- ]+ - )?Revision \d+:s   Unexpected HTML page found at (	   R   Rn   RP   Rr   R   RM   R   R/  R   (   R{   R5   R   RN   R   R$  (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR3    s     
	
c      	   C   s_  | i  d d  d } d } | i   i d  o d | j o t |  \ } } } } } }	 | o | i d  o d | d	 j o | d	 i  d d  \ } } t |  \ }
 } |
 ok d
 |
 j o, |
 i  d
 d  \ } } d | | f } n d |
 } | } t | | | | | |	 f  } q*q.n |  i d | |  t i 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(   R{   R5   RN   t   credsR6   t   netlocR8   RR   t   qR   t   autht   hostt   usert   pw(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR/    s"    #)
*c         C   s   t  |   \ } } } } } | i d d  d } | i d d  d } d  } d | j o | i d d  \ } } n t | | | | d f  }  |  | f S(   Nt   +i   iR3   i    R4  R   (   R   R4   R*   t   rsplitR   (   R5   t
   pop_prefixR6   R8  R8   R:   R   t   rev(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   _vcs_split_rev_from_url%  s    c         C   s   | i  d d  d } |  i | d t \ } } |  i d | |  t i d | | f  | d  j	 o+ |  i d |  t i 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   RB  R~   R   RM   R6  R*   (   R{   R5   RN   RA  (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR0  7  s    	c         C   s   | i  d d  d } |  i | d t \ } } |  i d | |  t i d | | f  | d  j	 o+ |  i d |  t i 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   RB  R~   R   RM   R6  R*   (   R{   R5   RN   RA  (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR1  G  s    	c         G   s   t  i | |  d  S(   N(   R   R   (   R{   R   Rb   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR   W  s    c         G   s   t  i | |  d  S(   N(   R   R   (   R{   R   Rb   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR   Z  s    c         G   s   t  i | |  d  S(   N(   R   R   (   R{   R   Rb   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR   ]  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   R2  R3  R/  t   staticmethodRB  R0  R1  R   R   R   (    (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR$     sL   0				*									)B	)	#	#									s!   &(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?c         C   s7   t  |  t  p |  S|  d j o t |   St |   S(   Ni   (   R   R  R   t   chr(   t   c(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   uchrd  s
     c         C   s   |  i  d  } | i d  o t | d d  } n@ | i d  o t | d  } n t i | |  i  d   } t |  S(   Ni   s   #xi   i   R3   i    (   RA   R,   R  R   R   RG  (   R@   t   what(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   decode_entityj  s    c         C   s   t  t |   S(   s'   Decode HTML entities in the given text.(   t
   entity_subRI  (   t   text(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyRp   t  s    c            s     f d   } | S(   Nc            s      f d   } | S(   Nc             s?   t  i   } t  i    z  |  |   SWd  t  i |  Xd  S(   N(   t   sockett   getdefaulttimeoutt   setdefaulttimeout(   Rb   Rc   t   old_timeout(   t   timeoutRd   (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   _socket_timeoutz  s
    (    (   Rd   RQ  (   RP  (   Rd   s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyRQ  y  s    (    (   RP  RQ  (    (   RP  s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   socket_timeoutx  s    	c         C   sC   t  |   } | i   } t i |  } | i   } | i 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.  (   R:  t   auth_st
   auth_bytest   encoded_bytest   encoded(    (    s<   /usr/lib/python2.6/site-packages/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(   R{   R\  R]  (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s    	c         c   s   |  i  V|  i Vd  S(   N(   R\  R]  (   R{   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   __iter__  s    c         C   s   d t  |   S(   Ns   %(username)s:%(password)s(   t   vars(   R{   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   __str__  s    (   R   R   R   R   R^  R`  (    (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR[    s   		t
   PyPIConfigc           B   s2   e  Z d    Z e d    Z d   Z d   Z RS(   c         C   sw   t  i d d d g d  } t i i |  |  t i i t i i d  d  } t i i |  o |  i	 |  n d S(   s%   
        Load from ~/.pypirc
        R\  R]  t
   repositoryR   t   ~s   .pypircN(
   t   dictt   fromkeysR   R   RM   R8   RV   t
   expanduserR   R   (   R{   t   defaultst   rc(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR     s
    !c         C   sZ   g  } |  i    D]* } |  i | d  i   o | | q q ~ } t t |  i |   S(   NRb  (   t   sectionsR   Rn   Rd  Rl   t   _get_repo_cred(   R{   R   t   sectiont   sections_with_repositories(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   creds_by_repository  s    -c         C   sO   |  i  | d  i   } | t |  i  | d  i   |  i  | d  i    f S(   NRb  R\  R]  (   R   Rn   R[  (   R{   Rk  t   repo(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyRj    s    c         C   s9   x2 |  i  i   D]! \ } } | i |  o | Sq Wd S(   s   
        If the URL indicated appears to be a repository defined in this
        config, return the credential for that repository.
        N(   Rm  t   itemsR,   (   R{   R5   Rb  t   cred(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   find_credential  s     (   R   R   R   t   propertyRm  Rj  Rq  (    (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyRa    s   			c         C   s  t  |   \ } } } } } } | i d  o t i d   n | d	 j o t |  \ } }	 n d
 } | pM t   i |   }
 |
 o0 t |
  } |
 i	 |  f } t
 i d |  q n | oQ d t |  } t | |	 | | | | f  } t i |  } | i d |  n t i |   } | i d t  | |  } | od t  | i  \ } } } } } } | | j o2 | |	 j o% t | | | | | | f  | _ qn | S(   s4   Open a urllib2 request, handling HTTP authenticationR5  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*   Ra  Rq  Rm   R\  R   R   RZ  R   R   t   Requestt
   add_headert
   user_agentR5   (   R5   R   R6   R8  R8   t   paramsR:   R   R:  R;  Rp  R   R   t   requestR  t   s2t   h2t   path2t   param2t   query2t   frag2(    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR    s2    !)c         C   s   |  S(   N(    (   R5   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt
   fix_sf_url  s    c      	   C   s  t  |   \ } } } } } } t |  } t i i |  o t i |   S| i d  o t i i |  o g  } x t i	 |  D] }	 |	 d j oL t
 t i i | |	  d  i i   }
 z |
 ~
 } | i   } Wd QXPn1 t i i t i i | |	   o |	 d 7}	 n | i d |	 |	 f  q Wd |  d d i |  } d \ } } n d \ } } } h d d 6} t |  | | | t |   S(   s7   Read a local path, with special support for directoriesR1   s
   index.htmlt   rNs   <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   RV   R
  R  R   R   R   R   (   R5   R6   R7   R8   t   paramR:   R   RN   t   filesR   R   R  t   bodyt   statust   messageR   (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyR    s*    # 5"(^   R   t   sysRM   RP   R  RL  RT  R   t	   functoolsR    t   pkg_resourcesR   R   R   R   R   R   R   R   R	   R
   R   R   R   Ry   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   IRo   R   R@   R   R4   RF   t   __all__t   _SOCKET_TIMEOUTR&   R<   R*   R%   R>   RO   R'   Ra   Rf   Ri   Rx   R  Rx  t   objectRz   R   R$   R   RJ  RG  RI  Rp   RR  RZ  R[  Ra  R   R  R  R  (    (    (    s<   /usr/lib/python2.6/site-packages/setuptools/package_index.pyt   <module>   sp   Xd					!	
!!  _		
		'+	