ó
[³XMc           @   s  d  Z  d d l m Z m Z y d d l m Z Wn d d l m Z e Z n Xd d d „  ƒ  YZ d e f d „  ƒ  YZ	 d	 e	 f d
 „  ƒ  YZ
 d e f d „  ƒ  YZ d d d „  ƒ  YZ d e f d „  ƒ  YZ d d l m Z d d d „  ƒ  YZ d e e f d „  ƒ  YZ d S(   s7   
Utility classes for dealing with circular references.
iÿÿÿÿ(   t   logt   reflect(   t   instancemethod(   t   PyMethodt   NotKnownc           B   s2   e  Z d  „  Z d „  Z d Z d „  Z d „  Z RS(   c         C   s   g  |  _  d |  _ d  S(   Ni    (   t
   dependantst   resolved(   t   self(    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyt   __init__   s    	c         C   s*   |  j  s t ‚ |  j j | | f ƒ d  S(   N(   R   t   AssertionErrorR   t   append(   R   t   mutableObjectt   key(    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyt   addDependant   s    c         C   s\   d |  _  | |  _ xC |  j D]8 \ } } | | | <t | t ƒ r | j | | ƒ q q Wd  S(   Ni   (   R   t   resolvedObjectR   t
   isinstanceR   R   (   R   t	   newObjectt   mutR   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyt   resolveDependants   s    		
c         C   s   d s t  d ‚ d  S(   Ni    s(   I am not to be used as a dictionary key.(   R	   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyt   __hash__'   s    N(   t   __name__t
   __module__R   R   t   NoneR   R   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR      s
   			t
   _Containerc           B   s    e  Z d  Z d „  Z d „  Z RS(   sK   
    Helper class to resolve circular references on container objects.
    c         C   s´   t  j |  ƒ | |  _ | |  _ t t | ƒ ƒ |  _ xT t t | ƒ ƒ D]@ } t | | t  ƒ ss |  j j	 | ƒ qG | | j
 |  | ƒ qG W|  j s° |  j |  j |  j ƒ ƒ n  d S(   sÌ   
        @param l: The list of object which may contain some not yet referenced
        objects.

        @param containerType: A type of container objects (e.g., C{tuple} or
            C{set}).
        N(   R   R   t   containerTypet   lt   ranget   lent   locst   xrangeR   t   removeR   R   (   R   R   R   t   idx(    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR   1   s    			c         C   sX   | |  j  | <t | t ƒ sT |  j j | ƒ |  j sT |  j |  j |  j  ƒ ƒ qT n  d S(   s€   
        Change the value of one contained objects, and resolve references if
        all objects have been referenced.
        N(   R   R   R   R   R   R   R   (   R   t   nt   obj(    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyt   __setitem__F   s
    	(   R   R   t   __doc__R   R"   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR   ,   s   	t   _Tuplec           B   s   e  Z d  Z d „  Z RS(   sa   
    Manage tuple containing circular references. Deprecated: use C{_Container}
    instead.
    c         C   s   t  j |  | t ƒ d S(   si   
        @param l: The list of object which may contain some not yet referenced
        objects.
        N(   R   R   t   tuple(   R   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR   Y   s    (   R   R   R#   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR$   S   s   t   _InstanceMethodc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s3   t  j |  ƒ | |  _ | |  _ | j |  d ƒ d  S(   Ni    (   R   R   t   my_classt   nameR   (   R   t   im_namet   im_selft   im_class(    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR   c   s    		c         O   sl   d d  l  } t j d t j |  j ƒ |  j f ƒ t j d | | f ƒ | j d t j ƒ d sh t	 ‚ d  S(   Niÿÿÿÿs   instance method %s.%ss   being called with %r %rt   filei    (
   t	   tracebackR    t   msgR   t   qualR'   R(   t   print_stackt   logfileR	   (   R   t   argst   kwR-   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyt   __call__j   s
    &c         C   sT   | d k s t  d ‚ t | t ƒ sP |  j t |  j j |  j | |  j ƒ ƒ n  d  S(   Ni    s   only zero index allowed(   R	   R   R   R   R   R'   t   __dict__R(   (   R   R    R!   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR"   q   s
    (   R   R   R   R4   R"   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR&   b   s   		t   _DictKeyAndValuec           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  d  S(   N(   t   dict(   R   R7   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR   y   s    c         C   sn   | d k r t  d ƒ ‚ n  | r- | |  _ n	 | |  _ t |  d ƒ rj t |  d ƒ rj |  j |  j |  j <n  d  S(   Ni   i    s6   DictKeyAndValue should only ever be called with 0 or 1R   t   value(   i   i    (   t   RuntimeErrorR8   R   t   hasattrR7   (   R   R    R!   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR"   {   s    	(   R   R   R   R"   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR6   x   s   	t   _Dereferencec           B   s   e  Z d  „  Z RS(   c         C   s   t  j |  ƒ | |  _ d  S(   N(   R   R   t   id(   R   R<   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR   ‡   s    (   R   R   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR;   †   s   (   t   Deferredt   _Catcherc           B   s   e  Z d  „  Z RS(   c         C   s   | |  _  d  S(   N(   R8   (   R   R8   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyt   catch   s    (   R   R   R?   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR>   Ž   s   t   _Deferc           B   s)   e  Z d  „  Z d Z d „  Z d „  Z RS(   c         C   s(   t  j |  ƒ t j |  ƒ |  j ƒ  d  S(   N(   R=   R   R   t   pause(   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR   “   s    i    c         C   s<   |  j  r" t d | | f ƒ ‚ n	 d |  _  |  j | ƒ d  S(   Ns4   setitem should only be called once, setting %r to %ri   (   t   wassetR9   t   callback(   R   R    R!   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR"   š   s    		c         C   s7   t  j |  | | ƒ |  j ƒ  |  j } |  j | ƒ d  S(   N(   R   R   t   unpauset   resultR   (   R   t   depR   t   resovd(    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR   ¡   s    
	(   R   R   R   RB   R"   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyR@   ’   s   		N(    (    (    (   R#   t   twisted.pythonR    R   t   newR   t   org.python.coreR   R   R   R$   R&   R6   R;   t   twisted.internet.deferR=   R>   R@   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/persisted/crefutil.pyt   <module>	   s   
'