HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3/dist-packages/zope/interface/__pycache__/registry.cpython-38.pyc
U

ؒ�]�Z�@s�dZddlmZzddlmZWnek
r<dd�ZYnXddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlmZddlm
Z
dd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZGdd�de�Zdd�ZGdd�de�Zee
�Gdd�de��Z dd �Z!d!d"�Z"d#d$�Z#d%d&�Z$ee
�Gd'd(�d(e��Z%ee	�Gd)d*�d*e��Z&ee�Gd+d,�d,e&��Z'ee�Gd-d.�d.e&��Z(d/S)0zBasic components support
�)�defaultdict)�notifycOsdS�N�)�arg�kwrr�9/usr/lib/python3/dist-packages/zope/interface/registry.pyr�r)�ISpecification)�ComponentLookupError)�IAdapterRegistration)�IComponents)�IHandlerRegistration)� ISubscriptionAdapterRegistration)�IUtilityRegistration)�
Registered)�Unregistered)�	Interface)�
implementedBy)�implementer)�implementer_only)�
providedBy)�AdapterRegistry)�CLASS_TYPES)�STRING_TYPESc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�_UnhashableComponentCountercCsdd�|��D�|_dS)NcSsg|]}|�qSrr)�.0�itemrrr�
<listcomp>0sz8_UnhashableComponentCounter.__init__.<locals>.<listcomp>)�items�_data)�selfZ	otherdictrrr�__init__.sz$_UnhashableComponentCounter.__init__cCs$|jD]\}}||kr|SqdS�Nr)r )r!�key�	component�countrrr�__getitem__2s
z'_UnhashableComponentCounter.__getitem__cCsHt|j�D](\}}|d|kr
||f|j|<dSq
|j�||f�dSr#)�	enumerater �append)r!r%r&�i�datarrr�__setitem__8s
z'_UnhashableComponentCounter.__setitem__cCs:t|j�D]"\}}|d|kr
|j|=dSq
t|��dSr#)r(r �KeyError)r!r%r*r+rrr�__delitem__?s
z'_UnhashableComponentCounter.__delitem__N)�__name__�
__module__�__qualname__r"r'r,r.rrrrr+srcCstt�Sr)r�intrrrr�_defaultdict_intFsr3c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�_UtilityRegistrationscCs"tt�|_||_||_|��dSr)rr3�_cache�
_utilities�_utility_registrations�%_UtilityRegistrations__populate_cache)r!�	utilitiesZutility_registrationsrrrr"Ks
z_UtilityRegistrations.__init__cCs4t|j���D] \\}}}|d}|�||�qdSr#)�iterr7r�$_UtilityRegistrations__cache_utility)r!�p�_r+r%rrrZ__populate_cacheSsz&_UtilityRegistrations.__populate_cachecCs\z|j||d7<Wn<tk
rVt|j|�}|j|<||d7<YnXdS)N�)r5�	TypeErrorr)r!�providedr%ZprovrrrZ__cache_utilityXs
z%_UtilityRegistrations.__cache_utilitycCs:|j|}||}|d8}|dkr*||=n|||<|dkS)Nr>r)r5)r!r@r%r&rrrZ__uncache_utilityas
z'_UtilityRegistrations.__uncache_utilitycCs0z|j||dkWStk
r*YdSXdS)NrF)r5r?)r!r@r%rrr�_is_utility_subscribedpsz,_UtilityRegistrations._is_utility_subscribedcCsV|�||�}|||f|j||f<|j�d|||�|sF|j�d||�|�||�dS�Nr)rAr7r6�register�	subscriber;)r!r@�namer%�info�factory�
subscribedrrr�registerUtilitywsz%_UtilityRegistrations.registerUtilitycCs@|j||f=|j�d||�|�||�}|s<|j�d||�dSrB)r7r6�
unregister�&_UtilityRegistrations__uncache_utility�unsubscribe)r!r@rEr%rHrrr�unregisterUtility�s
z'_UtilityRegistrations.unregisterUtilityN)
r/r0r1r"r8r;rKrArIrMrrrrr4Is	r4csDeZdZdZdFdd�Zdd�Z�fdd	�Zd
d�Zdd
�Ze	dd��Z
dd�Zdd�Ze	dd�dd��Z
dGdd�ZdHdd�Zdd�ZdIdd�ZdJd d!�Zd"d#�Zd$d%�ZdKd&d'�ZdLd(d)�Zd*d+�ZdMd,d-�ZdNd.d/�ZdOd0d1�ZdPd2d3�Zd4d5�ZdQd6d7�Zd8d9�ZdRd:d;�Zd<d=�Z dSd>d?�Z!d@dA�Z"dTdBdC�Z#dDdE�Z$�Z%S)U�
ComponentsN�rcCs8t|t�st�||_|��|��t|�|_d|_dSr)	�
isinstancer�AssertionErrorr/�_init_registries�_init_registrations�tuple�	__bases__�_v_utility_registrations_cache)r!rE�basesrrrr"�s
zComponents.__init__cCsd|jj|jfS)Nz<%s %s>)�	__class__r/�r!rrr�__repr__�szComponents.__repr__cs<tt|���}dd�|d��D�}t|�}||d<t|�S)NcSs i|]\}}|�d�s||�qS)Z_v_)�
startswith)r�k�vrrr�
<dictcomp>�s
�z)Components.__reduce__.<locals>.<dictcomp>�)�superrN�
__reduce__r�listrT)r!Z	reductionZfiltered_state�rXrrra�s
zComponents.__reduce__cCst�|_t�|_dSr)r�adaptersr9rYrrrrR�szComponents._init_registriescCsi|_i|_g|_g|_dSr)r7�_adapter_registrations�_subscription_registrations�_handler_registrationsrYrrrrS�szComponents._init_registrationscCs>|j}|dks&|j|jk	s&|j|jk	r:t|j|j�}|_|Sr)rVr6r9r7r4)r!�cacherrr�_utility_registrations_cache�s
�
��
z'Components._utility_registrations_cachecCs|j�dd�S)NrUr)�__dict__�getrYrrr�	_getBases�szComponents._getBasescCs>tdd�|D��|j_tdd�|D��|j_t|�|jd<dS)NcSsg|]
}|j�qSr)rd�r�baserrrr�sz(Components._setBases.<locals>.<listcomp>cSsg|]
}|j�qSr)r9rmrrrr�srU)rTrdrUr9rj�r!rWrrr�	_setBases�s��zComponents._setBasescCs|��Sr)rlrYrrr�<lambda>�r	zComponents.<lambda>cCs
|�|�Sr)rprorrrrq�r	Tc	Cs�|r|rtd��|�}|dkr&t|�}|dkr6t|�}|j�||f�}|dk	rx|dd�||fkrfdS|�|d||�|j�|||||�|r�tt	t
||||||���dS)N�$Can't specify factory and component.rOr_r)r?�_getUtilityProvided�_getNamer7rkrMrirIrr�UtilityRegistration)r!r%r@rErF�eventrGZregrrrrI�s4���zComponents.registerUtilitycCs�|r|rtd��|�}|dkr6|dkr.td��t|�}|j�||f�}|dksb|dk	rf||dkrfdS|dkrv|d}|j�|||�ttt||||f|dd�����dS)Nrrz3Must specify one of component, factory and providedrFr>T)	r?rsr7rkrirMrrru)r!r%r@rErG�oldrrrrM�s0
���zComponents.unregisterUtilityccs4t|j���D] \\}}}t|||f|��VqdSr)r:r7rru)r!r@rEr+rrr�registeredUtilitiess�zComponents.registeredUtilitiescCs|j�d|||�SrB)r9�lookup)r!r@rE�defaultrrr�queryUtilityszComponents.queryUtilitycCs&|j�d||�}|dkr"t||��|SrB)r9ryr)r!r@rE�utilityrrr�
getUtilitys
zComponents.getUtilityccs&|j�d|�D]\}}||fVqdSrB)r9�	lookupAll)r!�	interfacerEr|rrr�getUtilitiesFor!szComponents.getUtilitiesForcCs|j�d|�SrB)r9Z
subscriptions)r!rrrr�getAllUtilitiesRegisteredFor%sz'Components.getAllUtilitiesRegisteredForc	Csr|dkrt|�}t||�}|dkr*t|�}||f|j|||f<|j�||||�|rnttt||||||���dS�NrO)	�_getAdapterProvided�_getAdapterRequiredrtrerdrCrr�AdapterRegistration�r!rG�requiredr@rErFrvrrr�registerAdapter(s
�
��zComponents.registerAdaptercCs�|dkr |dkrtd��t|�}|dkr8|dkr8td��t||�}|j�|||f�}|dksp|dk	rt||dkrtdS|j|||f=|j�|||�ttt	||||f|����dS)N�(Must specify one of factory and provided�(Must specify one of factory and requiredrFT)
r?r�r�rerkrdrJrrr�)r!rGr�r@rErwrrr�unregisterAdapter:s(

���zComponents.unregisterAdapterccs:t|j���D]&\\}}}\}}t||||||�VqdSr)r:rerr�)r!r�r@rEr%rFrrr�registeredAdaptersUs�
�zComponents.registeredAdapterscCs|j�||||�Sr)rd�queryAdapter)r!�objectrrErzrrrr�[szComponents.queryAdaptercCs(|j�|||�}|dkr$t|||��|Sr)rdr�r)r!r�rrE�adapterrrr�
getAdapter^szComponents.getAdaptercCs|j�||||�Sr)rd�queryMultiAdapter)r!�objectsrrErzrrrr�ds�zComponents.queryMultiAdaptercCs(|j�|||�}|dkr$t|||��|Sr)rdr�r)r!r�rrEr�rrr�getMultiAdapteriszComponents.getMultiAdapterccs@|j�ttt|��|�D]"\}}||�}|dk	r||fVqdSr)rdr~rb�mapr)r!r�r@rErGr�rrr�getAdaptersos�zComponents.getAdaptersc	Csn|rtd��|dkrt|�}t||�}|j�|||||f�|j�|||�|rjttt	||||||���dS)N�'Named subscribers are not yet supported)
r?r�r�rfr)rdrDrr�SubscriptionRegistrationr�rrr�registerSubscriptionAdapterws 
�
��z&Components.registerSubscriptionAdapterccs |jD]}t|f|��VqdSr)rfr��r!r+rrr�registeredSubscriptionAdapters�s
z)Components.registeredSubscriptionAdaptersc	s�|rtd���dkr,�dkr$td��t����dkrD�dkrDtd��t�����dkrn��fdd�|jD�}n���fdd�|jD�}t|�t|j�kr�dS||jdd�<|j�����ttt	|��|�d���d	S)
Nr�r�r�cs4g|],\}}}}}|�kr"|�ks|||||f�qSrr�r�rr<�n�fr*)r@r�rrr�s�z<Components.unregisterSubscriptionAdapter.<locals>.<listcomp>cs<g|]4\}}}}}|�kr*|�kr*|�ks|||||f�qSrrr��rGr@r�rrr�s
�FrOT)
r?r�r�rf�lenrdrLrrr�)r!rGr�r@rE�newrr�r�unregisterSubscriptionAdapter�s6
��
��z(Components.unregisterSubscriptionAdaptercCs|j�||�Sr�rd�subscribers)r!r�r@rrrr��szComponents.subscriberscCsZ|rtd��t||�}|j�||||f�|j�|d|�|rVttt|||||���dS)Nz$Named handlers are not yet supported)	r?r�rgr)rdrDrr�HandlerRegistration)r!rGr�rErFrvrrr�registerHandler�s

��zComponents.registerHandlerccs |jD]}t|f|��VqdSr)rgr�r�rrr�registeredHandlers�s
zComponents.registeredHandlerscs�|rtd���dkr$�dkr$td��t�����dkrL�fdd�|jD�}n��fdd�|jD�}t|�t|j�krxdS||jdd�<|j��d��ttt|�|�d���dS)	Nr�r�cs(g|] \}}}}|�kr||||f�qSrr�rr�r�r�r*)r�rrr�s
�z0Components.unregisterHandler.<locals>.<listcomp>cs0g|](\}}}}|�kr |�ks||||f�qSrrr��rGr�rrr�s
�FrOT)	r?r�rgr�rdrLrrr�)r!rGr�rEr�rr�r�unregisterHandler�s(

���zComponents.unregisterHandlercGs|j�|d�dSrr�)r!r�rrr�handle�szComponents.handle)rOr)NNrOrOTN)NNrON)rON)rO)NNrOrOT)NNNrO)rON)rO)rON)rO)NNrOrOT)NNNrO)NrOrOT)NNrO)&r/r0r1rVr"rZrarRrS�propertyrirlrprUrIrMrxr{r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrrcrrN�s�


��
�


�
�


�

	�
�
*�

"rNcCs$z|jWStk
rYdSXdSr�)Z__component_name__�AttributeError)r%rrrrt�srtcCs,tt|��}t|�dkr |dStd��dS)Nr>rzWThe utility doesn't provide a single interface and no provided interface was specified.)rbrr�r?)r%r@rrrrs�s�rscCs,tt|��}t|�dkr |dStd��dS)Nr>rzaThe adapter factory doesn't implement a single interface and no provided interface was specified.)rbrr�r?)rGr@rrrr�s�r�cCs�|dkr2z
|j}WqDtk
r.td��YqDXnt�|�rDtd��g}|D]B}|dkr^t}n&t�|�s�t|t�r|t|�}ntd��|�	|�qLt
|�S)NzoThe adapter factory doesn't have a __component_adapts__ attribute and no required specifications were specifiedzLthe required argument should be a list of interfaces, not a single interfacez8Required specification must be a specification or class.)Z__component_adapts__r�r?r
rrrPrrr)rT)rGr��resultr�rrrr�
s&
�



r�c@sVeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)ruNcCs,||||||f\|_|_|_|_|_|_dSr)�registryr@rEr%rFrG)r!r�r@rEr%�docrGrrrr",s��zUtilityRegistration.__init__c
Cs<d|jj|jt|jdd�|jt|jdt|j��|j|j	fS)Nz%s(%r, %s, %r, %s, %r, %r)r/)
rXr/r��getattrr@rEr%�reprrGrFrYrrrrZ1s�zUtilityRegistration.__repr__cCst|�Sr��idrYrrr�__hash__:szUtilityRegistration.__hash__cCst|�t|�kSr�r��r!�otherrrr�__eq__=szUtilityRegistration.__eq__cCst|�t|�kSrr�r�rrr�__ne__@szUtilityRegistration.__ne__cCst|�t|�kSrr�r�rrr�__lt__CszUtilityRegistration.__lt__cCst|�t|�kSrr�r�rrr�__le__FszUtilityRegistration.__le__cCst|�t|�kSrr�r�rrr�__gt__IszUtilityRegistration.__gt__cCst|�t|�kSrr�r�rrr�__ge__LszUtilityRegistration.__ge__)N�r/r0r1r"rZr�r�r�r�r�r�r�rrrrru)s
	ruc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)r�cCs,||||||f\|_|_|_|_|_|_dSr)r�r�r@rErGrF)r!r�r�r@rEr%r�rrrr"Rs
��zAdapterRegistration.__init__cCsTd|jj|jdd�dd�|jD��dt|jdd�|jt|jdt	|j��|j
fS)Nz%s(%r, %s, %s, %r, %s, %r)�[�, cSsg|]
}|j�qSr�r/�rr�rrrr[sz0AdapterRegistration.__repr__.<locals>.<listcomp>�]r/)rXr/r��joinr�r�r@rErGr�rFrYrrrrZWs�zAdapterRegistration.__repr__cCst|�Srr�rYrrrr�`szAdapterRegistration.__hash__cCst|�t|�kSrr�r�rrrr�cszAdapterRegistration.__eq__cCst|�t|�kSrr�r�rrrr�fszAdapterRegistration.__ne__cCst|�t|�kSrr�r�rrrr�iszAdapterRegistration.__lt__cCst|�t|�kSrr�r�rrrr�lszAdapterRegistration.__le__cCst|�t|�kSrr�r�rrrr�oszAdapterRegistration.__gt__cCst|�t|�kSrr�r�rrrr�rszAdapterRegistration.__ge__Nr�rrrrr�Os	r�c@seZdZdS)r�N)r/r0r1rrrrr�usr�c@s,eZdZdd�Zedd��ZdZdd�ZdS)r�cCs&|||||f\|_|_|_|_|_dSr)r�r�rE�handlerrF)r!r�r�rEr�r�rrrr"}s�zHandlerRegistration.__init__cCs|jSr)r�rYrrrrG�szHandlerRegistration.factoryNc
CsHd|jj|jdd�dd�|jD��d|jt|jdt|j��|j	fS)Nz%s(%r, %s, %r, %s, %r)r�r�cSsg|]
}|j�qSrr�r�rrrr�sz0HandlerRegistration.__repr__.<locals>.<listcomp>r�r/)
rXr/r�r�r�rEr�rGr�rFrYrrrrZ�s�zHandlerRegistration.__repr__)r/r0r1r"r�rGr@rZrrrrr�zs

r�N))�__doc__�collectionsrZ
zope.eventr�ImportErrorZzope.interface.interfacesr
rrr
rrrrrZzope.interface.interfacerZzope.interface.declarationsrrrrZzope.interface.adapterrZzope.interface._compatrrr�rr3r4rNrtrsr�r�rur�r�r�rrrr�<module>sRCl%%