# Path: pyxmpp2/etree.py
# class ElementClass:
#     """Abstract class used to reference the :etree:`ElementTree.Element`
#     object type of the selected Element Tree implementation.
#     """
#     # pylint: disable=W0232,R0903
#     __metaclass__ = ABCMeta
#     element_type = None
#     @classmethod
#     def __subclasshook__(cls, other):
#         if cls.element_type is None:
#             cls.element_type = type(ElementTree.Element("x"))
#         if cls is ElementClass:
#             return other is cls.element_type or hasattr(other, "tag")
#         return NotImplemented
# 
# Path: pyxmpp2/interfaces.py
# class StanzaPayload:
#     """Abstract base class for stanza payload objects.
# 
#     Subclasses are used to encapsulate stanza payload data
#     and to reference payload type in stanza handlers or when
#     requesting particular payload from a stanza.
#     """
#     # pylint: disable=W0232
#     __metaclass__ = ABCMeta
# 
#     @abstractclassmethod
#     def from_xml(cls, element):
#         """Create a `cls` instance from an XML element.
# 
#         :Parameters:
#             - `element`: the XML element
#         :Types:
#             - `element`: :etree:`ElementTree.Element`
#         """
#         # pylint: disable=E0213
#         raise NotImplementedError
# 
#     @abstractmethod
#     def as_xml(self):
#         """Return the XML representation of the payload.
# 
#         :returntype: :etree:`ElementTree.Element`
#         """
#         raise NotImplementedError
# 
#     def copy(self):
#         """Return a deep copy of self."""
#         return deepcopy(self)
# 
#     @property
#     def handler_key(self):
#         """Defines a key which may be used when registering handlers
#         for stanzas with this payload."""
#         # pylint: disable-msg=R0201
#         return None


import logging
from collections import defaultdict
from .etree import ElementClass
from .interfaces import StanzaPayload
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

"""XMPP payload classes."""



STANZA_PAYLOAD_CLASSES = {}
STANZA_PAYLOAD_ELEMENTS = defaultdict(list)

logger = logging.getLogger("pyxmpp2.stanzapayload")

class XMLPayload(StanzaPayload):
    """Transparent XML payload for stanza.

    This object can be used for any stanza payload.
    It doesn't decode the XML element, but instead keeps it in the ElementTree
    format.

    :Ivariables:
        - `xml_element_name`: qualified name of the wrapped element
        - `element`: the wrapped element
    :Types:
        - `xml_element_name`: `unicode`
        - `element`: :etree:`ElementTree.Element`
    """
    def __init__(self, data):

# Path: pyxmpp2/etree.py
# class ElementClass:
#     """Abstract class used to reference the :etree:`ElementTree.Element`
#     object type of the selected Element Tree implementation.
#     """
#     # pylint: disable=W0232,R0903
#     __metaclass__ = ABCMeta
#     element_type = None
#     @classmethod
#     def __subclasshook__(cls, other):
#         if cls.element_type is None:
#             cls.element_type = type(ElementTree.Element("x"))
#         if cls is ElementClass:
#             return other is cls.element_type or hasattr(other, "tag")
#         return NotImplemented
# 
# Path: pyxmpp2/interfaces.py
# class StanzaPayload:
#     """Abstract base class for stanza payload objects.
# 
#     Subclasses are used to encapsulate stanza payload data
#     and to reference payload type in stanza handlers or when
#     requesting particular payload from a stanza.
#     """
#     # pylint: disable=W0232
#     __metaclass__ = ABCMeta
# 
#     @abstractclassmethod
#     def from_xml(cls, element):
#         """Create a `cls` instance from an XML element.
# 
#         :Parameters:
#             - `element`: the XML element
#         :Types:
#             - `element`: :etree:`ElementTree.Element`
#         """
#         # pylint: disable=E0213
#         raise NotImplementedError
# 
#     @abstractmethod
#     def as_xml(self):
#         """Return the XML representation of the payload.
# 
#         :returntype: :etree:`ElementTree.Element`
#         """
#         raise NotImplementedError
# 
#     def copy(self):
#         """Return a deep copy of self."""
#         return deepcopy(self)
# 
#     @property
#     def handler_key(self):
#         """Defines a key which may be used when registering handlers
#         for stanzas with this payload."""
#         # pylint: disable-msg=R0201
#         return None


# Path: pyxmpp2/stanzapayload.py
import logging
from collections import defaultdict
from .etree import ElementClass
from .interfaces import StanzaPayload

#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

"""XMPP payload classes."""



STANZA_PAYLOAD_CLASSES = {}
STANZA_PAYLOAD_ELEMENTS = defaultdict(list)

logger = logging.getLogger("pyxmpp2.stanzapayload")

class XMLPayload(StanzaPayload):
    """Transparent XML payload for stanza.

    This object can be used for any stanza payload.
    It doesn't decode the XML element, but instead keeps it in the ElementTree
    format.

    :Ivariables:
        - `xml_element_name`: qualified name of the wrapped element
        - `element`: the wrapped element
    :Types:
        - `xml_element_name`: `unicode`
        - `element`: :etree:`ElementTree.Element`
    """
    def __init__(self, data):

        if isinstance(data, StanzaPayload):