σ
ΎΓ9Qc           @   sq   d  Z  d d g Z d e f d     YZ d e f d     YZ d e f d     YZ d e e f d     YZ d	 S(
   s[   This module contains variants of certain base types which call registered
hooks on changes.t   Hookablet   HookableSett   HookableTypec           B   s    e  Z d    Z e d    Z RS(   c         C   s½   | j  d  r§ y | d } WnY t k
 rx d  } xC t d   |  D]+ } | rk t d t |    qF | } qF Wn Xx+ | d D] } t j | |  | | <q Wn  t j	 |  | | |  S(   Nt   _hookable_change_methodst   _hookable_base_classc         S   s
   |  t  k S(   N(   R    (   t   x(    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   <lambda>$   s    s   too many base classes: %s(
   t   has_keyt   KeyErrort   Nonet   filtert	   TypeErrort   strR   t   wrap_methodt   typet   __new__(   t   clst   namet   basest   dctt   baset   base_candidatet
   methodname(    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyR      s    c            s+   t  | |      f d   } | | _ | S(   Nc            s      |  | |  } |  j    | S(   N(   t
   _run_hooks(   t   selft   pt   kt   retval(   t   func(    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   methodwrapper4   s    
(   t   getattrt	   func_name(   R   R   R   R   (    (   R   s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyR   0   s    	(   t   __name__t
   __module__R   t   classmethodR   (    (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyR      s   	t
   _HookEntryc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   _HookEntry__hookt   _HookEntry__argst   _HookEntry__kwargs(   R   t   hookt   argst   kwargs(    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   __init__?   s    		c         C   s4   |  j  | j  k o3 |  j | j k o3 |  j | j k S(   N(   R$   R%   R&   (   R   t   obj(    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   __cmp__E   s    $c         C   s-   |  j  j   |  j j   A|  j j   j   AS(   N(   R$   t   __hash__R%   R&   t	   iteritems(   R   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyR-   I   s    c         C   s   |  j  |  j |  j   d  S(   N(   R$   R%   R&   (   R   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   runM   s    (   R    R!   R*   R,   R-   R/   (    (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyR#   =   s   			c           B   s   e  Z d  Z e Z e d    Z d   Z d   Z e e e  Z	 d   Z
 d   Z e e
 e  Z d   Z d   Z d   Z d	   Z d
   Z RS(   s2   An object which calls registered hooks on changes.c         O   s%   t  |  d  s t   |  _ n  |  j S(   Nt   __real_hooks__(   t   hasattrt   setR0   (   R   R   R   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt	   __hooks__W   s    c         C   s"   t  |  d  s t |  _ n  |  j S(   Nt   __hooks_enabled__(   R1   t   TrueR4   (   R   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   _get_hooks_enabled]   s    c         C   s   | |  _  d  S(   N(   R4   (   R   t   enabled(    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   _set_hooks_enabledb   s    c         C   s"   t  |  d  s t |  _ n  |  j S(   Nt   __hooks_frozen__(   R1   t   FalseR9   (   R   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   _get_hooks_frozeng   s    c         C   sY   | |  j  k r d  S| |  _ | r1 t   |  _ n$ x |  j D] } | j   q; W|  ` d  S(   N(   t   hooks_frozenR9   R2   t   __hooks_frozen_entries__R/   (   R   t   freezet	   hookentry(    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   _set_hooks_frozenl   s    	c         C   s   t  |  _ d  S(   N(   R5   R<   (   R   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   freeze_hooks{   s    c         C   s   t  |  _ d  S(   N(   R:   R<   (   R   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt
   thaw_hooks~   s    c         O   s&   t  | | |  } |  j j |  d  S(   N(   R#   R3   t   add(   R   R'   R(   R)   R?   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   add_hook   s    c         O   s    |  j  j t | | |   d  S(   N(   R3   t   removeR#   (   R   R'   R(   R)   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   remove_hook   s    c         C   sM   |  j  rI |  j s3 x1 |  j D] } | j   q WqI |  j j |  j  n  d  S(   N(   t   hooks_enabledR<   R3   R/   R=   t   update(   R   R?   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyR      s
    		(   R    R!   t   __doc__R   t   __metaclass__t   propertyR3   R6   R8   RG   R;   R@   R<   RA   RB   RD   RF   R   (    (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyR    Q   s   								c        	   B   s   e  Z d  Z d Z d
   Z RS(   s5   A set object which calls registered hooks on changes.RC   t   cleart   difference_updatet   discardt   intersection_updatet   popRE   t   symmetric_difference_updateRH   c         C   s   t  j |   } t    | _ | S(   N(   R2   t   copyR0   (   R   R+   (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyRR      s    (	   s   adds   clears   difference_updates   discards   intersection_updates   pops   removes   symmetric_difference_updates   update(   R    R!   RI   R   RR   (    (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyR      s
     N(	   RI   t   __all__R   R   t   objectR#   R    R2   R   (    (    (    s6   /usr/lib/python2.7/site-packages/slip/util/hookable.pyt   <module>   s
   "C