o $ x`!@sdZgdZGdddeZGdddeZGdddeZGdd d eZGd d d eZGd d d eZGdddeZ Gddde Z dS)zInterface-specific exceptions )InvalidDoesNotImplementBrokenImplementationBrokenMethodImplementationMultipleInvalid BadImplementsInvalidInterfacec@eZdZdZdS)rz A specification is violated N__name__ __module__ __qualname____doc__rr;/usr/lib/python3/dist-packages/zope/interface/exceptions.pyrrc@sjeZdZdZdZeZdZdddZe ddZ e d d Z e d d Z e d dZ dZdZdZddZdS)_TargetInvalidz NcCs&z|j|WS|jy|YSwN)args_NOT_GIVEN_CATCH)selfixdefaultrrr_get_arg_or_default8s  z"_TargetInvalid._get_arg_or_defaultcCs ||jSr)r _IX_INTERFACErrrr interface>s z_TargetInvalid.interfacecCs||j|jSr)r _IX_TARGET _NOT_GIVENrrrrtargetBsz_TargetInvalid.targetcCs|j}||jur dSd|fS)Nz An objectz The object %r)r r)rr rrr _str_subjectZs  z_TargetInvalid._str_subjectcCsd|jpdS)Nz$has failed to implement interface %sz )rrrrr_str_descriptionasz_TargetInvalid._str_descriptionz: z .cCsd|j|j|j|j|jfS)Nz %s %s%s%s%s)r!r"_str_conjunction _str_details _str_trailerrrrr__str__ksz_TargetInvalid.__str__r)r r r rr IndexErrorrrrpropertyrr r!r"r$r%r&r'rrrrr"s$      rc@seZdZdZdZdS)ra DoesNotImplement(interface[, target]) The *target* (optional) does not implement the *interface*. .. versionchanged:: 5.0.0 Add the *target* argument and attribute, and change the resulting string value of this object accordingly. z.Does not declaratively implement the interfaceN)r r r r r%rrrrrus rc@s:eZdZdZejdZedZeddZ eddZ dS)ra[ BrokenImplementation(interface, name[, target]) The *target* (optional) is missing the attribute *name*. .. versionchanged:: 5.0.0 Add the *target* argument and attribute, and change the resulting string value of this object accordingly. The *name* can either be a simple string or a ``Attribute`` object. rcC |jdSNrrrrrrname zBrokenImplementation.namecCs"dt|jtr t|jS|jS)Nz!The %s attribute was not provided) isinstancer-strreprrrrrr%s z!BrokenImplementation._str_detailsN) r r r r rr_IX_NAMErr)r-r%rrrrrs  rc@sTeZdZdZdZedZedZeddZeddZ e dd Z ed d Z d S) ra BrokenMethodImplementation(method, message[, implementation, interface, target]) The *target* (optional) has a *method* in *implementation* that violates its contract in a way described by *mess*. .. versionchanged:: 5.0.0 Add the *interface* and *target* argument and attribute, and change the resulting string value of this object accordingly. The *method* can either be a simple string or a ``Method`` object. .. versionchanged:: 5.0.0 If *implementation* is given, then the *message* will have the string "implementation" replaced with an short but informative representation of *implementation*. rcCr*)Nrr,rrrrmethodr.z!BrokenMethodImplementation.methodcCr*r+r,rrrrmessr.zBrokenMethodImplementation.messc sddl}z|j}t}Wnty |j}|jfdd}Ynwz||}Wnttfy6t|YSwz|j }Wn tyH|j }Ynw|||S)Nrcs|Srr)sigfrrszABrokenMethodImplementation.__implementation_str..) inspect signaturer0AttributeError getargspec formatargspec ValueError TypeErrorr1r r )implr:r6 formatsigr-rr7r__implementation_strs(       z/BrokenMethodImplementation.__implementation_strcCsn||j|j}|j}||jur"d|vr"|dd}|||f}dt|jtr1t |j|fS|j|fS)Nimplementationz%rz)The contract of %s is violated because %s) r_IX_IMPLrr5replace/_BrokenMethodImplementation__implementation_strr/r4r0r1)rrAmessagerrrr%s z'BrokenMethodImplementation._str_detailsN) r r r r rErrr)r4r5 staticmethodrGr%rrrrrs   rcsDeZdZdZdZfddZeddZeddZd Z d Z Z S) rz The *target* has failed to implement the *interface* in multiple ways. The failures are described by *exceptions*, a collection of other `Invalid` instances. .. versionadded:: 5.0 rcstt|||t|dSr)superr__init__tuple)rrr exceptions __class__rrrKszMultipleInvalid.__init__cCr*)Nr3r,rrrrrMr.zMultipleInvalid.exceptionscCsdddd|jDS)Nz css,|]}t|tr|jnt|VqdSr)r/rr%stripr0).0xrrr s  z/MultipleInvalid._str_details..)joinrMrrrrr%s  zMultipleInvalid._str_details:) r r r r rrKr)rMr%r$r& __classcell__rrrNrrs    rc@r)rz'The interface has invalid contents Nr rrrrr rrc@r)rzAn implementation assertion is invalid because it doesn't contain an interface or a sequence of valid implementation assertions. Nr rrrrrrrN) r __all__ Exceptionrrrrrrrr@rrrrrs  SK!