Ñò
•èRc           @  sž  d  d k  l 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 e i e ƒ Z d e f d „  ƒ  YZ e ƒ  Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ h e e d ƒ 6e e i 6Z y d  d k Z e e e i <Wn e  e! f j
 o n Xd „  Z" h  Z# d „  Z$ d S(   iÿÿÿÿ(   t   unicode_literalsNi   (   t   DistlibException(   t   cached_propertyt   get_cache_baset   path_to_cache_dirt   Cachec           B  s>   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z RS(   ut   
    A class implementing a cache for resources that need to live in the file system
    e.g. shared libraries.
    c         C  sr   | d j o@ t i i t ƒ  d ƒ } t i i | ƒ p t i | ƒ qM n t i i t i i | ƒ ƒ |  _	 d S(   u  
        Initialise an instance.

        :param base: The base directory where the cache should be located. If
                     not specified, this will be the ``resource-cache``
                     directory under whatever :func:`get_cache_base` returns.
        u   resource-cacheN(
   t   Nonet   ost   patht   joinR   t   isdirt   makedirst   abspatht   normpatht   base(   t   selfR   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   __init__   s
    c         C  s
   t  | ƒ S(   uN   
        Converts a resource prefix to a directory name in the cache.
        (   R   (   R   t   prefix(    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   prefix_to_dir,   s    c         C  s   t  S(   uã   
        Is the cache stale for the given resource?

        :param resource: The :class:`Resource` being cached.
        :param path: The path of the resource in the cache.
        :return: True if the cache is stale.
        (   t   True(   R   t   resourceR   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   is_stale2   s    	c   	      C  s  | i  i | ƒ \ } } | d j o
 | } nÑ t i i |  i |  i | ƒ | ƒ } t i i | ƒ } t i i	 | ƒ p t i
 | ƒ n t i i | ƒ p
 t } n |  i | | ƒ } | o@ t | d ƒ i i ƒ  } z | ~ } | i | i ƒ Wd QXn | S(   u¤   
        Get a resource into the cache,

        :param resource: A :class:`Resource` instance.
        :return: The pathname of the resource in the cache.
        u   wbN(   t   findert   get_cache_infoR   R   R   R	   R   R   t   dirnameR
   R   t   existsR   R   t   opent   __exit__t	   __enter__t   writet   bytes(	   R   R   R   R   t   resultR   t   stalet   _[1]t   f(    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   get=   s    
$
&c         C  sÁ   g  } x´ t  i |  i ƒ D]  } t  i i |  i | ƒ } y_ t  i i | ƒ p t  i i | ƒ o t  i | ƒ n% t  i i | ƒ o t	 i
 | ƒ n Wq t j
 o | i | ƒ q Xq W| S(   u"   
        Clear the cache.
        (   R   t   listdirR   R   R	   t   islinkt   isfilet   removeR
   t   shutilt   rmtreet	   Exceptiont   append(   R   t   not_removedt   fn(    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   clearV   s     &N(	   t   __name__t
   __module__t   __doc__R   R   R   R   R#   R.   (    (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR      s   			t   ResourceBasec           B  s   e  Z d  „  Z RS(   c         C  s   | |  _  | |  _ d  S(   N(   R   t   name(   R   R   R3   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR   i   s    	(   R/   R0   R   (    (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR2   h   s   t   Resourcec           B  sJ   e  Z d  Z e Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 RS(   uÇ   
    A class representing an in-package resource, such as a data file. This is
    not normally instantiated by user code, but rather by a
    :class:`ResourceFinder` which manages the resource.
    c         C  s   |  i  i |  ƒ S(   u@   Get the resource as a stream. Not a property, as not idempotent.(   R   t
   get_stream(   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt	   as_streamu   s    c         C  s   t  i |  ƒ S(   N(   t   cacheR#   (   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt	   file_pathy   s    c         C  s   |  i  i |  ƒ S(   N(   R   t	   get_bytes(   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR   }   s    c         C  s   |  i  i |  ƒ S(   N(   R   t   get_size(   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   size   s    (
   R/   R0   R1   t   Falset   is_containerR6   R   R8   R   R;   (    (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR4   m   s   	t   ResourceContainerc           B  s   e  Z e Z e d  „  ƒ Z RS(   c         C  s   |  i  i |  ƒ S(   N(   R   t   get_resources(   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt	   resourcesˆ   s    (   R/   R0   R   R=   R   R@   (    (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR>   …   s   t   ResourceFinderc           B  sz   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z e e i i ƒ Z RS(   u4   
    Resource finder for file system resources.
    c         C  sC   | |  _  t | d d  ƒ |  _ t i i t | d d ƒ ƒ |  _ d  S(   Nu
   __loader__u   __file__u    (   t   modulet   getattrR   t   loaderR   R   R   R   (   R   RB   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR      s    	c         C  s2   | i  d ƒ } | i d |  i ƒ t i i | Œ  S(   Nu   /i    (   t   splitt   insertR   R   R   R	   (   R   t   resource_namet   parts(    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt
   _make_path•   s    c         C  s   t  i i | ƒ S(   N(   R   R   R   (   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   _findš   s    c         C  s   d  | i f S(   N(   R   R   (   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR      s    c         C  sh   |  i  | ƒ } |  i | ƒ p
 d  } n< |  i | ƒ o t |  | ƒ } n t |  | ƒ } | | _ | S(   N(   RI   RJ   R   t   _is_directoryR>   R4   R   (   R   RG   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   find    s    
	c         C  s   t  | i d ƒ S(   Nu   rb(   R   R   (   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR5   ¬   s    c         C  s=   t  | i d ƒ i i ƒ  } z | ~ } | i ƒ  SWd  QXd  S(   Nu   rb(   R   R   R   R   t   read(   R   R   R!   R"   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR9   ¯   s    )c         C  s   t  i i | i ƒ S(   N(   R   R   t   getsize(   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR:   ³   s    c         C  sK   d „  } t  g  } t i | i ƒ D] } | | ƒ o | | q# q# ~ ƒ S(   Nc         S  s   |  d j o |  i  d ƒ S(   Nu   __pycache__u   .pycu   .pyo(   u   .pycu   .pyo(   t   endswith(   R"   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   allowed·   s    (   t   setR   R$   R   (   R   R   RP   R!   R"   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR?   ¶   s    	c         C  s   |  i  | i ƒ S(   N(   RK   R   (   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR=   »   s    (   R/   R0   R1   R   RI   RJ   R   RL   R5   R9   R:   R?   R=   t   staticmethodR   R   R
   RK   (    (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyRA   Œ   s   										t   ZipResourceFinderc           B  sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   u6   
    Resource finder for resources in .zip files.
    c         C  s   t  t |  ƒ i | ƒ |  i i } d t | ƒ |  _ t |  i d ƒ o |  i i |  _ n t	 i
 | |  _ t |  i ƒ |  _ d  S(   Ni   u   _files(   t   superRS   R   RD   t   archivet   lent
   prefix_lent   hasattrt   _filest	   zipimportt   _zip_directory_cachet   sortedt   index(   R   RB   RU   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR   Ä   s    c         C  sØ   | |  i  } | |  i j o
 t } nq | d t i j o | t i } n t i |  i | ƒ } y |  i | i | ƒ } Wn t j
 o t	 } n X| p t
 i d | |  i i ƒ n t
 i d | |  i i ƒ | S(   Niÿÿÿÿu   _find failed: %r %ru   _find worked: %r %r(   RW   RY   R   R   t   sept   bisectR]   t
   startswitht
   IndexErrorR<   t   loggert   debugRD   R   (   R   R   R   t   i(    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyRJ   Ï   s    
c         C  s-   |  i  i } | i d t | ƒ } | | f S(   Ni   (   RD   RU   R   RV   (   R   R   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR   á   s    c         C  s   |  i  i | i ƒ S(   N(   RD   t   get_dataR   (   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR9   æ   s    c         C  s   t  i |  i | ƒ ƒ S(   N(   t   iot   BytesIOR9   (   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR5   é   s    c         C  s   | i  |  i } |  i | d S(   Ni   (   R   RW   RY   (   R   R   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR:   ì   s    c         C  sØ   | i  |  i } | d t i j o | t i 7} n t | ƒ } t ƒ  } t i |  i | ƒ } xr | t |  i ƒ j  o[ |  i | i | ƒ p Pn |  i | | } | i	 | i
 t i d ƒ d ƒ | d 7} qb W| S(   Niÿÿÿÿi   i    (   R   RW   R   R^   RV   RQ   R_   R]   R`   t   addRE   (   R   R   R   t   plenR   Rd   t   s(    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR?   ð   s    	  c         C  s   | |  i  } | d t i j o | t i 7} n t i |  i | ƒ } y |  i | i | ƒ } Wn t j
 o t } n X| S(   Niÿÿÿÿ(   RW   R   R^   R_   R]   R`   Ra   R<   (   R   R   Rd   R   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyRK   ÿ   s    (   R/   R0   R1   R   RJ   R   R9   R5   R:   R?   RK   (    (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyRS   À   s   							c         C  s   | t  t |  ƒ <d  S(   N(   t   _finder_registryt   type(   RD   t   finder_maker(    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   register_finder  s    c         C  s×   |  t  j o t  |  } n¹ |  t i j o t |  ƒ n t i |  } t | d d ƒ } | d j o t d ƒ ‚ n t | d d ƒ } t i t	 | ƒ ƒ } | d j o t d |  ƒ ‚ n | | ƒ } | t  |  <| S(   uŸ   
    Return a resource finder for a package.
    :param package: The name of the package.
    :return: A :class:`ResourceFinder` instance for the package.
    u   __path__u8   You cannot get a finder for a module, only for a packageu
   __loader__u   Unable to locate finder for %rN(
   t   _finder_cachet   syst   modulest
   __import__RC   R   R   Rk   R#   Rl   (   t   packageR   RB   R   RD   Rm   (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyR     s    
(%   t
   __future__R    R_   Rf   t   loggingR   R(   Rp   RZ   t    R   t   utilR   R   R   t	   getLoggerR/   Rb   t   objectR   R7   R2   R4   R>   RA   RS   Rl   R   t   zipimporterRk   t   _frozen_importlibt   SourceFileLoadert   ImportErrort   AttributeErrorRn   Ro   R   (    (    (    sX   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/resources.pyt   <module>   s8   P	4J	