def parse_tags(self, element, trigger):
        """
        Parse tags in an XML element
        :param element: The response [message] XML element
        :type  element: etree._Element

        :return: A list of strings and Tag objects in the order they are parsed
        :rtype : list of (str or parser.tags.tag,Tag)
        """
        response = []

        # Add the starting text to the response list
        head = element.text if isinstance(element.text, string_types) else None
        if head:
            if head.strip():
                head = newlines_to_spaces(head)
                self._log.debug('Appending heading text: {text}'.format(text=head))
            response.append(head)

        # Internal method for appending an elements tail to the response list
        def append_tail(e):
            tail = e.tail if isinstance(e.tail, string_types) else None
            if tail:
                if tail.strip():
                    tail = newlines_to_spaces(tail)
                    self._log.debug('Appending trailing text: {text}'.format(text=tail))
                response.append(tail)

        # Parse the contained tags and add their associated string objects to the response list
        for child in element:
            # Parse star tags internally
            if child.tag == 'star':
                star_index = int_attribute(child, 'index', 1)
                star_format = attribute(child, 'format', 'none')
                self._log.debug('Appending Star tag object with index {no}'.format(no=star_index))

                response.append(Star(trigger, star_index, star_format))
                append_tail(child)
                continue

            # Make sure a parser for this tag exists
            if child.tag not in self._tags:
                self._log.warn('No parsers available for Tag "{tag}", skipping'.format(tag=child.tag))
                continue

            # Append the tag object to the response string
            tag = self._tags[child.tag]
            self._log.debug('Appending {tag} Tag object'.format(tag=child.tag.capitalize()))
            response.append(tag(trigger, child))

            # Append the trailing text to the response string (if there is any)
            append_tail(child)

        return response
def parse_tags ( self , element , trigger ) : response = [ ] head = element . text if isinstance ( element . text , string_types ) else None if head : if head . strip ( ) : head = newlines_to_spaces ( head ) self . _log . debug ( 'Appending heading text: {text}' . format ( text = head ) ) response . append ( head ) def append_tail ( e ) : tail = e . tail if isinstance ( e . tail , string_types ) else None if tail : if tail . strip ( ) : tail = newlines_to_spaces ( tail ) self . _log . debug ( 'Appending trailing text: {text}' . format ( text = tail ) ) response . append ( tail ) for child in element : if child . tag == 'star' : star_index = int_attribute ( child , 'index' , 1 ) star_format = attribute ( child , 'format' , 'none' ) self . _log . debug ( 'Appending Star tag object with index {no}' . format ( no = star_index ) ) response . append ( Star ( trigger , star_index , star_format ) ) append_tail ( child ) continue if child . tag not in self . _tags : self . _log . warn ( 'No parsers available for Tag "{tag}", skipping' . format ( tag = child . tag ) ) continue tag = self . _tags [ child . tag ] self . _log . debug ( 'Appending {tag} Tag object' . format ( tag = child . tag . capitalize ( ) ) ) response . append ( tag ( trigger , child ) ) append_tail ( child ) return response
Parse tags in an XML element
        :param element: The response [message] XML element
        :type  element: etree._Element

        :return: A list of strings and Tag objects in the order they are parsed
        :rtype : list of (str or parser.tags.tag,Tag)