# Path: pyxmpp2/etree.py
# class ElementClass:
#     def __subclasshook__(cls, other):
# def element_to_unicode(element):
# 
# Path: pyxmpp2/constants.py
# STANZA_ERROR_NS = 'urn:ietf:params:xml:ns:xmpp-stanzas'
# 
# STREAM_ERROR_NS = 'urn:ietf:params:xml:ns:xmpp-streams'
# 
# Path: pyxmpp2/constants.py
# STREAM_QNP = "{{{0}}}".format(STREAM_NS)
# 
# STANZA_ERROR_QNP = "{{{0}}}".format(STANZA_ERROR_NS)
# 
# STREAM_ERROR_QNP = "{{{0}}}".format(STREAM_ERROR_NS)
# 
# Path: pyxmpp2/constants.py
# STANZA_CLIENT_QNP = "{{{0}}}".format(STANZA_CLIENT_NS)
# 
# STANZA_SERVER_QNP = "{{{0}}}".format(STANZA_SERVER_NS)
# 
# STANZA_NAMESPACES = (STANZA_CLIENT_NS, STANZA_SERVER_NS)
# 
# Path: pyxmpp2/constants.py
# XML_LANG_QNAME = XML_QNP + "lang"
# 
# Path: pyxmpp2/xmppserializer.py
# def serialize(element):
#     """Serialize an XMPP element.
# 
#     Utility function for debugging or logging.
# 
#         :Parameters:
#             - `element`: the element to serialize
#         :Types:
#             - `element`: :etree:`ElementTree.Element`
# 
#         :Return: serialized element
#         :Returntype: `unicode`
#     """
#     if getattr(_THREAD, "serializer", None) is None:
#         _THREAD.serializer = XMPPSerializer("jabber:client")
#         _THREAD.serializer.emit_head(None, None)
#     return _THREAD.serializer.emit_stanza(element)


import logging
from .etree import ElementTree, ElementClass
from copy import deepcopy
from .constants import STANZA_ERROR_NS, STREAM_ERROR_NS
from .constants import STREAM_QNP, STANZA_ERROR_QNP, STREAM_ERROR_QNP
from .constants import STANZA_CLIENT_QNP, STANZA_SERVER_QNP, STANZA_NAMESPACES
from .constants import XML_LANG_QNAME
from .xmppserializer import serialize
            - `text`: `unicode`
            - `language`: `unicode`
        """
        if isinstance(element_or_cond, unicode):
            if element_or_cond not in STREAM_ERRORS:
                raise ValueError("Bad error condition")
        ErrorElement.__init__(self, element_or_cond, text, language)

    def get_message(self):
        """Get the standard English message for the error.

        :return: the error message.
        :returntype: `unicode`"""
        cond = self.condition_name
        if cond in STREAM_ERRORS:
            return STREAM_ERRORS[cond][0]
        else:
            return None

class StanzaErrorElement(ErrorElement):
    """Stanza error element.

    :Ivariables:
        - `error_type`: 'type' of the error, one of: 'auth', 'cancel',
          'continue', 'modify', 'wait'
    :Types:
        - `error_type`: `unicode`
    """
    error_qname = STANZA_CLIENT_QNP + "error"
    text_qname = STANZA_CLIENT_QNP + "text"

# Path: pyxmpp2/etree.py
# class ElementClass:
#     def __subclasshook__(cls, other):
# def element_to_unicode(element):
# 
# Path: pyxmpp2/constants.py
# STANZA_ERROR_NS = 'urn:ietf:params:xml:ns:xmpp-stanzas'
# 
# STREAM_ERROR_NS = 'urn:ietf:params:xml:ns:xmpp-streams'
# 
# Path: pyxmpp2/constants.py
# STREAM_QNP = "{{{0}}}".format(STREAM_NS)
# 
# STANZA_ERROR_QNP = "{{{0}}}".format(STANZA_ERROR_NS)
# 
# STREAM_ERROR_QNP = "{{{0}}}".format(STREAM_ERROR_NS)
# 
# Path: pyxmpp2/constants.py
# STANZA_CLIENT_QNP = "{{{0}}}".format(STANZA_CLIENT_NS)
# 
# STANZA_SERVER_QNP = "{{{0}}}".format(STANZA_SERVER_NS)
# 
# STANZA_NAMESPACES = (STANZA_CLIENT_NS, STANZA_SERVER_NS)
# 
# Path: pyxmpp2/constants.py
# XML_LANG_QNAME = XML_QNP + "lang"
# 
# Path: pyxmpp2/xmppserializer.py
# def serialize(element):
#     """Serialize an XMPP element.
# 
#     Utility function for debugging or logging.
# 
#         :Parameters:
#             - `element`: the element to serialize
#         :Types:
#             - `element`: :etree:`ElementTree.Element`
# 
#         :Return: serialized element
#         :Returntype: `unicode`
#     """
#     if getattr(_THREAD, "serializer", None) is None:
#         _THREAD.serializer = XMPPSerializer("jabber:client")
#         _THREAD.serializer.emit_head(None, None)
#     return _THREAD.serializer.emit_stanza(element)


# Path: pyxmpp2/error.py
import logging
from .etree import ElementTree, ElementClass
from copy import deepcopy
from .constants import STANZA_ERROR_NS, STREAM_ERROR_NS
from .constants import STREAM_QNP, STANZA_ERROR_QNP, STREAM_ERROR_QNP
from .constants import STANZA_CLIENT_QNP, STANZA_SERVER_QNP, STANZA_NAMESPACES
from .constants import XML_LANG_QNAME
from .xmppserializer import serialize

            - `text`: `unicode`
            - `language`: `unicode`
        """
        if isinstance(element_or_cond, unicode):
            if element_or_cond not in STREAM_ERRORS:
                raise ValueError("Bad error condition")
        ErrorElement.__init__(self, element_or_cond, text, language)

    def get_message(self):
        """Get the standard English message for the error.

        :return: the error message.
        :returntype: `unicode`"""
        cond = self.condition_name
        if cond in STREAM_ERRORS:
            return STREAM_ERRORS[cond][0]
        else:
            return None

class StanzaErrorElement(ErrorElement):
    """Stanza error element.

    :Ivariables:
        - `error_type`: 'type' of the error, one of: 'auth', 'cancel',
          'continue', 'modify', 'wait'
    :Types:
        - `error_type`: `unicode`
    """
    error_qname = STANZA_CLIENT_QNP + "error"
    text_qname = STANZA_CLIENT_QNP + "text"

    cond_qname_prefix = STANZA_ERROR_QNP