Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/zope/interface/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/zope/interface/__pycache__/verify.cpython-37.pyc

B

R^� �@s�dZddlmZddlZddlZddlmZddlmZddlm	Z	ddl
mZddl
mZdd	l
m
Z
dd
l
mZddl
mZddlmZmZmZd
dgZefZddd�Zdd�Zddd�Zddd
�Zeje_dZeef�Zdd�Zdd�ZdS)z!Verify interface implementations
�)�print_functionN)�FunctionType)�
MethodType)�PYPY2)�BrokenImplementation)�BrokenMethodImplementation)�DoesNotImplement)�Invalid)�MultipleInvalid)�
fromMethod�fromFunction�Method�verifyObject�verifyClassFc	Cs�|dkr|j}n|j}g}|s6||�s6|�t||��xZ|jdd�D]J\}}yt|||||�WqDtk
r�}z|�|�Wdd}~XYqDXqDW|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�appendrZnamesAndDescriptions�_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 cCsVyt||�}Wn6tk
rDt|t�s4|dkr4dSt|||��YnXt|t�sTdSt�|�sht�|�rldSt|t�r�t	j
ddkr�t|t�r�|dkr�t|||dd�}nt|||d�}nZt|t
�r�t|j�tkr�t|||�}n4t|t�r�|dkr�dSt|��st|d|||��dSt|��|���}|�rRt�rBt|||��rBdSt|||||��dS)Nrr�r)rZimlevel)rzimplementation is not a method)�getattr�AttributeError�
isinstancer
r�inspect�ismethoddescriptor�	isbuiltinr�sys�version_info�typer�MethodTypes�__func__r�property�callabler�	_incompatZgetSignatureInfor�_pypy2_false_positive)rrrrr�attr�methZmessrrrr`s:

 



rcCst|||dd�S)zF
    Verify that the *candidate* might correctly provide *iface*.
    r)r)r )rrrrrrr�scCst|||dd�S)N�o)r)r )rrrrrrr�sz*implementation requires too many argumentscCs<|tkrdStt���}|dkr$|nt|�}||kr8dSdS)NFrT)�_KNOWN_PYPY2_FALSE_POSITIVES�vars�__builtins__�valuesr*)�msgrrZknown_builtin_typesZcandidate_typerrrr0�sr0cCslt|d�t|d�krtSt|d�t|d�kr@|ds@dS|drT|dsTdS|drh|dshdSdS)N�required�
positional�varargsz-implementation doesn't allow enough arguments�kwargsz0implementation doesn't support keyword argumentsz1implementation doesn't support variable arguments)r�
_MSG_TOO_MANY)r9Zimplementedrrrr/�sr/)FN)F)F)�__doc__�
__future__rr%r(�typesrrZzope.interface._compatrZzope.interface.exceptionsrrrr	r
Zzope.interface.interfacerrr
�__all__r+r rrrr=�	frozensetr4r0r/rrrr�<module>s2
6E