def build_message(self, text): """Builds an xhtml message without attributes. If input is not valid xhtml-im fallback to normal.""" try: node = XML2Node(text) # logging.debug('This message is XML : %s' % text) text_plain = xhtml2txt(text) logging.debug('Plain Text translation from XHTML-IM:\n%s' % text_plain) message = Message(body=text_plain) message.addChild(node = node) except ExpatError as ee: if text.strip(): # avoids keep alive pollution logging.debug('Determined that [%s] is not XHTML-IM (%s)' % (text, ee)) message = Message(body=text) return message
def build_message(self, text): """Builds an xhtml message without attributes. If input is not valid xhtml-im fallback to normal.""" try: node = XML2Node(text) # logging.debug('This message is XML : %s' % text) text_plain = xhtml2txt(text) logging.debug('Plain Text translation from XHTML-IM:\n%s' % text_plain) message = Message(body=text_plain) message.addChild(node=node) except ExpatError as ee: if text.strip(): # avoids keep alive pollution logging.debug('Determined that [%s] is not XHTML-IM (%s)' % (text, ee)) message = Message(body=text) return message
def build_message(self, text): """Builds an xhtml message without attributes. If input is not valid xhtml-im fallback to normal.""" try: text = utf8(text) XML2Node(text) # test if is it xml # yes, ok epurate it for hipchat try: hipchat_html = xhtml2hipchat(text) node = XML2Node(hipchat_html) message = Message(body=xhtml2txt(text)) message.addChild(node = node) except ExpatError as ee: logging.error('Error translating to hipchat [%s] Parsing error = [%s]' % (hipchat_html, ee)) except ExpatError as ee: if text.strip(): # avoids keep alive pollution logging.debug('Determined that [%s] is not XHTML-IM (%s)' % (text, ee)) message = Message(body=text) return message
def build_message(self, text): """Builds an xhtml message without attributes. If input is not valid xhtml-im fallback to normal.""" message = None # keeps the compiler happy try: text = utf8(text) XML2Node(text) # test if is it xml # yes, ok epurate it for hipchat hipchat_html = xhtml2hipchat(text) try: node = XML2Node(hipchat_html) message = Message(body=xhtml2txt(text)) message.addChild(node = node) except ExpatError as ee: logging.error('Error translating to hipchat [%s] Parsing error = [%s]' % (hipchat_html, ee)) except ExpatError as ee: if text.strip(): # avoids keep alive pollution logging.debug('Determined that [%s] is not XHTML-IM (%s)' % (text, ee)) message = Message(body=text) return message