HEX
Server: Apache/2.4.65 (Debian)
System: Linux kubikelcreative 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User: www-data (33)
PHP: 8.4.13
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/zope/interface/__pycache__/interface.cpython-39.pyc
a

��_���@sdZddlZddlmZddlmZddlZddlmZddlmZ	ddl
mZddlm
Zddlm
Z
gd	�Zd
ZdZdZd
Ze�Ze�Zdd�Zdd�ZGdd�de�ZeZeGdd�de��ZGdd�de�ZeGdd�dee��Zegd�ZGdd�de�Z Gdd�de!�Z"e"dee efd d!i�Z#d"d#�Z$Gd$d�de#�Z%e%d%d&d'�Z&d(d)�e&_'e&�(e&�e&j)e&fk�stJ�e&e _*e&e
_*Gd*d+�d+e%�Z+Gd,d-�d-e�Z,Gd.d/�d/e,�Z-d;d0d1�Z.d<d2d3�Z/d4d5�Z0dd6l1m2Z2dd7l1m3Z3dd8l
m4Z4dd9l
m5Z5dd:l1m6Z6e �(e6e6�dS)=z Interface object implementation
�N)�
MethodType)�FunctionType)�_use_c_impl)�PYTHON2)�Invalid)�ro)�InterfaceClass�
Specification�
adapter_hooks��Z__interface_tagged_values__Z__interface_methods__cCs2t�d�j}|�ti�}|�dg�}|�|�tS)N��
invariants)�sys�	_getframe�f_locals�
setdefault�TAGGED_DATA�append�_decorator_non_return)ZcallrZtagsr�r�:/usr/lib/python3/dist-packages/zope/interface/interface.py�	invariant2s

rcCs$t�d�j}|�ti�}|||<tS)z;Attaches a tagged value to an interface at definition time.r
)rrrrrr)�key�valuerZ
tagged_valuesrrr�taggedValue:src@sXeZdZdZddd�Zdd�Zdd�Zd	d
�Zddd
�Zdd�Z	dd�Z
eZeZe	Z
dS)�ElementzI
    Default implementation of `zope.interface.interfaces.IElement`.
    �cCs0|s|�d�dkr|}d}||_||_d|_dS)N� r)�find�__name__�__doc__�_Element__tagged_values)�selfr r!rrr�__init__LszElement.__init__cCs|jS)z! Returns the name of the object. �r �r#rrr�getNameWszElement.getNamecCs|jS)z+ Returns the documentation for the object. )r!r&rrr�getDoc[szElement.getDoccCs|jst|��|j|S��* Returns the value associated with 'tag'. )r"�KeyError)r#�tagrrr�getTaggedValuefszElement.getTaggedValueNcCs|jr|j�||�S|Sr))r"�get)r#r,�defaultrrr�queryTaggedValuelszElement.queryTaggedValuecCs|jr|j��SdS)z# Returns a collection of all tags. r)r"�keysr&rrr�getTaggedValueTagspszElement.getTaggedValueTagscCs|jduri|_||j|<dS)z  Associates 'value' with 'key'. N)r"�r#r,rrrr�setTaggedValuets
zElement.setTaggedValue)r)N)r �
__module__�__qualname__r!r$r'r(r-r0r2r4�queryDirectTaggedValueZgetDirectTaggedValue�getDirectTaggedValueTagsrrrrrBs	

rc@s,eZdZdZdd�Zdd�Zdd�ZeZdS)	�SpecificationBase)�_implied�_dependents�_bases�_v_attrs�__iro__�__sro__�__weakref__cCst|�}||jvS)z2Is the interface implemented by an object
        )�
providedByr:)r#�ob�specrrrrA�szSpecificationBase.providedBycCst|�}||jvS)z�Test whether the specification is implemented by a class or factory.

        Raise TypeError if argument is neither a class nor a callable.
        )�
implementedByr:)r#�clsrCrrrrD�szSpecificationBase.implementedBycCs
||jvS)zCIs the interface the same as or extend the given interface
        �r:)r#�	interfacerrr�isOrExtends�szSpecificationBase.isOrExtendsN)r r5r6�	__slots__rArDrH�__call__rrrrr9�s

r9c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�NameAndModuleComparisonMixinrcCs\||urdS|durdS|j|jf}z|j|jf}WntyJtYS0||k||kS)a�
        Compare *self* to *other* based on ``__name__`` and ``__module__``.

        Return 0 if they are equal, return 1 if *self* is
        greater than *other*, and return -1 if *self* is less than
        *other*.

        If *other* does not have ``__name__`` or ``__module__``, then
        return ``NotImplemented``.

        .. caution::
           This allows comparison to things well outside the type hierarchy,
           perhaps not symmetrically.

           For example, ``class Foo(object)`` and ``class Foo(Interface)``
           in the same file would compare equal, depending on the order of
           operands. Writing code like this by hand would be unusual, but it could
           happen with dynamic creation of types and interfaces.

        None is treated as a pseudo interface that implies the loosest
        contact possible, no contract. For that reason, all interfaces
        sort before None.
        rN���)r r5�AttributeError�NotImplemented)r#�otherZn1Zn2rrr�_compare�s
z%NameAndModuleComparisonMixin._comparecCs|�|�}|tur|S|dkS�Nr�rPrN�r#rO�crrr�__lt__�s
z#NameAndModuleComparisonMixin.__lt__cCs|�|�}|tur|S|dkSrQrRrSrrr�__le__�s
z#NameAndModuleComparisonMixin.__le__cCs|�|�}|tur|S|dkSrQrRrSrrr�__gt__�s
z#NameAndModuleComparisonMixin.__gt__cCs|�|�}|tur|S|dkSrQrRrSrrr�__ge__�s
z#NameAndModuleComparisonMixin.__ge__N)	r r5r6rIrPrUrVrWrXrrrrrK�s'rKc@s^eZdZdZdZddd�Zdd�Zedd	��Ze	fd
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)�
InterfaceBasez:Base class that wants to be replaced with a C base :)
    )r �__ibmodule__�_v_cached_hashNcCs||_||_dS�N)r rZ)r#�name�modulerrrr$
szInterfaceBase.__init__cCst�dSr\)�NotImplementedError�r#�conformrrr�
_call_conformszInterfaceBase._call_conformcCs|jSr\)rZr&rrr�__module_property__sz!InterfaceBase.__module_property__cCsrz
|j}Wnty d}Yn0|dur@|�|�}|dur@|S|�|�}|durV|S|turb|Std||��dS)z)Adapt an object to the interface
        NzCould not adapt)Z__conform__rMrb�	__adapt__�_marker�	TypeError)r#�objZ	alternatera�adapterrrrrJs



zInterfaceBase.__call__cCs6|�|�r|StD]}|||�}|dur|SqdS)z(Adapt an object to the receiver
        N)rAr
)r#rg�hookrhrrrrd+s


zInterfaceBase.__adapt__cCs4z|jWSty,t|j|jf�|_Yn0|jSr\)r[rM�hashr r5r&rrr�__hash__8s
zInterfaceBase.__hash__cCs|�|�}|tur|S|dkSrQrRrSrrr�__eq__@s
zInterfaceBase.__eq__cCs*||urdS|�|�}|tur"|S|dkS)NFrrRrSrrr�__ne__Fs
zInterfaceBase.__ne__)NN)r r5r6r!rIr$rb�propertyrcrerJrdrkrlrmrrrrrY�s


rYr
c@s�eZdZdZdZdZejZejZddd�Z	e
dd��Zdd	�Zd
d�Z
dd
�Ze
dd�e�Zdd�Zdd�Zdd�Zddd�Zddd�Zd dd�ZdS)!r	awSpecifications

    An interface specification is used to track interface declarations
    and component registrations.

    This class is a base class for both interfaces themselves and for
    interface specifications (declarations).

    Specifications are mutable.  If you reassign their bases, their
    relations with other specifications are adjusted accordingly.
    rNcCs2d|_d|_i|_d|_d|_d|_t|�|_dS)Nr)r;r<r:r=r>r?�tuple�	__bases__)r#�basesrrrr$hs	zSpecification.__init__cCs|jdurt��|_|jSr\)r;�weakref�WeakKeyDictionaryr&rrr�
dependentszs

zSpecification.dependentscCs|j�|d�d|j|<dS)Nrr
)rtr.r;)r#�	dependentrrr�	subscribe�szSpecification.subscribecCsZz|j|}Wnty(t|��Yn0|d8}|s@|j|=n|dksLJ�||j|<dS)Nr
r)r;rfr+rt)r#ru�nrrr�unsubscribe�s
zSpecification.unsubscribecCs>|jD]}|�|�q||_|D]}|�|�q |�|�dSr\)rprxr<rv�changed)r#rq�brrrZ
__setBases�s
zSpecification.__setBasescCs|jSr\)r<r&rrr�<lambda>��zSpecification.<lambda>csVt|dd�|jD�d�}|j��durR|rR|d�urR�fdd�|D�}|���|S)z�
        Calculate and return the resolution order for this object, using its ``__bases__``.

        Ensures that ``Interface`` is always the last (lowest priority) element.
        cSsi|]}||j�qSr)r?��.0rzrrr�
<dictcomp>�s�z0Specification._calculate_sro.<locals>.<dictcomp>)Z	base_mrosNrLcsg|]}|�ur|�qSrr)r~�x��rootrr�
<listcomp>�s�z0Specification._calculate_sro.<locals>.<listcomp>)�calculate_rorp�_ROOTr)r#Zsrorr�r�_calculate_sro�s#
�

�
zSpecification._calculate_srocCs~d|_|j}|��|��}t|�|_tdd�|D��|_|D]}d||<q>t|jr^|j��nd�D]}|�	|�qdd|_dS)z�
        We, or something we depend on, have changed.

        By the time this is called, the things we depend on,
        such as our bases, should themselves be stable.
        NcSsg|]}t|t�r|�qSr��
isinstancer)r~�ancestorrrrr��s
�z)Specification.changed.<locals>.<listcomp>r)
r=r:�clearr�ror?r>r;r1ry)r#Zoriginally_changedZimpliedZ	ancestorsr�rurrrry�s

zSpecification.changedccs8i}|jD](}|��D]}||vrd||<|Vqq
dS)�DReturn an iterator for the interfaces in the specification.
        r
N)rp�
interfaces)r#�seen�baserGrrrr��s
zSpecification.interfacesTcCs||jvo|p||kS)z�Does the specification extend the given interface?

        Test whether an interface in the specification extends the
        given interface
        rF)r#rG�strictrrr�extendss
�zSpecification.extendscCst�||�Sr\)rr�ref)r#�callbackrrrrrszSpecification.weakrefcCsd|j}|duri}|_|�|�}|durT|jD]"}|�|�}|dur0|||<qTq0|dur`|S|S)z+Query for an attribute description
        N)r=r.r>�direct)r#r]r/�attrs�attr�ifacerrrr.s



zSpecification.get)r)T)N)N)r r5r6r!rIr�r9rHrAr$rnrtrvrxZ_Specification__setBasesrpr�ryr�r�rrr.rrrrr	Rs*

�9 


r	c@s,eZdZdZdd�Zedd��Zdd�ZdS)	�_InterfaceMetaClassrcCsPt�d�jd}tjd}t|t�r.tjd}||d<t�||||�}||_	|S)Nr
r r5rc)
rr�	f_globalsrY�__dict__r��str�type�__new__�_InterfaceMetaClass__module)rEr]rqr�r5Zmoduledescr�kindrrrr�ms


z_InterfaceMetaClass.__new__cCs|jSr\)r��rErrrr5sz_InterfaceMetaClass.__module__cCsd|j|jfS)Nz<class '%s.%s'>)r�r r�rrr�__repr__�s�z_InterfaceMetaClass.__repr__N)r r5r6rIr�rnr�rrrrr�"s
I
r�rrIrcCs&t�d�j}|�ti�}|||j<tS)a�
    Convert a method specification to an actual method of the interface.

    This is a decorator that functions like `staticmethod` et al.

    The primary use of this decorator is to allow interface definitions to
    define the ``__adapt__`` method, but other interface methods can be
    overridden this way too.

    .. seealso:: `zope.interface.interfaces.IInterfaceDeclaration.interfacemethod`
    r
)rrrr�INTERFACE_METHODSr r)�funcr�methodsrrr�interfacemethod�s
r�c@s�eZdZdZd-dd�Zd.dd�Zdd	�Zd
d�Zdd
�Zdd�Z	d/dd�Z
dd�Zd0dd�Zdd�Z
e
Zdd�Zdd�Zd1dd�Zd2dd �Zd3d!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�ZdS)4rz�
    Prototype (scarecrow) Interfaces Implementation.

    Note that it is not possible to change the ``__name__`` or ``__module__``
    after an instance of this object has been constructed.
    Nrc	Cs�t|t�sJ�|pi}|�td�}|r�|�d|vr@d|�d�ini�d|vrVd|d<t|t�rh|f}n|turxtf}n|tf}t|�|d||�}n@t	r�|r�t
|�dkr�tdd�|D��}|r�t|d|i�jd}t�
|�S)N�
__classcell__rdr
Z_CALL_CUSTOM_ADAPTz<WithCustomMethods>css$|]}tt|�t�rt|�VqdSr\)�
issubclassr�� _InterfaceClassWithCustomMethodsr}rrr�	<genexpr>�s�z)InterfaceClass.__new__.<locals>.<genexpr>)r�ro�popr��updater�r�rr��PY2�len�__mro__�_InterfaceClassBaser�)	rEr]rqr�r!r5Zneeds_custom_classZ	cls_basesZbases_with_custom_methodsrrrr��sD��
����zInterfaceClass.__new__c
	Cs(tdd�|D��std��|dur&i}|durv|�d�}t|t�rJ|d=n,zt�d�jd}Wntt	fytYn0t
�|||�|�d�}|dur�t|t�s�|dur�|}|d=|dur�d}t
�|||�|�td�}|dur�|��D]\}}	|�||	�q�t�||�|�|�|_d	||f|_dS)
Ncss|]}t|t�VqdSr\r�)r~r�rrrr��r|z*InterfaceClass.__init__.<locals>.<genexpr>zExpected base interfacesr5r
r r!r�%s.%s)�allrfr.r�r�rrr�rMr+rYr$�	Attributerr�r�itemsr4r	�_InterfaceClass__compute_attrs�_InterfaceClass__attrsZ__identifier__)
r#r]rqr�r!r5�dZtagged_datar�valrrrr$�s:



zInterfaceClass.__init__cs"�fdd���fdd�|��D�S)NcsHt|t�r�|_|jsD||_n&t|t�r8t|�|d�}ntd|��|S)N)r]zConcrete attribute, )r�r�rGr r�fromFunction�InvalidInterface)�aname�avalr&rr�update_values

z4InterfaceClass.__compute_attrs.<locals>.update_valuecs,i|]$\}}|dvr|tur|�||��qS))Z
__locals__r6�__annotations__)r)r~r�r�)r�rrr%s�z2InterfaceClass.__compute_attrs.<locals>.<dictcomp>)r�)r#r�r)r#r�rZ__compute_attrss
�zInterfaceClass.__compute_attrsccs
|VdS)r�Nrr&rrrr�3szInterfaceClass.interfacescCs|jSr\)rpr&rrr�getBases8szInterfaceClass.getBasescCs||kp|�|�S)zSame interface or extends?)r�)r#rOrrr�isEqualOrExtendedBy;sz"InterfaceClass.isEqualOrExtendedByFcCsB|s|j��S|j��}|jD]}|�t�|�|���q|��S)z4Return the attribute names defined by the interface.)r�r1�copyrpr��dict�fromkeys�names�r#r��rr�rrrr�?s


zInterfaceClass.namescCst|jdd��S)NT)r�)�iterr�r&rrr�__iter__KszInterfaceClass.__iter__cCsP|s|j��Si}|jddd�D]}|�t|�|���q"|�|j�|��S)z=Return attribute names and descriptions defined by interface.NrL)r�r�rpr�r��namesAndDescriptionsr�rrrr�Ns
z#InterfaceClass.namesAndDescriptionscCs"|�|�}|dur|St|��dS)z4Return the attribute description for the given name.N)r.r+)r#r]r�rrr�getDescriptionFor[s
z InterfaceClass.getDescriptionForcCs|�|�duSr\�r.�r#r]rrr�__contains__eszInterfaceClass.__contains__cCs|j�|�Sr\)r�r.r�rrrr�hszInterfaceClass.directcCs|�||�Sr\r�)r#r]r/rrr�queryDescriptionForksz"InterfaceClass.queryDescriptionForcCsv|jD]^}|�dd�D]L}z||�Wqty`}z"|durJ|�|�n�WYd}~qd}~00qq|rrt|��dS)z&validate object to defined invariants.rrN)r>r7rr)r#rg�errorsr�r�errorrrr�validateInvariantsns
z!InterfaceClass.validateInvariantscCs,|jD] }|�|t�}|tur|Sq|S)z�
        Queries for the value associated with *tag*, returning it from the nearest
        interface in the ``__iro__``.

        If not found, returns *default*.
        )r>r7re)r#r,r/r�rrrrr0~s


zInterfaceClass.queryTaggedValuecCs"|j|td�}|turt|��|S)r*)r/)r0rer+r3rrrr-�szInterfaceClass.getTaggedValuecCs$t�}|jD]}|�|���q|S)z Returns a list of all tags. )�setr>r�r8)r#r1r�rrrr2�s
z!InterfaceClass.getTaggedValueTagscCsVz|jWStyP|j}|j}|r2d||f}d|jj|f}||_|YS0dS)Nr�z<%s %s>)Z_v_reprrMr rZ�	__class__)r#r]�mr�rrrr��szInterfaceClass.__repr__cCs6z
||�WSty0t��djdur,�Yn0dS)N�)rfr�exc_info�tb_nextr`rrrrb�s
zInterfaceClass._call_conformcCs|jSr\r%r&rrr�
__reduce__�szInterfaceClass.__reduce__)NrNNN)rNNN)F)F)N)N)N)r r5r6r!r�r$r�r�r�r�r�r�r�r��__getitem__r�r�r�r�r0r-r2r�rbr�rrrrr�s4�
3�
3






�	Interfacezzope.interface)r5cCstfSr\)r�rrrrr{�r|r{c@seZdZdZdS)r�z_
    Marker class for interfaces with custom methods that override InterfaceClass methods.
    N)r r5r6r!rrrrr��sr�c@s,eZdZdZdZdd�Zdd�Zdd�ZdS)	r�zAttribute descriptions
    NcCsdS)z/Return extra data to put at the end of __str__.rrr&rrr�
_get_str_info�szAttribute._get_str_infocCs<d}|jdur&|jjd|jjd}||jp0d|��S)Nr�.z	<unknown>)rGr5r r�)r#Zofrrr�__str__�s
zAttribute.__str__cCs dt|�jt|�jt|�|fS)Nz<%s.%s object at 0x%x %s>)r�r5r �idr&rrrr��s�zAttribute.__repr__)r r5r6r!rGr�r�r�rrrrr��s
r�c@sdeZdZdZdZZdZZZdd�Z	dd�Z
dd	�Zee	e
e�Z
d
d�Zdd
�Zdd�ZeZdS)�Methodz�Method interfaces

    The idea here is that you have objects that describe methods.
    This provides an opportunity for rich meta-data.
    rNcCs|jduriS|jSr\��	_optionalr&rrr�
_get_optional�s
zMethod._get_optionalcCs
||_dSr\r�)r#�optrrr�
_set_optional�szMethod._set_optionalcCs
d|_dSr\r�r&rrr�
_del_optional�szMethod._del_optionalcOst|j|j��dSr\)�BrokenImplementationrGr )r#�args�kwrrrrJszMethod.__call__cCs|j|j|j|j|jd�S)N��
positional�required�optional�varargs�kwargsr�r&rrr�getSignatureInfos�zMethod.getSignatureInfocCs�g}|jD]:}|�|�||j��vr
|ddt|j|�7<q
|jr\|�d|j�|jrr|�d|j�dd�|�S)NrL�=�*z**z(%s)z, )r�rr�r1�reprr�r��join)r#Zsig�vrrr�getSignatureStrings

 zMethod.getSignatureString)r r5r6r!r�r�r�r�r�r�r�r�rnr�rJr�r�r�rrrrr��s
r�cCs0|p|j}t||j�}t|dd�p$d}|j}|j|}|j|d�}i}	t|�}
|
s`t|dd�}
||
}|dkr�||d�}d}|	�t	t
||d�|���|d|�|_|d|�|_|	|_
|}|jt@r�|||_|d}nd|_|jt@r�|||_nd|_||_|j��D]\}
}|�|
|��q|S)N�__defaults__rZ__defaults_count__rr
)r r�r!�getattr�__code__�co_argcount�co_varnamesr�r�r��zipr�r�r��co_flags�
CO_VARARGSr��CO_VARKEYWORDSr�rGr�r�r4)r�rG�imlevelr]�method�defaults�codeZnar�r�Zdefaults_countZnrZargnorrrrrr�s<





r�cCs&t|t�r|j}n|}t||d|d�S)Nr
)r�r])r�r�__func__r�)�methrGr]r�rrr�
fromMethodOs
rcCs~ddlm}ddlm}|t|�ddlm}|t|�ddlm}|t|�ddlm	}|t
|�ddlm}|t|�dS)Nr)�classImplements)�IElement)�
IAttribute)�IMethod)�ISpecification)�
IInterface)
�zope.interface.declarationsrZzope.interface.interfacesrrrr�rr�rr	r	r)rrrrrr	rrr�_wireXs



r)rD)rA)r�)r�)�_empty)NrN)NN)7r!r�typesrrrrZzope.interface._compatrrr�Zzope.interface.exceptionsrZzope.interface.rorr�Zzope.interface�__all__r�r�rr��objectrrerrrZSpecificationBasePyr9rKrYr
r	r�r�r�r�rr�r�ryr?r�r�r�r�r�rrr
rDrAr�r�rrrrr�<module>sp
=.NO
Qh�

3
4