Spade

Mini Shell

Directory:~$ /proc/self/root/usr/lib64/python2.7/site-packages/zope/interface/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyc

�
j�/Qc@s-dZdZddlZddlmZddlmZddlmZddlZddlZddl	m
Z
ddlmZdd	lm
Z
dd
lmZddlmZddlmZiZd
ZdZdefd��YZdefd��YZd�ZeZd�Zd�Zd�Zdd9d��YZdd:d��YZd�Zd�Z
d�Z!defd��YZ"e"Z#ej$�Z%d
�Z"e&e"_'d!�Z(d"�Z)d#�Z*d$e+fd%��YZ,e,Z-e,Z.yddl/Z/Wne0k
rnXdd&l/m.Z.d'ee.fd(��YZ1d)�Z2d*�Z3d+�Z4d,d;d-��YZ5d.�Z6d/�Z7d0�Z8e8Z9d1�Z:e:Z;d2e+fd3��YZ<e<Z=dd4�Z?e�Z@yddl/Z/Wne0k
r�nAXdd5l/mZdd6l/m;Z;dd7l/m9Z9dd8l/m=Z=e=�ZAdS(<s�Implementation
of interface declarations

There are three flavors of declarations:

  - Declarations are used to simply name declared interfaces.

  - ImplementsDeclarations are used to express the interfaces that a
    class implements (that instances of the class provides).

    Implements specifications support inheriting interfaces.

  - ProvidesDeclarations are used to express interfaces directly
    provided by objects.

trestructuredtexti����N(tFunctionType(t
MethodType(t
ModuleType(taddClassAdvisor(tInterfaceClass(tSpecificationBase(t
Specification(tCLASS_TYPES(tPYTHON3sIClass
advice impossible in Python3.  Use the @%s class decorator instead.s\The %s
API is deprecated, and will not work in Python3  Use the @%s class
decorator
instead.tDeclarationcBsSeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e	Z
RS(sInterface
declarationscGstj|t|��dS(N(Rt__init__t_normalizeargs(tselft
interfaces((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR7scCs2tj||�y
|`Wntk
r-nXdS(N(Rtchangedt_v_attrstAttributeError(R
toriginally_changed((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR:s


cCs|j|�o||j�kS(s:Test whether an interface is in the
specification
       
(textendsR(R
t	interface((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt__contains__AscCs
|j�S(sCReturn an iterator for the interfaces in the specification
       
(R(R
((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt__iter__GscCs
t|j�S(sCReturn
an iterator of all included and extended interfaces
       
(titert__iro__(R
((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt	flattenedLscCsTtg|j�D]=}g|j�D]}|j|d�r#|^q#s|^q�S(s/Remove
interfaces from a specification
        i(R
RR(R
tothertitj((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt__sub__QscCs�i}g}x:|j�D],}||krd||<|j|�qqWx:|j�D],}||krVd||<|j|�qVqVWt|�S(sCAdd
two specifications or a specification and an interface
        i(RtappendR
(R
RtseentresultR((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt__add__[s

(t__name__t
__module__t__doc__RRRRRRR!t__radd__(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR
4s						
	t
ImplementscBs,eZdZdZdZd�Zd�ZRS(t?cCsd|jS(Ns<implementedBy
%s>(R"(R
((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt__repr__~scCst|jffS(N(t
implementedBytinherit(R
((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt
__reduce__�sN((R"R#tNoneR*tdeclaredR(R+(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR&ts
	c
Cs`y|jjd�}Wnutk
r�t|dd�}|dkrgtj|�}|dk	rc|StS|jtkrz|St	t
|f��SXt|t�r�|S|dkr�tj|�}|dk	r�|Sn|dk	r|f}tt
|��}d|_|`
nsy
|j}Wn5tk
rLt|�sCtd|��nd}nXtg|D]}t|�^qW�}||_t|dd�p�ddt|dd�p�d|_ym||_
t|d�s�t|_nt|t�rd|jkrt|t|d	t|���|_nWn<tk
r[t|t�sNtd
|��n|t|<nX|S(
skReturn the interfaces implemented for a
class' instances

      The value returned is an IDeclaration.
    t__implemented__s$ImplementedBy called for
non-factoryR#R't.R"t__providedBy__t__provides__t	__class__s!ImplementedBy
called for
non-typeN((t__dict__tgetRtgetattrR,t#BuiltinImplementationSpecificationst_emptyR2R&R
Rt
isinstanceR*R.t	__bases__tcallablet	TypeErrorR)R"thasattrtobjectSpecificationDescriptorR0tDescriptorAwareMetaClassest
ClassProvidesttypeR1(tclstspectbasestc((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pytimplementedByFallback�s\
			


%	5	%
cGs/t|�}d|_d|_t||�dS(s8Declare
the only interfaces implemented by instances of a class

      The arguments after the class are one or more interfaces or interface
      specifications (``IDeclaration`` objects).

      The interfaces given (including the interfaces in the specifications)
      replace any previous declarations.
   
N((R)R-R,R*tclassImplements(RARRB((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pytclassImplementsOnly�s			cGs�t|�}|jtt|��7_g}i}x7|jD],}||kr=d||<|j|�q=q=W|jdk	r�xI|jjD]8}t|�}||kr�d||<|j|�q�q�Wnt|�|_dS(sIDeclare
additional interfaces implemented for instances of a class

      The arguments after the class are one or more interfaces or
      interface specifications (``IDeclaration`` objects).

      The interfaces given (including the interfaces in the specifications)
      are added to any interfaces previously declared.
   
iN(R)R-ttupleRRR*R,R9(RARRBRCRtbRD((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRF�s	

cCs*|jd\}}|`|||�|S(Nt__implements_advice_data__(R3RJ(RARRF((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt_implements_advice	s
timplementercBs
eZdZd�Zd�ZRS(sDeclare the interfaces implemented by instances
of a class.

      This function is called as a class decorator.

      The arguments are one or more interfaces or interface
      specifications (IDeclaration objects).

      The interfaces given (including the interfaces in the
      specifications) are added to any interfaces previously
      declared.

      Previous declarations include declarations for base classes
      unless implementsOnly was used.

      This function is provided for convenience. It provides a more
      convenient way to call classImplements. For example::

        @implementer(I1)
        class C(object):
            pass

      is equivalent to calling::

        classImplements(C, I1)

      after the class has been created.
     
cGs
||_dS(N(R(R
R((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR-scCsft|t�r#t||j�|St|j�}y
||_Wn
tk
ratd|��nX|S(NsCan't declare
implements(R8R>RFRR&R.RR;(R
tobRB((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt__call__0s

(R"R#R$RRN(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRLs	timplementer_onlycBs
eZdZd�Zd�ZRS(snDeclare the only interfaces implemented by
instances of a class

      This function is called as a class decorator.

      The arguments are one or more interfaces or interface
      specifications (IDeclaration objects).

      Previous declarations including declarations for base classes
      are overridden.

      This function is provided for convenience. It provides a more
      convenient way to call classImplementsOnly. For example::

        @implementer_only(I1)
        class C(object): pass

      is equivalent to calling::

        classImplementsOnly(I1)

      after the class has been created.
     
cGs
||_dS(N(R(R
R((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRTscCs<t|ttf�r$td��nt||j�|SdS(NsIThe
implementer_only decorator is not supported for methods or
functions.(R8RRt
ValueErrorRGR(R
RM((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRNWs(R"R#R$RRN(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRO<s	cCs�trtd��ntjd�}|j}||jksHd|kr[t|d��nd|krzt|d��n||f|d<ttdd�dS(	Ns"Class
advice impossible in Python3iR#s* can be used only from a class
definition.RJs- can be used only once in a class
definition.tdepthi(R	R;tsyst	_getframetf_localst	f_globalsRRK(tnameRRFtframetlocals((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt_implementscs	cGs-trttd��ntd|t�dS(s�Declare
interfaces implemented by instances of a class

      This function is called in a class definition.

      The arguments are one or more interfaces or interface
      specifications (IDeclaration objects).

      The interfaces given (including the interfaces in the
      specifications) are added to any interfaces previously
      declared.

      Previous declarations include declarations for base classes
      unless implementsOnly was used.

      This function is provided for convenience. It provides a more
      convenient way to call classImplements. For example::

        implements(I1)

      is equivalent to calling::

        classImplements(C, I1)

      after the class has been created.
    RLt
implementsN(R	R;t
_ADVICE_ERRORRYRF(R((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRZwscGs-trttd��ntd|t�dS(sLDeclare
the only interfaces implemented by instances of a class

      This function is called in a class definition.

      The arguments are one or more interfaces or interface
      specifications (IDeclaration objects).

      Previous declarations including declarations for base classes
      are overridden.

      This function is provided for convenience. It provides a more
      convenient way to call classImplementsOnly. For example::

        implementsOnly(I1)

      is equivalent to calling::

        classImplementsOnly(I1)

      after the class has been created.
   
ROtimplementsOnlyN(R	R;R[RYRG(R((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR\�stProvidescBs/eZdZd�Zd�ZdZd�ZRS(s�Implement
__provides__, the instance-specific specification

    When an object is pickled, we pickle the interfaces that it implements.
   
cGs:|f||_||_tj||t|�f�dS(N(t_Provides__argst_clsR
RR)(R
RAR((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR�s	cCs
t|jfS(N(R]R^(R
((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR+�sszope.interfacecCs/|dkr||jkr|Std��dS(sHMake
sure that a class __provides__ doesn't leak to an instance
       
R1N(R,R_R(R
tinstRA((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt__get__�s(R"R#R$RR+Ra(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR]�s
		cGs8tj|�}|dkr4t|�}|t|<n|S(s�Cache instance
declarations

      Instance declarations are shared among instances that have the same
      declaration. The declarations are cached in a weak value dictionary.
   
N(tInstanceDeclarationsR4R,t
ProvidesClass(RRB((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR]�s

cGs�t|dd�}|dk	rWt|dd�|krWt|t�sWtd��qWnt|�}|dkr~t|�}nt}x'tD]}t||�r�t	}Pq�q�W|r�t
|||�|_nt||�|_dS(s@Declare interfaces declared directly for
an object

      The arguments after the object are one or more interfaces or
interface
      specifications (``IDeclaration`` objects).

      The interfaces given (including the interfaces in the specifications)
      replace interfaces previously declared for the object.
    R2sHAttempt to make an interface declaration on a non-descriptor-aware
classN(
R5R,R8R>R;RR@tFalset
issubclasstTrueR?R1R](tobjectRRAtissubtdamc((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pytdirectlyProvides�s
	$	
cGst|t|�|�dS(sADeclare
interfaces declared directly for an object

    The arguments after the object are one or more interfaces or interface
    specifications (``IDeclaration`` objects).

    The interfaces given (including the interfaces in the specifications)
are
    added to the interfaces previously declared for the object.
   
N(RjtdirectlyProvidedBy(RgR((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pytalsoProvidess	cCs9t|t|�|�|j|�r5td��ndS(s;
Removes a directly provided interface from an object.
    s-Can only remove directly provided interfaces.N(RjRkt
providedByRP(RgR((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pytnoLongerProvidesstClassProvidesBaseFallbackcBseZd�ZRS(cCs6||jkr&|dkr|S|jStd��dS(NR1(R_R,RYR(R
R`RA((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRa
s
(R"R#Ra(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRos(tClassProvidesBaseR?cBs)eZdZd�Zd�ZejZRS(s�Special
descriptor for class __provides__

    The descriptor caches the implementedBy info, so that
    we can get declarations for objects without instance-specific
    interfaces a bit quicker.
   
cGsL||_t|�|_||f||_tj||t|�f�dS(N(R_R)RYt_ClassProvides__argsR
R(R
RAtmetaclsR((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR@s	cCs|j|jfS(N(R2Rq(R
((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR+Fs(R"R#R$RR+RpRa(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR?9s		cCsBt|dd�}|dks-t|t�r1tSt|jd
�S(spReturn the interfaces directly provided by the given object

    The value returned is an ``IDeclaration``.
    R1i����N(R5R,R8R&R7R
R9(Rgtprovides((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRkLs
cGs�trttd��ntjd�}|j}||jksLd|kr[td��nd|krvtd��nt|�|d<tt	dd�d	S(
s�Declare interfaces provided directly by a class

      This function is called in a class definition.

      The arguments are one or more interfaces or interface specifications
      (``IDeclaration`` objects).

      The given interfaces (including the interfaces in the specifications)
      are used to create the class's direct-object interface
specification.
      An error will be raised if the module class has an direct interface
      specification. In other words, it is an error to call this function
more
      than once in a class definition.

      Note that the given interfaces have nothing to do with the interfaces
      implemented by instances of the class.

      This function is provided for convenience. It provides a more
convenient
      way to call directlyProvides for a class. For example::

        classProvides(I1)

      is equivalent to calling::

        directlyProvides(theclass, I1)

      after the class has been created.
    tprovideriR#s7classProvides can be used only from a class
definition.R1s:classProvides can only be used once in a class
definition.RQiN(
R	R;R[RRRSRTRURRt_classProvides_advice(RRWRX((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt
classProvides^s	cCs$|jd}|`t||�|S(NR1(R3R1Rj(RAR((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRu�s

RtcBs
eZdZd�Zd�ZRS(s(Class decorator version of
classProvidescGs
||_dS(N(R(R
R((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR�scCst||j�|S(N(RjR(R
RM((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRN�s(R"R#R$RRN(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRt�s	cGsztjd�}|j}||jk	s3d|krBtd��nd|kr]td��nttt|��|d<dS(s�Declare
interfaces provided by a module

    This function is used in a module definition.

    The arguments are one or more interfaces or interface specifications
    (``IDeclaration`` objects).

    The given interfaces (including the interfaces in the specifications)
are
    used to create the module's direct-object interface specification.
 An
    error will be raised if the module already has an interface
specification.
    In other words, it is an error to call this function more than once in
a
    module definition.

    This function is provided for convenience. It provides a more
convenient
    way to call directlyProvides. For example::

      moduleImplements(I1)

    is equivalent to::

      directlyProvides(sys.modules[__name__], I1)
    iR"s9moduleProvides can only be used from a module
definition.R1s<moduleProvides can only be used once in a module
definition.N(RRRSRTRUR;R]RR(RRWRX((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pytmoduleProvides�s	cCs
t||�S(sfProvide
object specifications

    These combine information for the object and for it's classes.
   
(R](tdirectRA((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pytObjectSpecification�scCs`t|dd�}|dk	r4t|t�r4|Sny
|j}Wntk
rUtSXt|�S(NR1(R5R,R8RR2RR7R)(RMRsRA((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pytgetObjectSpecificationFallback�s

cCs�y
|j}Wntk
r't|�SXy|jWnztk
r�y
|j}Wntk
rmt|j�SXy|jj}Wntk
r�|SX||kr�t|j�SnX|S(N(R0RtgetObjectSpecificationRR1R)R2(RMtrtcp((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pytprovidedByFallback�s$





t%ObjectSpecificationDescriptorFallbackcBseZdZd�ZRS(s�Implement
the `__providedBy__` attribute

    The `__providedBy__` attribute computes the interfaces peovided by
    an object.
    cCsB|dkrt|�St|dd�}|dk	r8|St|�S(s2Get an
object specification for an object
       
R1N(R,R{R5R)(R
R`RARs((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRa
s
(R"R#R$Ra(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyRscCsn|dkrg}n|j}t|jks<t|jkrL|j|�nx|D]}t||�qSW|S(s�Normalize
declaration arguments

    Normalization arguments might contain Declarions, tuples, or single
    interfaces.

    Anything but individial interfaces or implements specs will be
expanded.
   
N(R,R2Rt__mro__R&RR(tsequencetoutputRAtv((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyR0s		
(R)(Rm(R{(tObjectSpecificationDescriptor((((BR$t
__docformat__RRttypesRRRtwarningstweakreftzope.interface.adviceRtzope.interface.interfaceRRRtzope.interface._compatRR>R	R6R[t_ADVICE_WARNINGR
R&RER)RGRFRKRLRORYRZR\R]RctWeakValueDictionaryRbRft__safe_for_unpickling__RjRlRnRgRotClassProvidesBasePyRpt_zope_interface_coptimizationstImportErrorR?RkRvRuRtRwRyRzR{R~RmRR�R,RR7R=(((sA/usr/lib64/python2.7/site-packages/zope/interface/declarations.pyt<module>s�@	W			,'		
	 	
		$		
		2	
	,			1