def _migrate_email_log(self, event, item): info = item._logInfo entry = self._migrate_log(event, item) entry.realm = EventLogRealm.emails entry.type = 'email' entry.summary = 'Sent email: {}'.format(convert_to_unicode(info['subject']).strip()) content_type = convert_to_unicode(info.get('contentType')) or ( 'text/html' if seems_html(info['body']) else 'text/plain') entry.data = { 'from': convert_to_unicode(info['fromAddr']), 'to': map(convert_to_unicode, set(info['toList'])), 'cc': map(convert_to_unicode, set(info['ccList'])), 'bcc': map(convert_to_unicode, set(info.get('bccList', []))), 'subject': convert_to_unicode(info['subject']), 'body': convert_to_unicode(info['body']), 'content_type': content_type, } return entry
def _migrate_email_log(self, event, item): info = item._logInfo entry = self._migrate_log(event, item) entry.realm = EventLogRealm.emails entry.type = "email" entry.summary = "Sent email: {}".format(convert_to_unicode(info["subject"]).strip()) content_type = convert_to_unicode(info.get("contentType")) or ( "text/html" if seems_html(info["body"]) else "text/plain" ) entry.data = { "from": convert_to_unicode(info["fromAddr"]), "to": map(convert_to_unicode, set(info["toList"])), "cc": map(convert_to_unicode, set(info["ccList"])), "bcc": map(convert_to_unicode, set(info.get("bccList", []))), "subject": convert_to_unicode(info["subject"]), "body": convert_to_unicode(info["body"]), "content_type": content_type, } return entry
def _migrate_email_log(self, event, item): info = item._logInfo entry = self._migrate_log(event, item) entry.realm = EventLogRealm.emails entry.type = 'email' entry.summary = 'Sent email: {}'.format( convert_to_unicode(info['subject']).strip()) content_type = convert_to_unicode(info.get('contentType')) or ( 'text/html' if seems_html(info['body']) else 'text/plain') entry.data = { 'from': convert_to_unicode(info['fromAddr']), 'to': map(convert_to_unicode, set(info['toList'])), 'cc': map(convert_to_unicode, set(info['ccList'])), 'bcc': map(convert_to_unicode, set(info.get('bccList', []))), 'subject': convert_to_unicode(info['subject']), 'body': convert_to_unicode(info['body']), 'content_type': content_type, } return entry
def test_seems_html(): assert seems_html('<b>test') assert seems_html('a <b> c') assert not seems_html('test') assert not seems_html('a < b > c')
def getLogContentType(self): return self._logInfo.get( "contentType", "text/html" if seems_html(self._logInfo['body']) else 'text/plain')
def getLogContentType(self): return self._logInfo.get("contentType", "text/html" if seems_html(self._logInfo['body']) else 'text/plain')
def test_seems_html(): assert seems_html("<b>test") assert seems_html("a <b> c") assert not seems_html("test") assert not seems_html("a < b > c")