%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/words/protocols/jabber/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/words/protocols/jabber/__pycache__/error.cpython-312.pyc

�

Ϫ�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#d0�dd1�dd2�dd3�dd4�d'd5�d6d7�d
d8�dd9�dd:�d;d<�d+d=�d*d7�d>d=�Z
Gd?�d@e�ZGdA�dBe�Z
GdC�dDe�ZdE�ZdF�ZdG�Zy)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-request�400�modify)�code�type�conflict�409�cancel�feature-not-implemented�501�	forbidden�403�auth�gone�302�internal-server-error�500�wait�item-not-found�404z
jid-malformed�not-acceptable�406�not-allowed�405�not-authorized�401�payment-required�402zrecipient-unavailable�redirect�registration-required�407zremote-server-not-found�remote-server-timeout�504�503)zresource-constraint�service-unavailablezsubscription-requiredzundefined-conditionzunexpected-request)rr)rr)rr)rr)rr)rr)rr)rr)r"r�408)r$r)r
r)rr)r
r�502)r'r)r'r�510c�@�eZdZUdZdZeeed<dd�Zdefd�Z	d�Z
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�	namespacec�f�tj|�||_||_||_||_y)N)�	Exception�__init__�	condition�text�textLang�appCondition)�selfr1r2r3r4s     �F/usr/lib/python3/dist-packages/twisted/words/protocols/jabber/error.pyr0zBaseError.__init__Ys-�����4� �"�����	� ��
�(����returnc��dj|jj|j�}|jr|d|jzz
}|S)Nz{} with condition {!r}z: )�format�	__class__�__name__r1r2)r5�messages  r6�__str__zBaseError.__str__`sF��*�1�1��N�N�#�#�T�^�^�
���9�9��t�d�i�i�'�'�G��r7c�x�tjd�}|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}
        )N�errorr2)�content�lang)
r�Element�
addElementr-r1r2r3�NS_XMLr4�addChild)r5r@r2s   r6�
getElementzBaseError.getElementjs�������/��
���$�.�.�$�.�.�9�:��9�9��#�#�T�^�^�V�$<�d�i�i�#�P�D��}�}�)-����f�f�%�&�����N�N�4�,�,�-��r7)NNN)r<�
__module__�__qualname__�__doc__r-r�str�__annotations__r0r>rG�r7r6r,r,Bs-���( $�I�x��}�#�)����r7r,c��eZdZdZeZd�Zy)�StreamErrorzq
    Stream Error exception.

    Refer to RFC 3920, section 4.7.3, for the allowed values for C{condition}.
    c�J�ddlm}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,rG�uri)r5rQr@s   r6rGzStreamError.getElement�s$��	H��$�$�T�*����	��r7N)r<rHrIrJ�NS_XMPP_STREAMSr-rGrMr7r6rOrO~s��� �I�
r7rOc�*�eZdZdZeZ	dd�Zd�Zd�Zy)�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.
    Nc���tj|||||�|�
	t|d}||_	t|d|_g|_d|_y#t$rY�3wxYw#t$r
d|_Y�0wxYw)Nr	r)r,r0�STANZA_CONDITIONS�KeyErrorr	r�children�iq)r5r1r	r2r3r4s      r6r0zStanzaError.__init__�s���	���4��D�(�L�I��<�
�(��3�F�;����	�	�)�)�4�V�<�D�I���
������
��
���	��D�I�	�s"�A�A �	A�A� A3�2A3c��tj|�}|j|d<|jr|j|d<|S)z�
        Get XML representation from self.

        Overrides the base L{BaseError.getElement} to make sure the returned
        element has a C{type} attribute and optionally a legacy C{code}
        attribute.

        @rtype: L{domish.Element}
        r	r)r,rGr	r)r5r@s  r6rGzStanzaError.getElement�s:���$�$�T�*���	�	��f�
��9�9� �I�I�E�&�M��r7c��ddlm}||d��}tj|j�|_|j	|j��|S)a
        Construct error response stanza.

        The C{stanza} is transformed into an error response stanza by
        swapping the C{to} and C{from} addresses and inserting an error
        element.

        @note: This creates a shallow copy of the list of child elements of the
               stanza. The child elements themselves are not copied themselves,
               and references to their parent element will still point to the
               original stanza element.

               The serialization of an element does not use the reference to
               its parent, so the typical use case of immediately sending out
               the constructed error response is not affected.

        @param stanza: the stanza to respond to
        @type stanza: L{domish.Element}
        r)�
toResponser@)�
stanzaType)rRr^�copyrZrFrG)r5�stanzar^�responses    r6r^zStanzaError.toResponse�sC��(	H��f��9�� �I�I�f�o�o�6������$�/�/�+�,��r7)NNNN)	r<rHrIrJ�NS_XMPP_STANZASr-r0rGr^rMr7r6rVrV�s$��� �I�LP��(� r7rVc���d}d}d}d}|j�D]R}|j|k(r?|jdk(r#t|�}|j	t
df�}�D|j}�Q|}�T||||d�S)a�
    Parses an error element.

    @param error: The error element to be parsed
    @type error: L{domish.Element}
    @param errorNamespace: The namespace of the elements that hold the error
                           condition and text.
    @type errorNamespace: C{str}
    @return: Dictionary with extracted error information. If present, keys
             C{condition}, C{text}, C{textLang} have a string value,
             and C{appCondition} has an L{domish.Element} value.
    @rtype: C{dict}
    Nr2rB)r1r2r3r4)�elementsrS�namerK�getAttributerE)r@�errorNamespacer1r2r3r4�elements       r6�_parseErrorrj�s����I��D��H��L��>�>�#�#���;�;�.�(��|�|�v�%��7�|��"�/�/���0@�A��#�L�L�	�"�L�#����$�	�r7c�Z�t|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   r6�exceptionFromStreamErrorrms>��
���1�E��
�k��E�&�M�5��+<�e�N�>S��I��r7c���g}dx}x}x}x}x}}|j�D]�}|jdk(r�|j|jk(rn|jd�}|jd�}t	|t
�}	|	d}|	d}|	d}|	d}|r�t|s�wt|\}}t|j�}��|j|���|�td�St|||||�}
||
_||
_|
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)
rerfrSrgrjrc�CODES_TO_CONDITIONSrKr@�appendrVrZra)rarZr1r2r3r4r	rrir@rls           r6�exceptionFromStanzarqs���H�?C�C�I�C��C�x�C�,�C����?�?�$�%���<�<�7�"�w�{�{�f�j�j�'@��'�'��/�D��'�'��/�D����9�E��k�*�I���=�D��Z�(�H� ��0�L���"5�d�";��	�4��6�<�<�(���O�O�G�$�%� ���4� � ��I�t�T�8�\�J�I�!�I���I���r7)rJr`�typingr�twisted.words.xishrrErTrcrXror/r,rOrVrjrmrqrMr7r6�<module>rts����
��%�	/��7��7����E�8�4�����1����x�@���%��0�	�
�U�H�-���e�V�<�
��u�h�7���e�X�6���u�h�7���E�8�4���u�f�5�����7���e�V�<�����1���e�V�<�� ��x�@�!�"�e�V�<�#�$%*�6�:�$)�8�<�&+�V�<�$)�4�8�#(�&�9�-��2�	���	�$��
�%��
�'�	�

� ��
�'�
�
�$��
�'��
�,��
�,��
�!��
�,��
�0��
�*��
�,�� 
�,�!�"
�,�#��*9�	�9�x�)��2M�)�M�`"�J�$%r7

Zerion Mini Shell 1.0