本文整理汇总了Python中email_reply_parser.EmailReplyParser.read方法的典型用法代码示例。如果您正苦于以下问题:Python EmailReplyParser.read方法的具体用法?Python EmailReplyParser.read怎么用?Python EmailReplyParser.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类email_reply_parser.EmailReplyParser
的用法示例。
在下文中一共展示了EmailReplyParser.read方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from email_reply_parser import EmailReplyParser [as 别名]
# 或者: from email_reply_parser.EmailReplyParser import read [as 别名]
def __init__(self, message):
if (not isinstance(message, dict) or 'TextBody' not in message):
log.exception('ActivityEmailParser didn\'t get a valid message.')
raise ActivityEmailEncodingError(
'Invalid or malformed json message object.')
self.email = message
reply = self._extra_email_reply_parse(self.email['TextBody'])
self.reply = EmailReplyParser.read(reply).reply
示例2: __init__
# 需要导入模块: from email_reply_parser import EmailReplyParser [as 别名]
# 或者: from email_reply_parser.EmailReplyParser import read [as 别名]
def __init__(self, email_text):
"""Decode base64 email and turn it into a Django email object."""
try:
email_text = base64.standard_b64decode(urllib2.unquote(email_text.rstrip()))
except TypeError:
# Corrupt or invalid base 64.
self.decode_error = True
return
self.email = message_from_string(email_text)
self.reply_text = EmailReplyParser.read(self.email.get_payload()).reply
示例3: extract_alert
# 需要导入模块: from email_reply_parser import EmailReplyParser [as 别名]
# 或者: from email_reply_parser.EmailReplyParser import read [as 别名]
def extract_alert(msg):
"""Extract the original alert from an email thread.
Walk through all replies comprising the message, locate the
original alert email, strip off all pseudo-headers, remove quote
markers, and return the result.
"""
for part in msg.walk():
if part.get_content_type() == 'text/plain':
content = EmailReplyParser.read(
part.get_payload(decode=True))
for fragment in content.fragments:
content = fragment._content
if content != extract_reply(msg):
return sanitize_email_fragment(content)
return ''
示例4: __init__
# 需要导入模块: from email_reply_parser import EmailReplyParser [as 别名]
# 或者: from email_reply_parser.EmailReplyParser import read [as 别名]
def __init__(self, email_text):
"""Decode base64 email and turn it into a Django email object."""
try:
email_text = base64.standard_b64decode(
urllib2.unquote(email_text.rstrip()))
except TypeError:
# Corrupt or invalid base 64.
self.decode_error = True
return
self.email = message_from_string(email_text)
payload = self.email.get_payload() # If not multipart, it's a string.
if isinstance(payload, list):
# If multipart, get the plaintext part.
for part in payload:
if part.get_content_type() == 'text/plain':
payload = part.get_payload()
break
self.reply_text = EmailReplyParser.read(payload).reply
示例5: __init__
# 需要导入模块: from email_reply_parser import EmailReplyParser [as 别名]
# 或者: from email_reply_parser.EmailReplyParser import read [as 别名]
def __init__(self, email_text):
"""Decode base64 email and turn it into a Django email object."""
try:
log.info('CommEmailParser received email: ' + email_text)
email_text = base64.standard_b64decode(
urllib2.unquote(email_text.rstrip()))
except TypeError:
# Corrupt or invalid base 64.
self.decode_error = True
log.info('Decoding error for CommEmailParser')
return
self.email = message_from_string(email_text)
payload = self.email.get_payload()
if isinstance(payload, list):
# If multipart, get the plain text part.
for part in payload:
# Nested multipart. Go deeper.
if part.get_content_type() == 'multipart/alternative':
payload = part.get_payload()
for part in payload:
if part.get_content_type() == 'text/plain':
# Found the plain text part.
payload = part.get_payload()
break
if part.get_content_type() == 'text/plain':
# Found the plain text part.
payload = part.get_payload()
break
# Decode quoted-printable data and remove non-breaking spaces.
payload = (quopri.decodestring(payload)
.replace('\xc2\xa0', ' '))
payload = self.extra_email_reply_parse(payload)
self.reply_text = EmailReplyParser.read(payload).reply
示例6: __init__
# 需要导入模块: from email_reply_parser import EmailReplyParser [as 别名]
# 或者: from email_reply_parser.EmailReplyParser import read [as 别名]
def __init__(self, email_text):
self.email = message_from_string(email_text)
self.reply_text = EmailReplyParser.read(self.email.get_payload()).reply
示例7: get_email
# 需要导入模块: from email_reply_parser import EmailReplyParser [as 别名]
# 或者: from email_reply_parser.EmailReplyParser import read [as 别名]
def get_email(self, name):
""" Return EmailMessage instance
"""
with open('test/emails/%s.txt' % name) as f:
text = f.read()
return EmailReplyParser.read(text)
示例8: clean_email_body
# 需要导入模块: from email_reply_parser import EmailReplyParser [as 别名]
# 或者: from email_reply_parser.EmailReplyParser import read [as 别名]
def clean_email_body(raw_body):
"""
Cleans an email's plain text body by stripping out any signatures.
"""
s = EmailReplyParser.read(raw_body)
return r'\n'.join([f.content for f in s.fragments if not f.signature])
示例9: get_email
# 需要导入模块: from email_reply_parser import EmailReplyParser [as 别名]
# 或者: from email_reply_parser.EmailReplyParser import read [as 别名]
def get_email(self, name):
""" Return EmailMessage instance
"""
with open(os.path.join(TEST_EMAILS_DIR, '%s.txt' % name)) as f:
text = f.read()
return EmailReplyParser.read(text)