ok

Mini Shell

Direktori : /lib64/python3.6/site-packages/zope/interface/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/zope/interface/__pycache__/registry.cpython-36.pyc

3

��[�Z�
@s�dZddlmZyddlmZWnek
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� /usr/lib64/python3.6/registry.pyrsr)�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�|j�D�|_dS)NcSsg|]}|�qSrr)�.0�itemrrr�
<listcomp>0sz8_UnhashableComponentCounter.__init__.<locals>.<listcomp>)�items�_data)�selfZ	otherdictrrr�__init__.sz$_UnhashableComponentCounter.__init__cCs$x|jD]\}}||kr|SqWdS)Nr)r)r�key�	component�countrrr�__getitem__2sz'_UnhashableComponentCounter.__getitem__cCsJx4t|j�D]&\}}|d|kr||f|j|<dSqW|jj||f�dS)Nr)�	enumerater�append)rr"r#�i�datarrr�__setitem__8s
z'_UnhashableComponentCounter.__setitem__cCs<x.t|j�D] \}}|d|kr|j|=dSqWt|��dS)Nr)r%r�KeyError)rr"r'r(rrr�__delitem__?s
z'_UnhashableComponentCounter.__delitem__N)�__name__�
__module__�__qualname__r r$r)r+rrrrr+srcCstt�S)N)r�intrrrr�_defaultdict_intFsr0c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�_UtilityRegistrationscCs"tt�|_||_||_|j�dS)N)rr0�_cache�
_utilities�_utility_registrations�%_UtilityRegistrations__populate_cache)r�	utilitiesZutility_registrationsrrrr Ks
z_UtilityRegistrations.__init__cCs8x2t|jj��D] \\}}}|d}|j||�qWdS)Nr)�iterr4r�$_UtilityRegistrations__cache_utility)r�p�_r(r"rrrZ__populate_cacheSsz&_UtilityRegistrations.__populate_cachecCs\y|j||d7<Wn<tk
rVt|j|�}|j|<||d7<YnXdS)N�)r2�	TypeErrorr)r�providedr"ZprovrrrZ__cache_utilityXs
z%_UtilityRegistrations.__cache_utilitycCs:|j|}||}|d8}|dkr*||=n|||<|dkS)Nr;r)r2)rr=r"r#rrrZ__uncache_utilityas
z'_UtilityRegistrations.__uncache_utilitycCs,y|j||dkStk
r&dSXdS)NrF)r2r<)rr=r"rrr�_is_utility_subscribedpsz,_UtilityRegistrations._is_utility_subscribedcCsV|j||�}|||f|j||f<|jjf|||�|sF|jjf||�|j||�dS)N)r>r4r3�register�	subscriber8)rr=�namer"�info�factory�
subscribedrrr�registerUtilitywsz%_UtilityRegistrations.registerUtilitycCs@|j||f=|jjf||�|j||�}|s<|jjf||�dS)N)r4r3�
unregister�&_UtilityRegistrations__uncache_utility�unsubscribe)rr=rAr"rDrrr�unregisterUtility�s
z'_UtilityRegistrations.unregisterUtilityN)
r,r-r.r r5r8rGr>rErIrrrrr1Is	r1csHeZdZdZdffdd�Zdd�Z�fdd�Zd	d
�Zdd�Ze	d
d��Z
dd�Zdd�Ze	dd�dd��Z
dEdd�ZdFdd�Zdd�ZdGdd�ZdHdd �Zd!d"�Zd#d$�ZdId%d&�ZdJd'd(�Zd)d*�ZdKd+d,�ZdLd-d.�ZdMd/d0�ZdNd1d2�Zd3d4�ZdOd5d6�Zd7d8�ZdPd9d:�Zd;d<�Z dQd=d>�Z!d?d@�Z"dRdAdB�Z#dCdD�Z$�Z%S)S�
ComponentsN�cCs8t|t�st�||_|j�|j�t|�|_d|_dS)N)	�
isinstancer�AssertionErrorr,�_init_registries�_init_registrations�tuple�	__bases__�_v_utility_registrations_cache)rrA�basesrrrr �s
zComponents.__init__cCsd|jj|jfS)Nz<%s %s>)�	__class__r,)rrrr�__repr__�szComponents.__repr__cs<tt|�j�}dd�|dj�D�}t|�}||d<t|�S)NcSs i|]\}}|jd�s||�qS)Z_v_)�
startswith)r�k�vrrr�
<dictcomp>�sz)Components.__reduce__.<locals>.<dictcomp>�)�superrJ�
__reduce__r�listrP)rZ	reductionZfiltered_state)rTrrr\�s
zComponents.__reduce__cCst�|_t�|_dS)N)r�adaptersr6)rrrrrN�szComponents._init_registriescCsi|_i|_g|_g|_dS)N)r4�_adapter_registrations�_subscription_registrations�_handler_registrations)rrrrrO�szComponents._init_registrationscCs>|j}|dks&|j|jk	s&|j|jk	r:t|j|j�}|_|S)N)rRr3r6r4r1)r�cacherrr�_utility_registrations_cache�sz'Components._utility_registrations_cachecCs|jjdf�S)NrQ)�__dict__�get)rrrr�	_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)r6)rrgrrrr�srQ)rPr^rQr6rd)rrSrrr�	_setBases�s
zComponents._setBasescCs|j�S)N)rf)rrrr�<lambda>�szComponents.<lambda>cCs
|j|�S)N)rh)rrSrrrri�sTc	Cs�|r|rtd��|�}|dkr&t|�}|dkr6t|�}|jj||f�}|dk	rx|dd�||fkrfdS|j|d||�|jj|||||�|r�tt	t
||||||���dS)Nz$Can't specify factory and component.rKrZr)r<�_getUtilityProvided�_getNamer4rerIrcrErr�UtilityRegistration)rr"r=rArB�eventrCZregrrrrE�s&zComponents.registerUtilitycCs�|r|rtd��|�}|dkr6|dkr.td��t|�}|jj||f�}|dksb|dk	rf||dkrfdS|dkrv|d}|jj|||�ttt||||f|dd�����dS)Nz$Can't specify factory and component.z3Must specify one of component, factory and providedrFr;T)	r<rjr4rercrIrrrl)rr"r=rArC�oldrrrrI�s&
 zComponents.unregisterUtilityccs8x2t|jj��D] \\}}}t|||f|��VqWdS)N)r7r4rrl)rr=rAr(rrr�registeredUtilitiesszComponents.registeredUtilitiescCs|jjf|||�S)N)r6�lookup)rr=rA�defaultrrr�queryUtilityszComponents.queryUtilitycCs&|jjf||�}|dkr"t||��|S)N)r6rpr	)rr=rA�utilityrrr�
getUtilitys
zComponents.getUtilityccs*x$|jjf|�D]\}}||fVqWdS)N)r6�	lookupAll)r�	interfacerArsrrr�getUtilitiesFor!szComponents.getUtilitiesForcCs|jjf|�S)N)r6Z
subscriptions)rrvrrr�getAllUtilitiesRegisteredFor%sz'Components.getAllUtilitiesRegisteredForc	Csr|dkrt|�}t||�}|dkr*t|�}||f|j|||f<|jj||||�|rnttt||||||���dS)NrK)	�_getAdapterProvided�_getAdapterRequiredrkr_r^r?rr�AdapterRegistration)rrC�requiredr=rArBrmrrr�registerAdapter(s

zComponents.registerAdaptercCs�|dkr |dkrtd��t|�}|dkr8|dkr8td��t||�}|jj|||f�}|dksp|dk	rt||dkrtdS|j|||f=|jj|||�ttt	||||f|����dS)Nz(Must specify one of factory and providedz(Must specify one of factory and requiredrFT)
r<ryrzr_rer^rFrrr{)rrCr|r=rArnrrr�unregisterAdapter:s"
zComponents.unregisterAdapterccs>x8t|jj��D]&\\}}}\}}t||||||�VqWdS)N)r7r_rr{)rr|r=rAr"rBrrr�registeredAdaptersUs 
zComponents.registeredAdapterscCs|jj||||�S)N)r^�queryAdapter)r�objectrvrArqrrrr�[szComponents.queryAdaptercCs(|jj|||�}|dkr$t|||��|S)N)r^r�r	)rr�rvrA�adapterrrr�
getAdapter^szComponents.getAdaptercCs|jj||||�S)N)r^�queryMultiAdapter)r�objectsrvrArqrrrr�dszComponents.queryMultiAdaptercCs(|jj|||�}|dkr$t|||��|S)N)r^r�r	)rr�rvrAr�rrr�getMultiAdapteriszComponents.getMultiAdapterccsDx>|jjttt|��|�D]"\}}||�}|dk	r||fVqWdS)N)r^rur]�mapr)rr�r=rArCr�rrr�getAdaptersoszComponents.getAdaptersc	Csn|rtd��|dkrt|�}t||�}|jj|||||f�|jj|||�|rjttt	||||||���dS)Nz'Named subscribers are not yet supported)
r<ryrzr`r&r^r@rr�SubscriptionRegistration)rrCr|r=rArBrmrrr�registerSubscriptionAdapterws

z&Components.registerSubscriptionAdapterccs$x|jD]}t|f|��VqWdS)N)r`r�)rr(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�<|jj����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|],\}}}}}|�ko |�ks|||||f�qSrr)r�rr9�n�fr')r=r|rrr�sz<Components.unregisterSubscriptionAdapter.<locals>.<listcomp>cs<g|]4\}}}}}|�ko(|�ko(|�ks|||||f�qSrr)rr�r9r�r�r')rCr=r|rrr�sFrKT)
r<ryrzr`�lenr^rHrrr�)rrCr|r=rA�newr)rCr=r|r�unregisterSubscriptionAdapter�s,


z(Components.unregisterSubscriptionAdaptercCs|jj||�S)N)r^�subscribers)rr�r=rrrr��szComponents.subscriberscCsZ|rtd��t||�}|jj||||f�|jj|d|�|rVttt|||||���dS)Nz$Named handlers are not yet supported)	r<rzrar&r^r@rr�HandlerRegistration)rrCr|rArBrmrrr�registerHandler�s
zComponents.registerHandlerccs$x|jD]}t|f|��VqWdS)N)rar�)rr(rrr�registeredHandlers�szComponents.registeredHandlerscs�|rtd���dkr$�dkr$td��t�����dkrL�fdd�|jD�}n��fdd�|jD�}t|�t|j�krxdS||jdd�<|jj�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|](\}}}}|�ko|�ks||||f�qSrr)rr�r�r�r')rCr|rrr�s
FrKT)	r<rzrar�r^rHrrr�)rrCr|rAr�r)rCr|r�unregisterHandler�s"


zComponents.unregisterHandlercGs|jj|d�dS)N)r^r�)rr�rrr�handle�szComponents.handle)NNrKrKTN)NNrKN)rKN)rK)NNrKrKT)NNNrK)rKN)rK)rKN)rK)NNrKrKT)NNNrK)NrKrKT)NNrK)&r,r-r.rRr rUr\rNrO�propertyrcrfrhrQrErIrorrrtrwrxr}r~rr�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rr)rTrrJ�sZ












	

)

"rJcCs y|jStk
rdSXdS)NrK)Z__component_name__�AttributeError)r"rrrrk�srkcCs,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=rrrrj�s
rjcCs,tt|��}t|�dkr |dStd��dS)Nr;rzaThe adapter factory doesn't implement a single interface and no provided interface was specified.)r]rr�r<)rCr=rrrrys
rycCs�|dkr2y
|j}WqDtk
r.td��YqDXntj|�rDtd��g}xJ|D]B}|dkr`t}n&tj|�s�t|t�r~t|�}ntd��|j	|�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 interfacez8Required specification must be a specification or class.)Z__component_adapts__r�r<rrrrLrrr&rP)rCr|�resultr�rrrrz
s$





rzc@sVeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)rlNcCs,||||||f\|_|_|_|_|_|_dS)N)�registryr=rAr"rBrC)rr�r=rAr"�docrCrrrr ,szUtilityRegistration.__init__c
Cs<d|jj|jt|jdd�|jt|jdt|j��|j|j	fS)Nz%s(%r, %s, %r, %s, %r, %r)r,)
rTr,r��getattrr=rAr"�reprrCrB)rrrrrU1szUtilityRegistration.__repr__cCst|�S)N)�id)rrrr�__hash__:szUtilityRegistration.__hash__cCst|�t|�kS)N)r�)r�otherrrr�__eq__=szUtilityRegistration.__eq__cCst|�t|�kS)N)r�)rr�rrr�__ne__@szUtilityRegistration.__ne__cCst|�t|�kS)N)r�)rr�rrr�__lt__CszUtilityRegistration.__lt__cCst|�t|�kS)N)r�)rr�rrr�__le__FszUtilityRegistration.__le__cCst|�t|�kS)N)r�)rr�rrr�__gt__IszUtilityRegistration.__gt__cCst|�t|�kS)N)r�)rr�rrr�__ge__LszUtilityRegistration.__ge__)N)r,r-r.r rUr�r�r�r�r�r�r�rrrrrl)s
	rlc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)r{cCs,||||||f\|_|_|_|_|_|_dS)N)r�r|r=rArCrB)rr�r|r=rAr"r�rrrr RszAdapterRegistration.__init__cCsTd|jj|jddjdd�|jD��dt|jdd�|jt|jdt	|j��|j
fS)Nz%s(%r, %s, %s, %r, %s, %r)�[z, cSsg|]
}|j�qSr)r,)rr�rrrr[sz0AdapterRegistration.__repr__.<locals>.<listcomp>�]r,)rTr,r��joinr|r�r=rArCr�rB)rrrrrUWszAdapterRegistration.__repr__cCst|�S)N)r�)rrrrr�`szAdapterRegistration.__hash__cCst|�t|�kS)N)r�)rr�rrrr�cszAdapterRegistration.__eq__cCst|�t|�kS)N)r�)rr�rrrr�fszAdapterRegistration.__ne__cCst|�t|�kS)N)r�)rr�rrrr�iszAdapterRegistration.__lt__cCst|�t|�kS)N)r�)rr�rrrr�lszAdapterRegistration.__le__cCst|�t|�kS)N)r�)rr�rrrr�oszAdapterRegistration.__gt__cCst|�t|�kS)N)r�)rr�rrrr�rszAdapterRegistration.__ge__N)r,r-r.r rUr�r�r�r�r�r�r�rrrrr{Os	r{c@seZdZdS)r�N)r,r-r.rrrrr�usr�c@s,eZdZdd�Zedd��ZdZdd�ZdS)r�cCs&|||||f\|_|_|_|_|_dS)N)r�r|rA�handlerrB)rr�r|rAr�r�rrrr }szHandlerRegistration.__init__cCs|jS)N)r�)rrrrrC�szHandlerRegistration.factoryNc
CsHd|jj|jddjdd�|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,)
rTr,r�r�r|rAr�rCr�rB)rrrrrU�szHandlerRegistration.__repr__)r,r-r.r r�rCr=rUrrrrr�zsr�N))�__doc__�collectionsrZ
zope.eventr�ImportErrorZzope.interface.interfacesrr	r
rrr
rrrZzope.interface.interfacerZzope.interface.declarationsrrrrZzope.interface.adapterrZzope.interface._compatrrr�rr0r1rJrkrjryrzrlr{r�r�rrrr�<module>sRCl%%

Zerion Mini Shell 1.0