ó
^ęWc           @   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(    (    su   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/filewrapper.pyt   __init__   s    	c         C   s   |  j  d  } t | |  S(   NR   (   t   __getattribute__t   getattr(   R   t   nameR   (    (    su   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   (    (    su   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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(    (    su   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/filewrapper.pyR   0   s    	N(   t   __name__t
   __module__t   __doc__R   R   R   R   R   (    (    (    su   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/filewrapper.pyR      s
   
			N(   t   ioR    t   objectR   (    (    (    su   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/filewrapper.pyt   <module>   s   