mò
­fIc        
   @   sÉ   d  Z  d k Z d k l Z l Z l Z l Z l Z l Z l	 Z	 d k
 l Z e e f Z d d d d d d	 d
 d d d g
 Z d e i f d „  ƒ  YZ d e f d „  ƒ  YZ d e i f d „  ƒ  YZ d S(   sƒ   Weak reference support for Python.

This module is an implementation of PEP 205:

http://python.sourceforge.net/peps/pep-0205.html
N(   s   getweakrefcounts   getweakrefss   refs   proxys   CallableProxyTypes	   ProxyTypes   ReferenceType(   s   ReferenceErrort   reft   proxyt   getweakrefcountt   getweakrefst   WeakKeyDictionaryt   ReferenceTypet	   ProxyTypet   CallableProxyTypet
   ProxyTypest   WeakValueDictionaryc           B   s¹   t  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 e
 d „ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e
 d „ Z e
 d „ Z d „  Z RS(   s›   Mapping class that references values weakly.

    Entries in the dictionary will be discarded when no strong
    reference to the value exists anymore
    c         O   s5   t  |  ƒ d „ } | |  _ t i i |  | | Ž d  S(   Nc         C   s+   | ƒ  } | d  j	 o | i |  i =n d  S(   N(   t   selfreft   selft   Nonet   datat   wrt   key(   R   R
   R   (    (    t$   /mit/python/lib/python2.4/weakref.pyt   remove.   s    	(   R    R   R   t   _removet   UserDictt   __init__t   argst   kw(   R   R   R   R   (    (    R   R   -   s    	c         C   s2   |  i | ƒ  } | d  j o t | ‚ n | Sd  S(   N(   R   R   R   t   oR   t   KeyError(   R   R   R   (    (    R   t   __getitem__5   s    c         C   s8   y |  i | ƒ  } Wn t j
 o t Sn X| d  j	 S(   N(   R   R   R   R   R   t   FalseR   (   R   R   R   (    (    R   t   __contains__<   s
    	c         C   s8   y |  i | ƒ  } Wn t j
 o t Sn X| d  j	 S(   N(   R   R   R   R   R   R   R   (   R   R   R   (    (    R   t   has_keyC   s
    	c         C   s   d t  |  ƒ S(   Ns   <WeakValueDictionary at %s>(   t   idR   (   R   (    (    R   t   __repr__J   s    c         C   s    t  | |  i | ƒ |  i | <d  S(   N(   t   KeyedReft   valueR   R   R   R   (   R   R   R    (    (    R   t   __setitem__M   s    c         C   sQ   t  ƒ  } xA |  i i ƒ  D]0 \ } } | ƒ  } | d  j	 o | | | <q q W| S(   N(	   R	   t   newR   R   t   itemsR   R   R   R   (   R   R   R   R   R"   (    (    R   t   copyP   s    	 	c         C   sQ   y |  i | } Wn t j
 o | Sn$ X| ƒ  } | d  j o | Sn | Sd  S(   N(   R   R   R   R   R   t   defaultR   R   (   R   R   R%   R   R   (    (    R   t   getX   s    		c         C   sW   g  } xJ |  i i ƒ  D]9 \ } } | ƒ  } | d  j	 o | i | | f ƒ q q W| S(   N(	   t   LR   R   R#   R   R   R   R   t   append(   R   R'   R   R   R   (    (    R   R#   e   s     	c         c   sE   x> |  i i ƒ  D]- } | ƒ  } | d  j	 o | i | f Vq q Wd  S(   N(   R   R   t
   itervaluesR   R    R   R   (   R   R   R    (    (    R   t	   iteritemsm   s
     	c         C   s   |  i i ƒ  S(   N(   R   R   t   iterkeys(   R   (    (    R   R+   s   s    c         C   s   |  i i ƒ  S(   N(   R   R   R+   (   R   (    (    R   t   __iter__v   s    c         c   s<   x5 |  i i ƒ  D]$ } | ƒ  } | d  j	 o | Vq q Wd  S(   N(   R   R   R)   R   t   objR   (   R   R-   R   (    (    R   R)   y   s
     	c         C   sE   x> |  i i ƒ  \ } } | ƒ  } | d  j	 o | | f Sq q Wd  S(   Ni   (   R   R   t   popitemR   R   R   R   (   R   R   R   R   (    (    R   R.      s      	c         G   sg   y |  i i | ƒ ƒ  } Wn) t j
 o | o | d Sn ‚  n X| d  j o t | ‚ n | Sd  S(   Ni    (   R   R   t   popR   R   R   R   R   (   R   R   R   R   (    (    R   R/   †   s    c         C   sR   y |  i | } Wn3 t j
 o' t | |  i | ƒ |  i | <| Sn	 X| ƒ  Sd  S(   N(   R   R   R   R   R   R   R%   R   (   R   R   R%   R   (    (    R   t
   setdefault’   s    	c         K   s˜   |  i } | d  j	 o` t | d ƒ p t h  ƒ | ƒ } n x7 | i ƒ  D]% \ } } t
 | |  i | ƒ | | <qI Wn t | ƒ o |  i | ƒ n d  S(   NR#   (   R   R   t   dt   dictR   t   hasattrt   typeR#   R   R   R   R   t   lent   kwargst   update(   R   R2   R6   R1   R   R   (    (    R   R7   ›   s    	 !c         C   sK   g  } x> |  i i ƒ  D]- } | ƒ  } | d  j	 o | i | ƒ q q W| S(   N(   R'   R   R   t   valuesR   R   R   R(   (   R   R'   R   R   (    (    R   R8   ¥   s     	(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R!   R$   R   R&   R#   R*   R+   R,   R)   R.   R/   R0   R7   R8   (    (    (    R   R	   !   s&    															
R   c           B   s&   t  Z d  Z d Z d „  Z d „  Z RS(   s[  Specialized reference that includes a key corresponding to the value.

    This is used in the WeakValueDictionary to avoid having to create
    a function object for each key stored in the mapping.  A shared
    callback object can use the 'key' attribute of a KeyedRef instead
    of getting a reference to the key from an enclosing scope.

    R   c         C   s"   t  i |  | | ƒ } | | _ | S(   N(   R    t   __new__R4   t   obt   callbackR   R   (   R4   R=   R>   R   R   (    (    R   R<   º   s    	c         C   s   t  t |  ƒ i | | ƒ d  S(   N(   t   superR   R   R   R=   R>   (   R   R=   R>   R   (    (    R   R   ¿   s    (   s   key(   R9   R:   R;   t	   __slots__R<   R   (    (    (    R   R   ®   s    	c           B   sÅ   t  Z d  Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 e d „ Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z e d „ Z RS(   s‰   Mapping class that references keys weakly.

    Entries in the dictionary will be discarded when there is no
    longer a strong reference to the key. This can be used to
    associate additional data with an object owned by other parts of
    an application without adding attributes to those objects. This
    can be especially useful with objects that override attribute
    accesses.
    c         C   sF   h  |  _ t |  ƒ d „ } | |  _ | d  j	 o |  i | ƒ n d  S(   Nc         C   s(   | ƒ  } | d  j	 o | i |  =n d  S(   N(   R
   R   R   R   t   k(   RA   R
   R   (    (    R   R   Ð   s    	(   R   R   R    R   R   R2   R   R7   (   R   R2   R   (    (    R   R   Î   s
    		 c         C   s   |  i t | ƒ =d  S(   N(   R   R   R    R   (   R   R   (    (    R   t   __delitem__×   s    c         C   s   |  i t | ƒ S(   N(   R   R   R    R   (   R   R   (    (    R   R   Ú   s    c         C   s   d t  |  ƒ S(   Ns   <WeakKeyDictionary at %s>(   R   R   (   R   (    (    R   R   Ý   s    c         C   s   | |  i t | |  i ƒ <d  S(   N(   R    R   R   R    R   R   (   R   R   R    (    (    R   R!   à   s    c         C   sQ   t  ƒ  } xA |  i i ƒ  D]0 \ } } | ƒ  } | d  j	 o | | | <q q W| S(   N(	   R   R"   R   R   R#   R   R    R   R   (   R   R    R   R   R"   (    (    R   R$   ã   s    	 	c         C   s   |  i i t | ƒ | ƒ S(   N(   R   R   R&   R    R   R%   (   R   R   R%   (    (    R   R&   ë   s    c         C   s7   y t  | ƒ } Wn t j
 o d Sn X| |  i j S(   Ni    (   R    R   R   t	   TypeErrorR   R   (   R   R   R   (    (    R   R   î   s
    	c         C   s7   y t  | ƒ } Wn t j
 o d Sn X| |  i j S(   Ni    (   R    R   R   RC   R   R   (   R   R   R   (    (    R   R   õ   s
    	c         C   sW   g  } xJ |  i i ƒ  D]9 \ } } | ƒ  } | d  j	 o | i | | f ƒ q q W| S(   N(	   R'   R   R   R#   R   R    R   R   R(   (   R   R'   R    R   R   (    (    R   R#   ü   s     	c         c   sH   xA |  i i ƒ  D]0 \ } } | ƒ  } | d  j	 o | | f Vq q Wd  S(   N(   R   R   R*   R   R    R   R   (   R   R   R   R    (    (    R   R*     s
     	c         c   s<   x5 |  i i ƒ  D]$ } | ƒ  } | d  j	 o | Vq q Wd  S(   N(   R   R   R+   R   R-   R   (   R   R-   R   (    (    R   R+   
  s
     	c         C   s
   |  i ƒ  S(   N(   R   R+   (   R   (    (    R   R,     s    c         C   s   |  i i ƒ  S(   N(   R   R   R)   (   R   (    (    R   R)     s    c         C   sK   g  } x> |  i i ƒ  D]- } | ƒ  } | d  j	 o | i | ƒ q q W| S(   N(   R'   R   R   t   keysR   R   R   R(   (   R   R'   R   R   (    (    R   RD     s     	c         C   sE   x> |  i i ƒ  \ } } | ƒ  } | d  j	 o | | f Sq q Wd  S(   Ni   (   R   R   R.   R   R    R   R   (   R   R   R    R   (    (    R   R.     s      	c         G   s   |  i i t | ƒ | Œ S(   N(   R   R   R/   R    R   R   (   R   R   R   (    (    R   R/   %  s    c         C   s   |  i i t | |  i ƒ | ƒ S(   N(   R   R   R0   R    R   R   R%   (   R   R   R%   (    (    R   R0   (  s    c         K   s•   |  i } | d  j	 o] t | d ƒ p t h  ƒ | ƒ } n x4 | i ƒ  D]" \ } } | | t
 | |  i ƒ <qI Wn t | ƒ o |  i | ƒ n d  S(   NR#   (   R   R   R1   R2   R   R3   R4   R#   R   R    R    R   R5   R6   R7   (   R   R2   R6   R1   R    R   (    (    R   R7   +  s    	 (   R9   R:   R;   R   R   RB   R   R   R!   R$   R&   R   R   R#   R*   R+   R,   R)   RD   R.   R/   R0   R7   (    (    (    R   R   Ã   s(   	 																(   R;   R   t   _weakrefR   R   R    R   R   R   R   t
   exceptionst   ReferenceErrorR   t   __all__R	   R   R   (   R   R   RH   R   R   R   R   R	   R   R   R   R   R    RG   (    (    R   t   ?   s   	1	$