
[Kc           @   sG  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	 Z	 d d k
 Z
 d d k Z d d k Td d k l Z d d k l Z y d d k l Z Wn# e j
 o d d k l Z n Xd d k l Z e i d  Z e i d	 e i  Z e i d
  Z e i d e i  i Z d i   Z d d d d g Z d   Z  d   Z! e" d  Z# e" d  Z$ e" d  Z% e" e& e" d  Z' e i d e i  Z( d   Z) d e i* d  e+ d  d i* f Z, d e- f d     YZ. e i d  i/ Z0 d   Z1 d    Z2 d!   Z3 d"   Z4 d#   Z5 d$   Z6 d S(%   s#   PyPI and direct package downloadingiN(   t   *(   t   log(   t   DistutilsError(   t   md5(   t	   translates   ^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_namec         C   s   |  i    } d	 \ } } | i d  oP | i d  o |  d  } qx | i d d  o |  d d !} |  d  } qx n | | f S(
   s=   Return (base,pyversion) or (None,None) for possible .exe names   .exes
   .win32.exeis	   .win32-pyiiiN(   NN(   t   lowert   Nonet   endswitht
   startswith(   t   nameR	   t   baset   py_ver(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR      s    c         C   sp   t  i  |   \ } } } } } } t i | i d  d  } d | j o | i d d  \ } } n | | f S(   Nt   /it   #i   (   t   urlparset   urllib2t   unquotet   split(   t   urlt   schemet   servert   patht
   parameterst   queryt   fragmentR   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   egg_info_for_url+   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   groupt   CHECKOUT_DIST(   R   t   metadataR   R   t   distR!   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR   1   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 d  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   .exet   win32N(	   R   t   Distributiont   from_locationR   R
   R   t   BINARY_DISTt
   EXTENSIONSt   len(   t   locationt   basenameR$   t   win_baseR   t   ext(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR   =   s     c         C   s"   t  t |   t i i |   |  S(   sE   Yield possible egg or source distribution objects based on a filename(   R   t   normalize_patht   osR   R.   (   t   filenameR$   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   distros_for_filenameT   s    c   	      c   s   | i  d  } | pM xJ t | d  D]4 \ } } t |  d j o | i d  o d Sq' Wn xa t d t |  d  D]F } t |  | d i | |   d i | |  d | d | d	 | Vq} 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!
    R&   i   i   s   py2.Ni   t
   py_versionR   t   platform(   R   t	   enumerateR,   R   t   rangeR(   t   join(	   R-   R.   R$   R5   R   R6   t   partst   it   p(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR   [   s     # )s(   <([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>c         c   s  x t  i |  D] } | i   \ } } t t i | i   i d   } d | j p d | j o> x; t i |  D]& } t	 i
 |  t | i d    Vqs Wq q Wxk d	 D]c } | i |  } | d j oA t i | |  } | o$ t	 i
 |  t | i d    Vqq q Wd S(
   sE   Find rel="homepage" and rel="download" links in `page`, yielding URLst   ,t   homepaget   downloadi   s   <th>Home Pages   <th>Download URLiN(   s   <th>Home Pages   <th>Download URL(   t   RELt   finditert   groupst   mapt   strt   stripR	   R   t   HREFR   t   urljoint
   htmldecodeR"   t   findt   search(   R   t   pageR!   t   tagt   relt   relst   pos(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   find_external_links   s     ! , s   Python-urllib/%s distribute/%si   t
   distributei    c           B   sI  e  Z d  Z d d" 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  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  d   Z! d    Z" d!   Z# RS($   s;   A distribution index that scans web pages for download URLss   http://pypi.python.org/simpleR    c         O   s}   t  i |  | |  | d | i d   |  _ h  |  _ h  |  _ h  |  _ t i d i	 t
 t |    i |  _ g  |  _ d  S(   NR   t   |(   t   Environmentt   __init__R   t	   index_urlt   scanned_urlst   fetched_urlst   package_pagest   ret   compileR9   RC   R   R!   t   allowst   to_scan(   t   selfRU   t   hostst   argst   kw(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRT      s    			'c   
      C   sM  | |  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	 |  i
 |  d S|  i |  p t |  i | <d S|  i d |  |  i | d  } | d j o d St |  i | <|  i | i <d | i i d d  i   j o | i   d S| i } | i   } t i d j o/ | i i d	  p d
 } | i | d  } n | i   | i |  i  o/ t | d d  d j o |  i | |  } n xE t i |  D]4 } t i | t  | i! d    }	 |  i" |	  qWd S(   s<   Evaluate a URL as a possible download, and maybe retrieve itNs   Found link: %ss
   Reading %ss5   Download error: %s -- Some packages may not be found!t   htmls   content-typet    i   t   charsets   latin-1t   ignoret   codei  i   (   i   (#   RV   t   Truet
   URL_SCHEMEt   process_filenamet   listR   t   url_okt   debugRW   RC   t   addt   infot   open_urlR
   R   t   headerst   getR	   t   closet   readt   syst   version_infot	   get_paramt   decodeR   RU   t   getattrt   process_indexRF   RA   R   RG   RH   R"   t   process_url(
   R]   R   t   retrievet   distst   fR   RK   Rc   R!   t   link(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRy      sJ     "
	
, !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 |  i |  n d  S(   Ns   Not found: %ss	   Found: %s(   R2   R   t   existst   warnt   isdirt   realpatht   listdirRh   R9   Rf   R4   Rk   RC   Rl   (   R]   t   fnt   nestedR   t   itemR{   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRh      s     'c         C   s   t  |  } | o | i d  i   d j p |  i t i |  d  o t Sd } | o t | |   n |  i | |  d  S(   Ni   t   files,   
Link to % s ***BLOCKED*** by --allow-hosts
(   Rg   R"   R	   R[   R   Rf   R   R   (   R]   R   t   fatalt   st   msg(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRj      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(   R2   R   R   R   R   t   scan_egg_link(   R]   t   search_pathR   t   entry(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   scan_egg_links   s      c         C   s   t  d  t t i t t i i | |     } t	 |  d j o\ xY t
 t i i | | d   D]4 } t i i | |  | _ t | _ |  i |  qc Wn d  S(   Ni   i    (   t   filterR
   RC   RD   RE   t   openR2   R   R9   R,   t   find_distributionsR-   t   SOURCE_DISTR   Rl   (   R]   R   R   t   linesR%   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR      s    0  	c   
         s    f d   } x< t  i |  D]+ } | t i | t | i d     q W| |  \ } } | o x~ t | |  D]m } t |  \ } }	 | i d  o8 |	 o0 | o | d | | f 7} q   i	 |  n   i
 |  qw Wt i d   |  Sd Sd S(   s#   Process the contents of a PyPI pagec            s   |  i    i  o t t i |  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(   NR   i   R   i   i    (   NN(   R   RU   RC   R   R   R,   R   t	   safe_namet   safe_versionRf   RX   t
   setdefaultR	   t   to_filenameR
   (   R}   R:   t   pkgt   ver(   R]   (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   scan   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   (   R"   (   t   m(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   <lambda>  s    Rb   N(   RF   RA   R   RG   RH   R"   RP   R   R   t   need_version_infot   scan_urlt   PYPI_MD5t   sub(
   R]   R   RK   R   R!   R   R   t   new_urlR   t   frag(    (   R]   s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRx      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]   R   (    (    s<   /usr/lib/python2.6/dist-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)(   RU   RW   R   Rm   R   (   R]   R   R_   (    (    s<   /usr/lib/python2.6/dist-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(   NR   (    (	   R   RU   t   unsafe_nameRX   Rp   t   keyt   project_namet   not_found_in_indexRi   (   R]   t   requirementR   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   find_packages2  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   Rk   t   superR   t   obtain(   R]   R   t	   installerR%   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR   A  s    
  c         C   s}   t  i d |  of |  i d |  | i   | d j o; | i   t i |  t d t i i	 |  d   qy n d  S(   Ns   md5=[0-9a-f]{32}$s   Validating md5 checksum for %si   s   MD5 validation failed for s   ; possible download problem?(
   RY   R!   Rk   t	   hexdigestRq   R2   t   unlinkR   R   R.   (   R]   t   csRm   R3   t   tfp(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt	   check_md5M  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
   Rg   R   Ri   R   R   t   append(   R]   t   urlsR   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   add_find_linksX  s     c         C   s.   |  i  o t |  i |  i   n d |  _  d S(   s7   Scan urls scheduled for prescanning (e.g. --find-links)N(   R\   RC   R   R
   (   R]   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR   g  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   Rm   R   R   R   (   R]   R   t   methR   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR   m  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: %rR-   N(   t
   isinstancet   RequirementRg   t   _download_urlR"   R   R   t	   gen_setupR2   R   R~   t   parset
   ValueErrorR   Rw   t   fetch_distributionR
   (   R]   t   spect   tmpdirR   t   foundR   R   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR?   v  s"    c            s    i  d |  h          f d   } | o  i    i |  n | |  } | d j o*  i d j	 o  i   | |  } n | d j o% | o  i |  | |  } n | d j o%  i d  o d p d |  n | 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   x  |  i  D] } | i t j o:  o2 |   j o  i d |  d   | <q q n | |  j oH | i t j p  o0  i d |  | i d  i | i    Sq Wd  S(   Ns&   Skipping development or system egg: %si   s   Best match: %sR-   (	   R   R   t   DEVELOP_DISTR   R   Rm   t   cloneR?   R-   (   t   reqR%   (   t   skippedt
   develop_okR]   t   sourceR   (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRI     s     %	s2   No local packages or download links found for %s%ss   a source distribution of Rb   N(   Rm   R   R   R
   R\   R   (   R]   R   R   t
   force_scanR   R   RI   R%   (    (   R   R   R]   R   R   s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR     s&    

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
   R-   (   R]   R   R   R   R   R%   (    (    s<   /usr/lib/python2.6/dist-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 d | d i | d i t i i |  d f  | i   | 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   R"   R
   t   versionR,   R2   R   R.   t   dirnameR9   t   setuptools.command.easy_installR   t   shutilt   copy2R   t   writeR   t   splitextRq   R   (   R]   R3   R   R   R!   t   _[1]t   dR{   R.   t   dstR   R   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR     s2    >
i    c      	   C   s  |  i  d |  d
 \ } } } zqd | j o | i d d  \ } } n |  i |  } t | t i  o# t d | | i | i	 f   n t
   } | i    } d } |  i }	 d }
 d | j o- t | d  }
 |  i | | | |	 |
  n t | d	  } xd t o\ | i |	  } | oA | i |  | i |  | d 7} |  i | | | |	 |
  qPqW| o |  i | | | |  n | SWd  | o | i   n | o | i   n Xd  S(   Ns   Downloading %sR   i   s   Can't download %s: %s %si    is   content-lengths   Content-Lengtht   wb(   NNN(   Rm   R
   R   Rn   R   R   t	   HTTPErrorR   Re   R   R   t   dl_blocksizet   intt
   reporthookR   Rf   Rr   t   updateR   R   Rq   (   R]   R   R3   t   fpR   Rm   R   Ro   t   blocknumt   bst   sizet   block(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   _download_to  sD     		 
   c         C   s   d  S(   N(    (   R]   R   R3   R   t   blksizeR   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR   ?  s    c         C   s  | i  d  o t |  Sy t |  SWn~t t i f j
 om } d i g  } | i D] } | t |  qY ~  } | 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   t   httplibt
   InvalidURLR9   R_   RD   R   R   R   R   t   URLErrort   reasont   BadStatusLinet   linet   HTTPException(   R]   R   t   warningt   vR   t   argR   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRn   C  s4    3c         C   s   t  d  t i |  d i d   } | oA | d } x: d | j o" | i d d  i d d  } q9 Wn d } | i d	  o | d
  } n t i i | |  } | d j p | i	 d  o |  i
 | |  S| d j o t i t i |  d  S|  i | t  |  i | |  Sd  S(   Ni   R   is   ..t   .s   \t   _t   __downloaded__s   .egg.zipit   svns   svn+R   (   R   R
   R   R   t   replaceR   R2   R   R9   R   t   _download_svnR   t   url2pathnameRj   Rf   t   _attempt_download(   R]   R   R   R   R   R3   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR   d  s     %
 'c         C   s   |  i  | t  d  S(   N(   Ry   Rf   (   R]   R   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR     s    c         C   sM   |  i  | |  } d | i d d  i   j o |  i | | |  S| Sd  S(   NRa   s   content-typeRb   (   R   Rp   R	   t   _download_html(   R]   R   R3   Ro   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR     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   RE   RY   RJ   Rq   R2   R   R   R   (   R]   R   Ro   R3   R   R   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR     s     
	
c         C   sD   | i  d d  d } |  i d | |  t i d | | f  | S(   NR   i   i    s'   Doing subversion checkout from %s to %ss   svn checkout -q %s %s(   R   Rm   R2   t   system(   R]   R   R3   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR     s    c         G   s   t  i | |  d  S(   N(   R   Rk   (   R]   R   R_   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRk     s    c         G   s   t  i | |  d  S(   N(   R   Rm   (   R]   R   R_   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRm     s    c         G   s   t  i | |  d  S(   N(   R   R   (   R]   R   R_   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR     s    (   R    N($   t   __name__t
   __module__t   __doc__RT   t   FalseRy   Rh   Rj   R   R   Rx   R   R
   R   R   R   R   R   R   R   R?   R   R   R   R   R   R   Rn   R   R   R   R   R   Rk   Rm   R   (    (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR      s@   ,
			)								*=	)	$	!							s!   &(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?c         C   s7   t  |  t  p |  S|  d j o t |   St |   S(   Ni   (   R   R   t   unichrt   chr(   t   c(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   uchr  s
     c         C   s   |  i  d  } | i d  o t | d d  } nP | i d  o t | d  } n, d d k l } | i | |  i  d   } t |  S(	   Ni   s   #xi   i   R   i(   t   name2codepointi    (   R"   R   R   t   htmlentitydefsR   Rp   R   (   R!   t   whatR   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   decode_entity  s    c         C   s   t  t |   S(   s'   Decode HTML entities in the given text.(   t
   entity_subR  (   t   text(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyRH     s    c         C   s]  t  i  |   \ } } } } } } | d j o t i |  \ } } n d } | of d t i |  i d  i   } t  i | | | | | | f  }	 t i |	  }
 |
 i	 d |  n t i |   }
 |
 i	 d t
  t i |
  } | oj t  i  | i  \ } } } } } } | | j o5 | | j o( t  i | | | | | | f  | _ qYn | S(	   s4   Open a urllib2 request, handling HTTP authenticationt   httpt   httpss   Basic t   base64t   Authorizations
   User-Agent(   R  R  N(   R   R   t	   splituserR
   R   t   encodeRE   t
   urlunparset   Requestt
   add_headert
   user_agentt   urlopenR   (   R   R   t   netlocR   t   paramsR   R   t   autht   hostR   t   requestR   t   s2t   h2t   path2t   param2t   query2t   frag2(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR     s"    !"!$,c         C   s   |  S(   N(    (   R   (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt
   fix_sf_url  s    c      	   C   s  t  i  |   \ } } } } } } t i |  } t i i |  o t i |   S| i d  o t i i |  o g  } x t i	 |  D] }	 |	 d j o9 t
 t i i | |	  d  }
 |
 i   } |
 i   Pn1 t i i t i i | |	   o |	 d 7}	 n | i d |	 |	 f  q Wd |  d d i |  } d \ } } n d \ } } } t i |  | | h d d 6t i |   S(   s7   Read a local path, with special support for directoriesR   s
   index.htmlt   rbs   <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   R  (   i  s   Path not founds	   Not found(   R   R   R   R2   R   t   isfileR  R   R   R   R   R9   Rr   Rq   R   R   t	   cStringIOt   StringIO(   R   R   R   R   t   paramR   R   R3   t   filesR|   R   t   bodyt   statust   message(    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyR     s,    !# 
"(7   R   Rs   t   os.pathR2   RY   R   R   R   t   randomt   socketR   R   t   pkg_resourcest	   distutilsR   t   distutils.errorsR   t   hashlibR   t   ImportErrort   fnmatchR   RZ   R    t   IRF   R   R!   Rg   R   R+   t   __all__R   R   R
   R   R   R4   R   R   R@   RP   R   t   requireR  RS   R   R   R  R   R  RH   R   R  R   (    (    (    s<   /usr/lib/python2.6/dist-packages/setuptools/package_index.pyt   <module>   sL   l
					!	!  				)	