Your IP : 216.73.216.213
B
R^� � @ s� d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlm Z ddl
mZ ddl
mZ dd l
m
Z
dd
l
mZ ddl
mZ ddlmZmZmZ d
dgZefZddd�Zdd� Zddd�Zddd
�Zej e_ dZeef�Zdd� Zdd� ZdS )z!Verify interface implementations
� )�print_functionN)�FunctionType)�
MethodType)�PYPY2)�BrokenImplementation)�BrokenMethodImplementation)�DoesNotImplement)�Invalid)�MultipleInvalid)�
fromMethod�fromFunction�Method�verifyObject�verifyClassFc C s� |dkr| j }n| j}g }|s6||�s6|�t| |�� xZ| jdd�D ]J\}}yt| ||||� W qD tk
r� } z|�|� W dd}~X Y qDX qDW |r�t|�dkr�|d �t| ||��dS )a�
Verify that *candidate* might correctly provide *iface*.
This involves:
- Making sure the candidate claims that it provides the
interface using ``iface.providedBy`` (unless *tentative* is `True`,
in which case this step is skipped). This means that the candidate's class
declares that it `implements <zope.interface.implementer>` the interface,
or the candidate itself declares that it `provides <zope.interface.provider>`
the interface
- Making sure the candidate defines all the necessary methods
- Making sure the methods have the correct signature (to the
extent possible)
- Making sure the candidate defines all the necessary attributes
:return bool: Returns a true value if everything that could be
checked passed.
:raises zope.interface.Invalid: If any of the previous
conditions does not hold.
.. versionchanged:: 5.0
If multiple methods or attributes are invalid, all such errors
are collected and reported. Previously, only the first error was reported.
As a special case, if only one such error is present, it is raised
alone, like before.
�cT)�allN� r ) Z
implementedByZ
providedBy�appendr ZnamesAndDescriptions�_verify_elementr �lenr
) �iface� candidate� tentative�vtype�testerZexcs�name�desc�e� r �H/opt/alt/python37/lib64/python3.7/site-packages/zope/interface/verify.py�_verify* s r c C sV yt ||�}W n6 tk
rD t|t�s4|dkr4d S t| ||��Y nX t|t�sTd S t�|�sht�|�rld S t|t�r�t j
d dkr�t|t�r�|dkr�t|| |dd�}nt|| |d�}nZt|t
�r�t|j�tkr�t|| |�}n4t|t�r�|dkr�d S t|��st|d|| |��d S t|�� |�� �}|�rRt�rBt|||��rBd S t|||| |��d S )Nr r � r )r Zimlevel)r zimplementation is not a method)�getattr�AttributeError�
isinstancer
r �inspect�ismethoddescriptor� isbuiltinr �sys�version_info�typer �MethodTypes�__func__r �property�callabler � _incompatZgetSignatureInfor �_pypy2_false_positive)r r r r r �attr�methZmessr r r r ` s:
r c C s t | ||dd�S )zF
Verify that the *candidate* might correctly provide *iface*.
r )r )r )r r r r r r r � s c C s t | ||dd�S )N�o)r )r )r r r r r r r � s z*implementation requires too many argumentsc C s<