示例#1
0
    def _create_hello_tree_msg(self, msg, name, reply):
        if isinstance(msg, bytes):
            msg = msg.decode('utf-8', 'strict')

        message = SubElement(reply, "Message")
        # check if object is iterable and not a string
        try:
            iter(msg)
        except TypeError:
            msg = str(msg)

        if isinstance(msg, str):
            message.text = msg
            message.tail = ""
        else:

            # after parsing the message, change the cluster tag to "message".
            self.parse(msg, name, message)
            message = reply[1]
            message.tag = "Message"
            message.text = ""
            message.tail = ""
            cluster = message[0]
            cluster.tail = ""