ó
P'^c           @   ső   d  d l  m Z m Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d d d	 d
 d d g Z d e f d     YZ d e f d     YZ d   Z d d  Z d e f d     YZ d e f d     YZ d e f d     YZ d S(   i˙˙˙˙(   t   isclasst   ismodulei   (   t   PY2(   t   walk_values(   t   iffy(   t
   cut_prefixt   cached_propertyt   cached_readonlyt	   wrap_propt   monkeyt	   namespacet
   LazyObjectc           B   s-   e  Z d  Z d Z Z d   Z d d  Z RS(   sr   
    Decorator that converts a method with a single self argument into
    a property cached on the instance.
    c         C   s   | |  _  t | d  |  _ d  S(   Nt   __doc__(   t   fgett   getattrR   (   t   selfR   (    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyt   __init__   s    	c         C   s4   | d  k r |  S|  j |  } | j |  j j <| S(   N(   t   NoneR   t   __dict__t   __name__(   R   t   instancet   typet   res(    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyt   __get__   s     N(   R   t
   __module__R   R   t   fsett   fdelR   R   (    (    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR      s   
	c           B   s   e  Z d  Z d   Z RS(   s9   Same as @cached_property, but protected against rewrites.c         C   s   t  d   d  S(   Ns   property is read-only(   t   AttributeError(   R   R   t   value(    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyt   __set__"   s    (   R   R   R   R   (    (    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR       s   c            s     f d   } | S(   s0   Wrap a property accessors with a context managerc            s&   d t  f    f d     Y} |   S(   Nt   WrapperPropc              st   e  Z  f d    Z d    f d  Z e  d  rN    f d   Z n  e  d  rr    f d   Z n  RS(   c            s
   t     S(   N(   t   repr(   R   (   t   prop(    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyt   __repr__*   s    c            s1   | d  k r |  S    j | |  SWd  QXd  S(   N(   R   R   (   R   R   R   (   t   ctxR    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR   -   s    R   c            s!       j  | |  SWd  QXd  S(   N(   R   (   R   t   nameR   (   R"   R    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR   5   s    t   __del__c            s       j  |  SWd  QXd  S(   N(   R$   (   R   R#   (   R"   R    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR$   :   s    N(   R   R   R!   R   R   t   hasattrR   R$   (    (   R"   R    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR   )   s   (   t   object(   R    R   (   R"   (   R    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyt	   decorator(   s    (    (   R"   R'   (    (   R"   s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR   &   s    c            s:   t     s$ t    s$ t d      f d   } | S(   sĽ   
    Monkey patches class or module by adding to it decorated function.

    Anything overwritten could be accessed via .original attribute of decorated object.
    s3   Attempting to monkey patch non-class and non-modulec            sc   t  |  d |   }  p. t | j d   j  } | | _ t    | d   | _ t   | |   |  S(   NR   s   %s__(   R   R   R   R   t   originalt   setattr(   R   t   funct	   func_name(   t   clsR#   (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR'   J   s    	(   R    R   t   AssertionError(   R,   R#   R'   (    (   R,   R#   s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR	   B   s    $	t   namespace_metac           B   s   e  Z d    Z RS(   c         C   s7   t  t t t  |  } t t |   j |  | | |  S(   N(   R   R   t   callablet   staticmethodt   superR.   t   __new__(   R,   R#   t   basest   attrs(    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR2   Z   s    (   R   R   R2   (    (    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR.   Y   s   c           B   s   e  Z d  Z e r e Z n  RS(   sE   A base class that prevents its member functions turning into methods.(   R   R   R   R   R.   t   __metaclass__(    (    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR
   ^   s   c           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s]   
    A simplistic lazy init object.
    Rewrites itself when any attribute is accesssed.
    c         C   s   | |  j  d <d  S(   Nt   _init(   R   (   R   t   init(    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR   k   s    c         C   s<   |  j    } t j |  d | j  t j |  d | j  d  S(   Nt	   __class__R   (   R6   R&   t   __setattr__R8   R   (   R   t   obj(    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyt   _setupn   s    c         C   s   |  j    t |  |  S(   N(   R;   R   (   R   R#   (    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyt   __getattr__s   s    
c         C   s   |  j    t |  | |  S(   N(   R;   R)   (   R   R#   R   (    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR9   w   s    
(   R   R   R   R   R;   R<   R9   (    (    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyR   d   s
   			N(   t   inspectR    R   t   compatR   t   collsR   t   funcsR   t   stringsR   t   __all__R&   R   R   R   R   R	   R   R.   R
   R   (    (    (    s/   /tmp/pip-unpacked-wheel-WgnHs6/funcy/objects.pyt   <module>   s   	