
    cT
              	       P    d Z dZ G d de      ZdededefdZddeded	edd
fdZy
)zBases class for interfaces to provide 'light' interface handling.

 TODO:
  _ implements a check method which check that an object implements the interface
  _ Attribute objects

This module requires at least python 2.2
zrestructuredtext enc                   *    e Zd ZdZededefd       Zy)	InterfacezBase class for interfaces.instancereturnc                     t        ||       S )N)
implements)clsr   s     :/usr/lib/python3/dist-packages/logilab/common/interface.pyis_implemented_byzInterface.is_implemented_by    s    (C((    N)__name__
__module____qualname____doc__classmethodtypeboolr
    r   r	   r   r      s%    $) )$ ) )r   r   obj	interfacer   c                 z    t        | dd      }t        |t        t        f      s|f}|D ]  }t	        ||      s y y)z^Return true if the give object (maybe an instance or class) implements
    the interface.
    __implements__r   TF)getattr
isinstancelisttuple
issubclass)r   r   kimplementsimplementedinterfaces       r	   r   r   %   sK     #/4KkD%=1"n + *I6 r   klass_recursNc                 `   t        | |      se	 | j                  }t        |      }t        |      }|j                  |        ||      | _        | j                         D ]  }t        ||d        y|r$| j                         D ]  }t        ||d        yy# t        $ r t
        }g }Y |w xY w)zAdd interface to klass'__implements__ if not already implemented in.

    If klass is subclassed, ensure subclasses __implements__ it as well.

    NOTE: klass should be e new class.
    T)r    N)	r   r   r   r   AttributeErrorr   append__subclasses__extend)r   r   r    r   kimplementsklasssubklasss         r	   r%   r%   2   s     eY'	..K#K0{+K 	9%/<,,. 	6H8Y5	6	,,. 	6H8Y5	6 
  	$K	s   "B B-,B-)F)r   __docformat__objectr   r   r   r   r%   r   r   r	   <module>r*      sX   $ &) )
D 
T 
d 
6$ 64 6$ 64 6r   