ó śŠ/Qc@s-dZdZddlZddlmZddlmZddlmZddlZddlZddl m Z ddl m Z dd l m Z dd l mZdd lmZdd 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(t CLASS_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.t DeclarationcBsSeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z e Z RS(sInterface declarationscGstj|t|ƒƒdS(N(Rt__init__t_normalizeargs(tselft interfaces((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyR 7scCs2tj||ƒy |`Wntk r-nXdS(N(Rtchangedt_v_attrstAttributeError(R toriginally_changed((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyR:s   cCs|j|ƒo||jƒkS(s:Test whether an interface is in the specification (textendsR(R t interface((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyt __contains__AscCs |jƒS(sCReturn an iterator for the interfaces in the specification (R(R ((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyt__iter__GscCs t|jƒS(sCReturn an iterator of all included and extended interfaces (titert__iro__(R ((s?/usr/lib/python2.7/dist-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((s?/usr/lib/python2.7/dist-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((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyt__add__[s    ( t__name__t __module__t__doc__R RRRRRR!t__radd__(((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyR 4s      t ImplementscBs,eZdZdZdZd„Zd„ZRS(t?cCs d|jS(Ns(R"(R ((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyt__repr__~scCst|jffS(N(t implementedBytinherit(R ((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyt __reduce__sN((R"R#tNoneR*tdeclaredR(R+(((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyR&ts  c Cs`y|jjdƒ}Wnutk rt|dd ƒ}|d krgtj|ƒ}|d k rc|StS|jtkrz|St t |fƒŒSXt |tƒr”|S|d krĻtj|ƒ}|d k rĻ|Sn|d k 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|RFRR&R.RR;(R tobRB((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyt__call__0s  (R"R#R$R RN(((s?/usr/lib/python2.7/dist-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((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyR TscCs<t|ttfƒr$tdƒ‚nt||jŒ|SdS(NsIThe implementer_only decorator is not supported for methods or functions.(R8RRt ValueErrorRGR(R RM((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyRNWs(R"R#R$R RN(((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyRO<s cCsžtrtdƒ‚ntjdƒ}|j}||jksHd|kr[t|dƒ‚nd|krzt|dƒ‚n||f|dR;R R@tFalset issubclasstTrueR?R1R](tobjectRRAtissubtdamc((s?/usr/lib/python2.7/dist-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((s?/usr/lib/python2.7/dist-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((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pytnoLongerProvidesstClassProvidesBaseFallbackcBseZd„ZRS(cCs6||jkr&|dkr|S|jStdƒ‚dS(NR1(R_R,RYR(R R`RA((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyRa s  (R"R#Ra(((s?/usr/lib/python2.7/dist-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((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyR @s cCs|j|jfS(N(R2Rq(R ((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyR+Fs(R"R#R$R R+RpRa(((s?/usr/lib/python2.7/dist-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((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pyRkLs  cGsštrttdƒ‚ntjdƒ}|j}||jksLd|kr[tdƒ‚nd|krvtdƒ‚nt|ƒ|dR R6R[t_ADVICE_WARNINGR R&RER)RGRFRKRLRORYRZR\R]RctWeakValueDictionaryRbRft__safe_for_unpickling__RjRlRnRgRotClassProvidesBasePyRpt_zope_interface_coptimizationst ImportErrorR?RkRvRuRtRwRyRzR{R~RmRR„R,R R7R=(((s?/usr/lib/python2.7/dist-packages/zope/interface/declarations.pytsˆ   @ W   ,'     $    2  ,   1