Ϫf(dZddlZddlmZddlmZdZdZdZidd d d d d dd dddd dddd ddd d dddd dddd dd d d ddd d dddd d d!dd d"d#dd d$ddd d%dd d d&d'dd d(ddd d)d*dd ddd d+dd d'dd ddd d dd d,Z idd-d d.d!d/d#d0dd1dd2dd3dd4d'd5d6d7d d8dd9dd:d;d<d+d=d*d7d>d=Z Gd?d@e Z GdAdBe Z GdCdDe ZdEZdFZdGZy)Hz XMPP Error support. N)Optional)domishz$http://www.w3.org/XML/1998/namespacez#urn:ietf:params:xml:ns:xmpp-streamsz#urn:ietf:params:xml:ns:xmpp-stanzas bad-request400modify)codetypeconflict409cancelfeature-not-implemented501 forbidden403authgone302internal-server-error500waititem-not-found404z jid-malformednot-acceptable406 not-allowed405not-authorized401payment-required402zrecipient-unavailableredirectregistration-required407zremote-server-not-foundremote-server-timeout504503)zresource-constraintservice-unavailablezsubscription-requiredzundefined-conditionzunexpected-request)rr)rr)rr)rr)rr)rr )rr )rr)r"r408)r$r)r r )rr)r r 502)r'r)r'r 510c@eZdZUdZdZeeed<ddZdefdZ dZ y) BaseErroraK Base class for XMPP error exceptions. @cvar namespace: The namespace of the C{error} element generated by C{getElement}. @type namespace: C{str} @ivar condition: The error condition. The valid values are defined by subclasses of L{BaseError}. @type contition: C{str} @ivar text: Optional text message to supplement the condition or application specific condition. @type text: C{unicode} @ivar textLang: Identifier of the language used for the message in C{text}. Values are as described in RFC 3066. @type textLang: C{str} @ivar appCondition: Application specific condition element, supplementing the error condition in C{condition}. @type appCondition: object providing L{domish.IElement}. N namespacecftj|||_||_||_||_y)N) Exception__init__ conditiontexttextLang appCondition)selfr1r2r3r4s F/usr/lib/python3/dist-packages/twisted/words/protocols/jabber/error.pyr0zBaseError.__init__Ys-4 "   (returncdj|jj|j}|jr|d|jzz }|S)Nz{} with condition {!r}z: )format __class____name__r1r2)r5messages r6__str__zBaseError.__str__`sF*11 NN # #T^^  99 tdii' 'Gr7cxtjd}|j|j|jf|j rJ|j|jdf|j }|j r|j |tdf<|jr|j|j|S)z Get XML representation from self. The method creates an L{domish} representation of the error data contained in this exception. @rtype: L{domish.Element} )Nerrorr2)contentlang) rElement addElementr-r1r2r3NS_XMLr4addChild)r5r@r2s r6 getElementzBaseError.getElementjs/ $..$..9: 99##T^^V$rGr7r6r,r,Bs-( $Ix}#)r7r,ceZdZdZeZdZy) StreamErrorzq Stream Error exception. Refer to RFC 3920, section 4.7.3, for the allowed values for C{condition}. cJddlm}tj|}||_|S)z Get XML representation from self. Overrides the base L{BaseError.getElement} to make sure the returned element is in the XML Stream namespace. @rtype: L{domish.Element} r) NS_STREAMS)(twisted.words.protocols.jabber.xmlstreamrQr,rGuri)r5rQr@s r6rGzStreamError.getElements$ H$$T*  r7N)r<rHrIrJNS_XMPP_STREAMSr-rGrMr7r6rOrO~s  I r7rOc*eZdZdZeZ ddZdZdZy) StanzaErrora Stanza Error exception. Refer to RFC 3920, section 9.3, for the allowed values for C{condition} and C{type}. @ivar type: The stanza error type. Gives a suggestion to the recipient of the error on how to proceed. @type type: C{str} @ivar code: A numeric identifier for the error condition for backwards compatibility with pre-XMPP Jabber implementations. Nctj|||||| t|d}||_ t|d|_g|_d|_y#t$rY3wxYw#t$r d|_Y0wxYw)Nr r)r,r0STANZA_CONDITIONSKeyErrorr rchildreniq)r5r1r r2r3r4s r6r0zStanzaError.__init__s 4D(LI < (3F;  ))4V>## ;;. (||v%7|"//0@A#LL "L#$  r7cZt|t}t|d|d|d|d}|S)z Build an exception object from a stream error. @param element: the stream error @type element: L{domish.Element} @return: the generated exception object @rtype: L{StreamError} r1r2r3r4)rjrTrO)rir@ exceptions r6exceptionFromStreamErrorrm s>  1E kE&M5+SI r7cg}dx}x}x}x}x}}|jD]}|jdk(r|j|jk(rn|jd}|jd}t |t } | d}| d}| d}| d}|rt|swt |\}}t|j}|j|| tdSt|||||} || _ || _ | S) z Build an exception object from an error stanza. @param stanza: the error stanza @type stanza: L{domish.Element} @return: the generated exception object @rtype: L{StanzaError} Nr@rr r1r2r3r4) rerfrSrgrjrcCODES_TO_CONDITIONSrKr@appendrVrZra) rarZr1r2r3r4r rrir@rls r6exceptionFromStanzarqsH?CCICCxC,C??$% <<7 "w{{fjj'@''/D''/D9Ek*I=DZ(H 0L"5d"; 46<<( OOG $% 4  ItT8\JI!II r7)rJr`typingrtwisted.words.xishrrErTrcrXror/r,rOrVrjrmrqrMr7r6rts   % /77E841x@%0   UH -  eV< uh7eX6uh7E84uf57eV<1eV< x@!"eV<#$%*6:$)8<&+V<$)48#(&9-2  $ % '     '  $ ' , , ! , 0 * ,  ,!" ,#*9 9x)2M)M`"J$%r7