o
    +׾g:                     @   s   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ ddgZefZdddZdd ZdddZdddZej e_ dZdd ZdS )z!Verify interface implementations
    N)FunctionType)
MethodType)BrokenImplementation)BrokenMethodImplementation)DoesNotImplement)Invalid)MultipleInvalid)Method)fromFunction)
fromMethodverifyObjectverifyClassFc           	      C   s   |dkr| j }n| j}g }|s||s|t| | | jddD ]%\}}z
t| |||| W q! tyF } z|| W Y d}~q!d}~ww |rYt|dkrS|d t| ||dS )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   )	implementedBy
providedByappendr   namesAndDescriptions_verify_elementr   lenr   )	iface	candidate	tentativevtypetesterexcsnamedesce r    _/var/www/html/backend_erp/backend_erp_env/lib/python3.10/site-packages/zope/interface/verify.py_verify)   s$    r"   c                 C   s(  zt ||}W n ty    t|ts|dkrY d S t| ||w t|ts(d S t|s2t|r4d S t|trSt|t	rK|dkrKt
|| |dd}n4t
|| |d}n,t|trft	|jtu rft|| |}nt|trq|dkrqd S t|s}t|d|| |d S t| | }|rt|||| |d S )Nr   r   )r   imlevel)r   zimplementation is not a method)getattrAttributeError
isinstancer	   r   inspectismethoddescriptor	isbuiltinr   typer
   MethodTypes__func__r   propertycallabler   	_incompatgetSignatureInfo)r   r   r   r   r   attrmethmessr    r    r!   r   _   s:   


r   c                 C      t | ||ddS )zF
    Verify that the *candidate* might correctly provide *iface*.
    r   r   r"   r   r   r   r    r    r!   r      s   c                 C   r4   )Nor5   r6   r7   r    r    r!   r      s   z*implementation requires too many argumentsc                 C   sp   t |d t | d krtS t |d t | d k r |d s dS | d r*|d s*dS | d r4|d s6dS d S d S )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)r9   implementedr    r    r!   r/      s   r/   )FN)F)__doc__r'   systypesr   r   zope.interface.exceptionsr   r   r   r   r   zope.interface.interfacer	   r
   r   __all__r+   r"   r   r   r   r=   r/   r    r    r    r!   <module>   s0   
6
B
