# Path: pyxmpp2/etree.py
# class ElementClass:
#     def __subclasshook__(cls, other):
# def element_to_unicode(element):
# 
# Path: pyxmpp2/exceptions.py
# class StreamParseError(FatalStreamError):
#     """Raised when invalid XML is received in an XMPP stream."""
#     pass


import threading
import logging
from .etree import ElementTree
from .exceptions import StreamParseError
        element = self._builder.end(tag)
        if self._level == 1:
            self._handler.stream_element(element)

class StreamReader(object):
    """XML stream reader.

    :Ivariables:
        - `handler`: object to receive parsed stream elements
        - `parser`: the xml parser
        - `lock`: lock to protect the object
        - `in_use`: re-entrancy protection
        - `_started`: flag set after the first byte is pushed to the parser
    :Types:
        - `handler`: `XMLStreamHandler`
        - `parser`: :etree:`ElementTree.XMLParser`
        - `lock`: :std:`threading.RLock`
        - `in_use`: `bool`
        - `_started`: `bool`
    """
    # pylint: disable-msg=R0903
    def __init__(self, handler):
        """Initialize the reader.

        :Parameters:
            - `handler`: Object to handle stream start, end and stanzas.
        :Types:
            - `handler`: `XMLStreamHandler`
        """
        self.handler = handler

# Path: pyxmpp2/etree.py
# class ElementClass:
#     def __subclasshook__(cls, other):
# def element_to_unicode(element):
# 
# Path: pyxmpp2/exceptions.py
# class StreamParseError(FatalStreamError):
#     """Raised when invalid XML is received in an XMPP stream."""
#     pass


# Path: pyxmpp2/xmppparser.py
import threading
import logging
from .etree import ElementTree
from .exceptions import StreamParseError

        element = self._builder.end(tag)
        if self._level == 1:
            self._handler.stream_element(element)

class StreamReader(object):
    """XML stream reader.

    :Ivariables:
        - `handler`: object to receive parsed stream elements
        - `parser`: the xml parser
        - `lock`: lock to protect the object
        - `in_use`: re-entrancy protection
        - `_started`: flag set after the first byte is pushed to the parser
    :Types:
        - `handler`: `XMLStreamHandler`
        - `parser`: :etree:`ElementTree.XMLParser`
        - `lock`: :std:`threading.RLock`
        - `in_use`: `bool`
        - `_started`: `bool`
    """
    # pylint: disable-msg=R0903
    def __init__(self, handler):
        """Initialize the reader.

        :Parameters:
            - `handler`: Object to handle stream start, end and stanzas.
        :Types:
            - `handler`: `XMLStreamHandler`
        """
        self.handler = handler

        self.parser = ElementTree.XMLParser(target = ParserTarget(handler))