Your IP : 216.73.216.213
B
�d{T!
� @ s. d Z dZG dd� de�Zdd� Zd
dd�Zd S )z�Bases 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
zrestructuredtext enc @ s e Zd ZdZdd� Zee�ZdS )� InterfacezBase class for interfaces.c C s
t || �S )N)�
implements)�cls�instance� r �I/opt/alt/python37/lib/python3.7/site-packages/logilab/common/interface.py�is_implemented_by s zInterface.is_implemented_byN)�__name__�
__module__�__qualname__�__doc__r �classmethodr r r r r s r c C s@ t | dd�}t|ttf�s |f}x|D ]}t||�r&dS q&W dS )z^Return true if the give object (maybe an instance or class) implements
the interface.
�__implements__r TF)�getattr�
isinstance�list�tuple�
issubclass)�obj� interface�kimplementsZimplementedinterfacer r r r % s
r Fc C s� t | |�sxy| j}t|�}t|�}W n tk
r@ t}g }Y nX |�|� ||�| _xD| �� D ]}t||dd� q`W n$|r�x| �� D ]}t||dd� q�W dS )z�Add 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)�_recursN) r r
�typer �AttributeErrorr �append�__subclasses__�extend)�klassr r r ZkimplementsklassZsubklassr r r r 2 s
r N)F)r �
__docformat__�objectr r r r r r r �<module> s