ok

Mini Shell

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

3

��[|[�@s~dZddlZddlmZddlmZddlmZddlmZddlmZddl	m
Z
dd	l	mZd
ZGdd�de
�Ze
�ZGd
d�de
�ZeZyddlmZWnek
r�eZYnXGdd�de�ZeZyddlmZWnek
r�eZYnXGdd�de
�ZGdd�dee�Zee�Gdd�de��ZGdd�dee�Zee�Gdd�de��Zdd�Zdd �Zd!d"�Zd#d$�Z dS)%zAdapter management
�N)�implementer)�
providedBy)�	Interface)�ro)�IAdapterRegistry)�_normalize_name)�STRING_TYPES�c	@s�eZdZd#Zd
Zffdd�Zd
d�Zedd�dd��Zdd�Z	dd�Z
dd�Zefdd�Z
d$dd�Zdd�Zd%dd �Zd!d"�ZdS)&�BaseAdapterRegistry�lookup�queryMultiAdapter�lookup1�queryAdapter�adapter_hook�	lookupAll�names�
subscriptions�subscribersrcCs$g|_g|_i|_|j�||_dS)N)�	_adapters�_subscribers�	_provided�
_createLookup�	__bases__)�self�bases�r�/usr/lib64/python3.6/adapter.py�__init__(s
zBaseAdapterRegistry.__init__cCs$||jd<tj|�|_|j|�dS)Nr)�__dict__r�changed)rrrrr�	_setBasesWs
zBaseAdapterRegistry._setBasescCs
|jdS)Nr)r)rrrr�<lambda>\szBaseAdapterRegistry.<lambda>cCs
|j|�S)N)r )rrrrrr!]scCs2|j|�|_x |jD]}t|j|�|j|<qWdS)N)�LookupClass�	_v_lookup�
_delegated�getattrr)r�namerrrr`sz!BaseAdapterRegistry._createLookupcCs|jd7_|jj|�dS)N�)�_generationr#r)r�originally_changedrrrreszBaseAdapterRegistry.changedcCst|t�std��|dkr.|j||||�dSttt|��}t|�}t|�}|j	}xt|�|krl|j
i�qTW||}||f}x.|D]&}	|j|	�}
|
dkr�i}
|
||	<|
}q�W|j|�|kr�dS|||<|jj|d�d}||j|<|dkr�|j
j|�|j|�dS)Nzname is not a stringrr')�
isinstancer�
ValueError�
unregister�tuple�map�_convert_None_to_Interfacer�lenr�append�getrr#�add_extendorr)r�required�providedr&�value�order�byorder�
components�key�k�d�nrrr�registeris6




zBaseAdapterRegistry.registerc
Csxttt|��}t|�}t|�}|j}t|�|kr4dS||}||f}x&|D]}|j|�}	|	dkrfdS|	}qLW|j|�S)N)r-r.r/rr0rr2)
rr4r5r&r7r8r9r:r;r<rrr�
registered�s


zBaseAdapterRegistry.registeredNcCs8ttt|��}t|�}|j}|t|�kr,dS||}||f}g}	x4|D],}
|j|
�}|dkrbdS|	j||
f�|}qHW|j|�}|dkr�dS|dk	r�||k	r�dS||=|s�x*t|	�D]\}
}
|
|
}|r�Pq�|
|
=q�Wx|r�|dr�|d=q�W|j|d}|dk�r |j|=|j	j
|�n
||j|<|j|�dS)NFr'r���r@)r-r.r/r0rr2r1�reversedrr#�remove_extendorr)rr4r5r&r6r7r8r9r:�lookupsr;r<�old�compr=rrrr,�sD







zBaseAdapterRegistry.unregistercCs�ttt|��}t}t|�}|j}xt|�|kr:|ji�q"W||}||f}x.|D]&}	|j|	�}
|
dkrvi}
|
||	<|
}qTW|j|f�|f||<|dk	r�|jj|d�d}||j|<|dkr�|j	j
|�|j|�dS)Nrr')r-r.r/�_BLANKr0rr1r2rr#r3r)rr4r5r6r&r7r8r9r:r;r<r=rrr�	subscribe�s*



zBaseAdapterRegistry.subscribecshttt|��}t|�}|j}|t|�kr,dS||}||f}g}x4|D],}	|j|	�}
|
dkrbdS|j||	f�|
}qHW|jt�}|s�dS�dkr�f}nt�fdd�|D��}||kr�dS|r�||t<nP|t=x*t|�D]\}
}	|
|	}
|
r�Pq�|
|	=q�Wx|�r|d�r|d=q�W|dk	�rZ|j	|t|�t|�}|dk�rZ|j	|=|j
j|�|j|�dS)Ncsg|]}|�kr|�qSrr)�.0�v)r6rr�
<listcomp>sz3BaseAdapterRegistry.unsubscribe.<locals>.<listcomp>r'rr@r@)
r-r.r/r0rr2r1rFrArr#rBr)rr4r5r6r7r8r9r:rCr;r<rD�newrEr=r)r6r�unsubscribe�sL








zBaseAdapterRegistry.unsubscribecCsGdd�d�}|S)Nc@seZdZiZdS)z2BaseAdapterRegistry.get.<locals>.XXXTwistedFakeOutN)�__name__�
__module__�__qualname__ZselfImpliedrrrr�XXXTwistedFakeOut'srPr)r�_rPrrrr2&szBaseAdapterRegistry.get)	rrr
rrrrrr)N)N)rMrNrOr$r(rr �propertyrrrr>rFr?r,rGrLr2rrrrr
s /
#
0
<r
c@sneZdZdd�Zddd�Zdd�Zedfdd	�Zedfd
d�Zedfdd
�Z	edfdd�Z
dd�Zdd�ZdS)�LookupBaseFallbackcCsi|_i|_i|_dS)N)�_cache�_mcache�_scache)rrrrr/szLookupBaseFallback.__init__NcCs"|jj�|jj�|jj�dS)N)rT�clearrUrV)r�ignoredrrrr4s

zLookupBaseFallback.changedcCsL|jj|�}|dkr"i}||j|<|rH|j|�}|dkrDi}|||<|}|S)N)rTr2)rr5r&�cache�crrr�	_getcache9s

zLookupBaseFallback._getcachecCs�t|t�std��|j||�}t|�}t|�dkrD|j|dt�}n|jt|�t�}|tkr�|j|||�}t|�dkr�|||d<n||t|�<|dkr�|S|S)Nzname is not a stringr'r)	r*rr+r[r-r0r2�_not_in_mapping�_uncached_lookup)rr4r5r&�defaultrY�resultrrrrFs
zLookupBaseFallback.lookupcCsTt|t�std��|j||�}|j|t�}|tkrD|j|f|||�S|dkrP|S|S)Nzname is not a string)r*rr+r[r2r\r)rr4r5r&r^rYr_rrrr
\s
zLookupBaseFallback.lookup1cCs|j||||�S)N)r)r�objectr5r&r^rrrriszLookupBaseFallback.queryAdapterc	Csjt|t�std��t|�}|j||�}|j|t�}|tkrJ|j|f||�}|dk	rf||�}|dk	rf|S|S)Nzname is not a string)r*rr+rr[r2r\r)	rr5r`r&r^r4rY�factoryr_rrrrls
zLookupBaseFallback.adapter_hookcCsV|jj|�}|dkr"i}||j|<t|�}|j|t�}|tkrR|j||�}|||<|S)N)rUr2r-r\�_uncached_lookupAll)rr4r5rYr_rrrr|s
zLookupBaseFallback.lookupAllcCsV|jj|�}|dkr"i}||j|<t|�}|j|t�}|tkrR|j||�}|||<|S)N)rVr2r-r\�_uncached_subscriptions)rr4r5rYr_rrrr�s
z LookupBaseFallback.subscriptions)N)
rMrNrOrrr[rFrr
rrrrrrrrrS-s


rS)�
LookupBasec@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�VerifyingBaseFallbackcCs4tj||�|jjdd�|_dd�|jD�|_dS)Nr'cSsg|]
}|j�qSr)r()rH�rrrrrJ�sz1VerifyingBaseFallback.changed.<locals>.<listcomp>)rSr�	_registryr�
_verify_ro�_verify_generations)rr)rrrr�szVerifyingBaseFallback.changedcCs$dd�|jD�|jkr |jd�dS)NcSsg|]
}|j�qSr)r()rHrfrrrrJ�sz1VerifyingBaseFallback._verify.<locals>.<listcomp>)rhrir)rrrr�_verify�szVerifyingBaseFallback._verifycCs|j�tj|||�S)N)rjrSr[)rr5r&rrrr[�szVerifyingBaseFallback._getcachecCs|j�tj|||�S)N)rjrSr)rr4r5rrrr�szVerifyingBaseFallback.lookupAllcCs|j�tj|||�S)N)rjrSr)rr4r5rrrr�sz#VerifyingBaseFallback.subscriptionsN)rMrNrOrrjr[rrrrrrre�s
re)�
VerifyingBasecs�eZdZ�fdd�Zd�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Ze	fdd�Z
e	dfdd�Zdd�Zdd�Z
dd�Zdd�Z�ZS)�AdapterLookupBasecs&||_i|_|j�tt|�j�dS)N)rg�	_required�init_extendors�superrlr)r�registry)�	__class__rrr�szAdapterLookupBase.__init__NcsJtt|�jd�x*|jj�D]}|�}|dk	r|j|�qW|jj�dS)N)rorlrrm�keysrLrW)rrXrf)rqrrr�szAdapterLookupBase.changedcCs&i|_x|jjD]}|j|�qWdS)N)�
_extendorsrgrr3)r�prrrrn�sz AdapterLookupBase.init_extendorscsT|j}xH�jD]>}|j|f�}�fdd�|D��g�fdd�|D�||<qWdS)Ncsg|]}�j|�r|�qSr)�isOrExtends)rH�e)r5rrrJ�sz2AdapterLookupBase.add_extendor.<locals>.<listcomp>csg|]}�j|�s|�qSr)ru)rHrv)r5rrrJ�s)rs�__iro__r2)rr5rs�i�	extendorsr)r5rr3�s
zAdapterLookupBase.add_extendorcs8|j}x,�jD]"}�fdd�|j|f�D�||<qWdS)Ncsg|]}|�kr|�qSrr)rHrv)r5rrrJsz5AdapterLookupBase.remove_extendor.<locals>.<listcomp>)rsrwr2)rr5rsrxr)r5rrB�sz!AdapterLookupBase.remove_extendorcGs:|j}x.|D]&}|j�}||kr|j|�d||<qWdS)Nr')rm�weakrefrG)rr4Z_refsrf�refrrr�
_subscribes

zAdapterLookupBase._subscribec
Cs�t|�}d}t|�}x\|jjD]P}|j}|t|�kr6q|jjj|�}|sJq||}	t|	|||d|�}|dk	rPqW|j	|�|S)Nr)
r-r0rgrrr#rsr2�_lookupr|)
rr4r5r&r_r7rpr8ryr9rrrr]s"
z"AdapterLookupBase._uncached_lookupcCs8|jtt|�||�}|dkr |S||�}|dkr4|S|S)N)rr.r)r�objectsr5r&r^rar_rrrr#sz#AdapterLookupBase.queryMultiAdapterc	Cs�t|�}t|�}i}xVt|jj�D]F}|j}|t|�kr:q"|jjj|�}|sNq"||}t	||||d|�q"W|j
|�t|j��S)Nr)r-r0rArgrrr#rsr2�
_lookupAllr|�items)	rr4r5r7r_rpr8ryr9rrrrb.s
z%AdapterLookupBase._uncached_lookupAllcCsdd�|j||�D�S)NcSsg|]}|d�qS)rr)rHrZrrrrJAsz+AdapterLookupBase.names.<locals>.<listcomp>)r)rr4r5rrrr@szAdapterLookupBase.namesc	Cs�t|�}t|�}g}xht|jj�D]X}|j}|t|�kr:q"|dkrJ|f}n|jjj|�}|dkrbq"t	||||t
|d|�q"W|j|�|S)Nr)r-r0rArgrrr#rsr2�_subscriptionsrFr|)rr4r5r7r_rpr8ryrrrrcCs 
z)AdapterLookupBase._uncached_subscriptionscCsf|jtt|�|�}|dkr6f}xB|D]}||�q$Wn,g}x&|D]}||�}|dk	r@|j|�q@W|S)N)rr.rr1)rr~r5rr_ZsubscriptionZ
subscriberrrrrZs

zAdapterLookupBase.subscribers)N)rMrNrOrrrnr3rBr|rFr]rrbrrcr�
__classcell__rr)rqrrl�srlc@seZdZdS)�
AdapterLookupN)rMrNrOrrrrr�hsr�csLeZdZeZff�fdd�	Zdd�Zdd�Z�fdd�Z�fd	d
�Z	�Z
S)�AdapterRegistrycstj�|_tt|�j|�dS)N)rz�WeakKeyDictionary�_v_subregistriesror�r)rr)rqrrrps
zAdapterRegistry.__init__cCsd|j|<dS)Nr')r�)rrfrrr�_addSubregistrywszAdapterRegistry._addSubregistrycCs||jkr|j|=dS)N)r�)rrfrrr�_removeSubregistryzs
z"AdapterRegistry._removeSubregistrycsb|jjdf�}x|D]}||kr|j|�qWx|D]}||kr4|j|�q4Wtt|�j|�dS)Nr)rr2r�r�ror�r )rrrDrf)rqrrr ~s

zAdapterRegistry._setBasescs2tt|�j|�x|jj�D]}|j|�qWdS)N)ror�rr�rr)rr)�sub)rqrrr�szAdapterRegistry.changed)rMrNrOr�r"rr�r�r rr�rr)rqrr�ksr�c@seZdZdS)�VerifyingAdapterLookupN)rMrNrOrrrrr��sr�c@seZdZeZdS)�VerifyingAdapterRegistryN)rMrNrOr�r"rrrrr��sr�cCs|dkrtS|SdS)N)r)�xrrrr/�sr/c
Cs�||krNxv||jD]4}|j|�}|rt|||||d|�}|dk	r|SqWn2x0|D](}	|j|	�}|rT|j|�}|dk	rT|SqTWdS)Nr')�__sro__r2r})
r9�specsr5r&rx�l�spec�compsrf�ifacerrrr}�s




r}c	Cst||krFxft||j�D](}|j|�}|rt|||||d|�qWn*x(t|�D]}|j|�}|rP|j|�qPWdS)Nr')rAr�r2r�update)	r9r�r5r_rxr�r�r�r�rrrr�s

rc
	Cs�||krHxvt||j�D]*}|j|�}|rt||||||d|�qWn8x6t|�D]*}	|j|	�}|rR|j|�}|rR|j|�qRWdS)Nr')rAr�r2r��extend)
r9r�r5r&r_rxr�r�r�r�rrrr��s


r�)!�__doc__rzZzope.interfacerrrrZzope.interface.interfacesrZzope.interface._compatrrrFr`r
r\rSZLookupBasePyZ-zope.interface._zope_interface_coptimizationsrd�ImportErrorreZVerifyingBasePyrkrlr�r�r�r�r/r}rr�rrrr�<module>sJl

$$

Zerion Mini Shell 1.0