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__/registry.cpython-37.pyc

B

R^�[�@s�dZddlmZyddlmZWnek
r<dd�ZYnXddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlmZddlm
Z
dd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZdgZGdd�de�Zdd�ZGdd�de�Z ee
�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�J/opt/alt/python37/lib64/python3.7/site-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_TYPES�
Componentsc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�_UnhashableComponentCountercCsdd�|��D�|_dS)NcSsg|]}|�qSrr)�.0�itemrrr�
<listcomp>6sz8_UnhashableComponentCounter.__init__.<locals>.<listcomp>)�items�_data)�selfZ	otherdictrrr�__init__4sz$_UnhashableComponentCounter.__init__cCs$x|jD]\}}||kr|SqWdS)Nr)r )r!�key�	component�countrrr�__getitem__8sz'_UnhashableComponentCounter.__getitem__cCsJx4t|j�D]&\}}|d|kr||f|j|<dSqW|j�||f�dS)Nr)�	enumerater �append)r!r$r%�i�datarrr�__setitem__>s
z'_UnhashableComponentCounter.__setitem__cCs<x.t|j�D] \}}|d|kr|j|=dSqWt|��dS)Nr)r'r �KeyError)r!r$r)r*rrr�__delitem__Es
z'_UnhashableComponentCounter.__delitem__N)�__name__�
__module__�__qualname__r"r&r+r-rrrrr1srcCstt�S)N)r�intrrrr�_defaultdict_intLsr2c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�_UtilityRegistrationscCs"tt�|_||_||_|��dS)N)rr2�_cache�
_utilities�_utility_registrations�%_UtilityRegistrations__populate_cache)r!�	utilitiesZutility_registrationsrrrr"Qs
z_UtilityRegistrations.__init__cCs8x2t|j���D] \\}}}|d}|�||�qWdS)Nr)�iterr6r�$_UtilityRegistrations__cache_utility)r!�p�_r*r$rrrZ__populate_cacheYsz&_UtilityRegistrations.__populate_cachecCs\y|j||d7<Wn<tk
rVt|j|�}|j|<||d7<YnXdS)N�)r4�	TypeErrorr)r!�providedr$ZprovrrrZ__cache_utility^s
z%_UtilityRegistrations.__cache_utilitycCs:|j|}||}|d8}|dkr*||=n|||<|dkS)Nr=r)r4)r!r?r$r%rrrZ__uncache_utilitygs
z'_UtilityRegistrations.__uncache_utilitycCs,y|j||dkStk
r&dSXdS)NrF)r4r>)r!r?r$rrr�_is_utility_subscribedvsz,_UtilityRegistrations._is_utility_subscribedcCsV|�||�}|||f|j||f<|j�d|||�|sF|j�d||�|�||�dS)Nr)r@r6r5�register�	subscriber:)r!r?�namer$�info�factory�
subscribedrrr�registerUtility}sz%_UtilityRegistrations.registerUtilitycCs@|j||f=|j�d||�|�||�}|s<|j�d||�dS)Nr)r6r5�
unregister�&_UtilityRegistrations__uncache_utility�unsubscribe)r!r?rCr$rFrrr�unregisterUtility�s
z'_UtilityRegistrations.unregisterUtilityN)
r.r/r0r"r7r:rIr@rGrKrrrrr3Os	r3csDeZdZdZdFdd�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)UrN�rcCs8t|t�st�||_|��|��t|�|_d|_dS)N)	�
isinstancer�AssertionErrorr.�_init_registries�_init_registrations�tuple�	__bases__�_v_utility_registrations_cache)r!rC�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>�sz)Components.__reduce__.<locals>.<dictcomp>�)�superr�
__reduce__r�listrQ)r!Z	reductionZfiltered_state)rUrrr]�s
zComponents.__reduce__cCst�|_t�|_dS)N)r�adaptersr8)r!rrrrO�szComponents._init_registriescCsi|_i|_g|_g|_dS)N)r6�_adapter_registrations�_subscription_registrations�_handler_registrations)r!rrrrP�szComponents._init_registrationscCs>|j}|dks&|j|jk	s&|j|jk	r:t|j|j�}|_|S)N)rSr5r8r6r3)r!�cacherrr�_utility_registrations_cache�sz'Components._utility_registrations_cachecCs|j�dd�S)NrRr)�__dict__�get)r!rrr�	_getBases�szComponents._getBasescCs>tdd�|D��|j_tdd�|D��|j_t|�|jd<dS)NcSsg|]
}|j�qSr)r_)r�baserrrr�sz(Components._setBases.<locals>.<listcomp>cSsg|]
}|j�qSr)r8)rrhrrrr�srR)rQr_rRr8re)r!rTrrr�	_setBases�s
zComponents._setBasescCs|��S)N)rg)r!rrr�<lambda>�rzComponents.<lambda>cCs
|�|�S)N)ri)r!rTrrrrj�rTc	Cs�|r|rtd��|�}|dkr&t|�}|dkr6t|�}|j�||f�}|dk	rx|dd�||fkrfdS|�|d||�|j�|||||�|r�tt	t
||||||���dS)Nz$Can't specify factory and component.rLr[r)r>�_getUtilityProvided�_getNamer6rfrKrdrGrr�UtilityRegistration)r!r$r?rCrD�eventrEZregrrrrG�s&zComponents.registerUtilitycCs�|r|rtd��|�}|dkr6|dkr.td��t|�}|j�||f�}|dksb|dk	rf||dkrfdS|dkrv|d}|j�|||�ttt||||f|dd�����dS)Nz$Can't specify factory and component.z3Must specify one of component, factory and providedrFr=T)	r>rkr6rfrdrKrrrm)r!r$r?rCrE�oldrrrrK�s&
 zComponents.unregisterUtilityccs8x2t|j���D] \\}}}t|||f|��VqWdS)N)r9r6rrm)r!r?rCr*rrr�registeredUtilitiesszComponents.registeredUtilitiescCs|j�d|||�S)Nr)r8�lookup)r!r?rC�defaultrrr�queryUtilityszComponents.queryUtilitycCs&|j�d||�}|dkr"t||��|S)Nr)r8rqr
)r!r?rC�utilityrrr�
getUtility!s
zComponents.getUtilityccs*x$|j�d|�D]\}}||fVqWdS)Nr)r8�	lookupAll)r!�	interfacerCrtrrr�getUtilitiesFor'szComponents.getUtilitiesForcCs|j�d|�S)Nr)r8Z
subscriptions)r!rwrrr�getAllUtilitiesRegisteredFor+sz'Components.getAllUtilitiesRegisteredForc	Csr|dkrt|�}t||�}|dkr*t|�}||f|j|||f<|j�||||�|rnttt||||||���dS)NrL)	�_getAdapterProvided�_getAdapterRequiredrlr`r_rArr�AdapterRegistration)r!rE�requiredr?rCrDrnrrr�registerAdapter.s

zComponents.registerAdaptercCs�|dkr |dkrtd��t|�}|dkr8|dkr8td��t||�}|j�|||f�}|dksp|dk	rt||dkrtdS|j|||f=|j�|||�ttt	||||f|����dS)Nz(Must specify one of factory and providedz(Must specify one of factory and requiredrFT)
r>rzr{r`rfr_rHrrr|)r!rEr}r?rCrorrr�unregisterAdapter@s"
zComponents.unregisterAdapterccs>x8t|j���D]&\\}}}\}}t||||||�VqWdS)N)r9r`rr|)r!r}r?rCr$rDrrr�registeredAdapters[s 
zComponents.registeredAdapterscCs|j�||||�S)N)r_�queryAdapter)r!�objectrwrCrrrrrr�aszComponents.queryAdaptercCs(|j�|||�}|dkr$t|||��|S)N)r_r�r
)r!r�rwrC�adapterrrr�
getAdapterdszComponents.getAdaptercCs|j�||||�S)N)r_�queryMultiAdapter)r!�objectsrwrCrrrrrr�jszComponents.queryMultiAdaptercCs(|j�|||�}|dkr$t|||��|S)N)r_r�r
)r!r�rwrCr�rrr�getMultiAdapteroszComponents.getMultiAdapterccsDx>|j�ttt|��|�D]"\}}||�}|dk	r||fVqWdS)N)r_rvr^�mapr)r!r�r?rCrEr�rrr�getAdaptersuszComponents.getAdaptersc	Csn|rtd��|dkrt|�}t||�}|j�|||||f�|j�|||�|rjttt	||||||���dS)Nz'Named subscribers are not yet supported)
r>rzr{rar(r_rBrr�SubscriptionRegistration)r!rEr}r?rCrDrnrrr�registerSubscriptionAdapter}s

z&Components.registerSubscriptionAdapterccs$x|jD]}t|f|��VqWdS)N)rar�)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)
Nz'Named subscribers are not yet supportedz(Must specify one of factory and providedz(Must specify one of factory and requiredcs4g|],\}}}}}|�kr"|�ks|||||f�qSrr)r�rr;�n�fr))r?r}rrr�sz<Components.unregisterSubscriptionAdapter.<locals>.<listcomp>cs<g|]4\}}}}}|�kr*|�kr*|�ks|||||f�qSrr)rr�r;r�r�r))rEr?r}rrr�sFrLT)
r>rzr{ra�lenr_rJrrr�)r!rEr}r?rC�newr)rEr?r}r�unregisterSubscriptionAdapter�s,


z(Components.unregisterSubscriptionAdaptercCs|j�||�S)N)r_�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{rbr(r_rBrr�HandlerRegistration)r!rEr}rCrDrnrrr�registerHandler�s
zComponents.registerHandlerccs$x|jD]}t|f|��VqWdS)N)rbr�)r!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)	Nz'Named subscribers are not yet supportedz(Must specify one of factory and requiredcs(g|] \}}}}|�kr||||f�qSrr)rr�r�r�r))r}rrr�s
z0Components.unregisterHandler.<locals>.<listcomp>cs0g|](\}}}}|�kr |�ks||||f�qSrr)rr�r�r�r))rEr}rrr�s
FrLT)	r>r{rbr�r_rJrrr�)r!rEr}rCr�r)rEr}r�unregisterHandler�s"


zComponents.unregisterHandlercGs|j�|d�dS)N)r_r�)r!r�rrr�handle�szComponents.handle)rLr)NNrLrLTN)NNrLN)rLN)rL)NNrLrLT)NNNrL)rLN)rL)rLN)rL)NNrLrLT)NNNrL)NrLrLT)NNrL)&r.r/r0rSr"rVr]rOrP�propertyrdrgrirRrGrKrprsrurxryr~rr�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rr)rUrr�sZ













	

)

"cCs y|jStk
rdSXdS)NrL)Z__component_name__�AttributeError)r$rrrrl�srlcCs,tt|��}t|�dkr |dStd��dS)Nr=rzWThe utility doesn't provide a single interface and no provided interface was specified.)r^rr�r>)r$r?rrrrks
rkcCs,tt|��}t|�dkr |dStd��dS)Nr=rzaThe adapter factory doesn't implement a single interface and no provided interface was specified.)r^rr�r>)rEr?rrrrzs
rzcCs�|dkr2y
|j}WqDtk
r.td��YqDXnt�|�rDtd��g}xR|D]J}|dkr`t}n.t�|�s�t|t�r~t|�}ntdt	|���|�
|�qNWt|�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 interfacez?Required specification must be a specification or class, not %r)Z__component_adapts__r�r>r	rrrMrr�typer(rQ)rEr}�resultr�rrrr{s&





r{c@sVeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)rmNcCs,||||||f\|_|_|_|_|_|_dS)N)�registryr?rCr$rDrE)r!r�r?rCr$�docrErrrr"2szUtilityRegistration.__init__c
Cs<d|jj|jt|jdd�|jt|jdt|j��|j|j	fS)Nz%s(%r, %s, %r, %s, %r, %r)r.)
rUr.r��getattrr?rCr$�reprrErD)r!rrrrV7szUtilityRegistration.__repr__cCst|�S)N)�id)r!rrr�__hash__@szUtilityRegistration.__hash__cCst|�t|�kS)N)r�)r!�otherrrr�__eq__CszUtilityRegistration.__eq__cCst|�t|�kS)N)r�)r!r�rrr�__ne__FszUtilityRegistration.__ne__cCst|�t|�kS)N)r�)r!r�rrr�__lt__IszUtilityRegistration.__lt__cCst|�t|�kS)N)r�)r!r�rrr�__le__LszUtilityRegistration.__le__cCst|�t|�kS)N)r�)r!r�rrr�__gt__OszUtilityRegistration.__gt__cCst|�t|�kS)N)r�)r!r�rrr�__ge__RszUtilityRegistration.__ge__)N)r.r/r0r"rVr�r�r�r�r�r�r�rrrrrm/s
	rmc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)r|cCs,||||||f\|_|_|_|_|_|_dS)N)r�r}r?rCrErD)r!r�r}r?rCr$r�rrrr"XszAdapterRegistration.__init__cCsTd|jj|jdd�dd�|jD��dt|jdd�|jt|jdt	|j��|j
fS)Nz%s(%r, %s, %s, %r, %s, %r)�[z, cSsg|]
}|j�qSr)r.)rr�rrrrasz0AdapterRegistration.__repr__.<locals>.<listcomp>�]r.)rUr.r��joinr}r�r?rCrEr�rD)r!rrrrV]szAdapterRegistration.__repr__cCst|�S)N)r�)r!rrrr�fszAdapterRegistration.__hash__cCst|�t|�kS)N)r�)r!r�rrrr�iszAdapterRegistration.__eq__cCst|�t|�kS)N)r�)r!r�rrrr�lszAdapterRegistration.__ne__cCst|�t|�kS)N)r�)r!r�rrrr�oszAdapterRegistration.__lt__cCst|�t|�kS)N)r�)r!r�rrrr�rszAdapterRegistration.__le__cCst|�t|�kS)N)r�)r!r�rrrr�uszAdapterRegistration.__gt__cCst|�t|�kS)N)r�)r!r�rrrr�xszAdapterRegistration.__ge__N)r.r/r0r"rVr�r�r�r�r�r�r�rrrrr|Us	r|c@seZdZdS)r�N)r.r/r0rrrrr�{sr�c@s,eZdZdd�Zedd��ZdZdd�ZdS)r�cCs&|||||f\|_|_|_|_|_dS)N)r�r}rC�handlerrD)r!r�r}rCr�r�rrrr"�szHandlerRegistration.__init__cCs|jS)N)r�)r!rrrrE�szHandlerRegistration.factoryNc
CsHd|jj|jdd�dd�|jD��d|jt|jdt|j��|j	fS)Nz%s(%r, %s, %r, %s, %r)r�z, cSsg|]
}|j�qSr)r.)rr�rrrr�sz0HandlerRegistration.__repr__.<locals>.<listcomp>r�r.)
rUr.r�r�r}rCr�rEr�rD)r!rrrrV�szHandlerRegistration.__repr__)r.r/r0r"r�rEr?rVrrrrr��sr�N)*�__doc__�collectionsrZ
zope.eventr�ImportErrorZzope.interface.interfacesr	r
rrr
rrrrZzope.interface.interfacerZzope.interface.declarationsrrrrZzope.interface.adapterrZzope.interface._compatrr�__all__r�rr2r3rrlrkrzr{rmr|r�r�rrrr�<module>sTCl%%