当前位置: 首页>>代码示例>>Python>>正文


Python EmailReplyParser.read方法代码示例

本文整理汇总了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
开发者ID:tsl143,项目名称:addons-server,代码行数:11,代码来源:utils.py

示例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
开发者ID:KKcorps,项目名称:zamboni,代码行数:13,代码来源:utils.py

示例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 ''
开发者ID:lil-cain,项目名称:koboli,代码行数:20,代码来源:koboli.py

示例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
开发者ID:patilkr,项目名称:zamboni,代码行数:23,代码来源:utils.py

示例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
开发者ID:rachelhathaway,项目名称:zamboni,代码行数:39,代码来源:utils_mail.py

示例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
开发者ID:abev66,项目名称:zamboni,代码行数:5,代码来源:utils.py

示例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)
开发者ID:DisruptiveLabs,项目名称:email-reply-parser,代码行数:8,代码来源:test_email_reply_parser.py

示例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])
开发者ID:sjkingo,项目名称:ticketus,代码行数:8,代码来源:utils.py

示例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)
开发者ID:ierror,项目名称:email-reply-parser,代码行数:8,代码来源:test_email_reply_parser.py


注:本文中的email_reply_parser.EmailReplyParser.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。