ó
¨9Vc           @   s*   d  d l  m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   BytesIOt   CallbackFileWrapperc           B   s5   e  Z d  Z d „  Z d „  Z d „  Z d d „ Z RS(   sv  
    Small wrapper around a fp object which will tee everything read into a
    buffer, and when that file is closed it will execute a callback with the
    contents of that buffer.

    All attributes are proxied to the underlying file object.

    This class uses members with a double underscore (__) leading prefix so as
    not to accidentally shadow an attribute.
    c         C   s"   t  ƒ  |  _ | |  _ | |  _ d  S(   N(   R    t   _CallbackFileWrapper__buft   _CallbackFileWrapper__fpt   _CallbackFileWrapper__callback(   t   selft   fpt   callback(    (    sA   /tmp/pip-build-5Z5nTX/pip/pip/_vendor/cachecontrol/filewrapper.pyt   __init__   s    	c         C   s   |  j  d ƒ } t | | ƒ S(   NR   (   t   __getattribute__t   getattr(   R   t   nameR   (    (    sA   /tmp/pip-build-5Z5nTX/pip/pip/_vendor/cachecontrol/filewrapper.pyt   __getattr__   s    	c         C   sN   y |  j  j d  k SWn t k
 r' n Xy |  j  j SWn t k
 rI n Xt S(   N(   R   R   t   Nonet   AttributeErrort   closedt   False(   R   (    (    sA   /tmp/pip-build-5Z5nTX/pip/pip/_vendor/cachecontrol/filewrapper.pyt   __is_fp_closed!   s    c         C   s`   |  j  j | ƒ } |  j j | ƒ |  j ƒ  r\ |  j rP |  j |  j j ƒ  ƒ n  d  |  _ n  | S(   N(   R   t   readR   t   writet"   _CallbackFileWrapper__is_fp_closedR   t   getvalueR   (   R   t   amtt   data(    (    sA   /tmp/pip-build-5Z5nTX/pip/pip/_vendor/cachecontrol/filewrapper.pyR   0   s    	N(   t   __name__t
   __module__t   __doc__R   R   R   R   R   (    (    (    sA   /tmp/pip-build-5Z5nTX/pip/pip/_vendor/cachecontrol/filewrapper.pyR      s
   
			N(   t   ioR    t   objectR   (    (    (    sA   /tmp/pip-build-5Z5nTX/pip/pip/_vendor/cachecontrol/filewrapper.pyt   <module>   s   