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


Python Mail.verbose方法代码示例

本文整理汇总了Python中mail.Mail.verbose方法的典型用法代码示例。如果您正苦于以下问题:Python Mail.verbose方法的具体用法?Python Mail.verbose怎么用?Python Mail.verbose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mail.Mail的用法示例。


在下文中一共展示了Mail.verbose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import verbose [as 别名]
class Detach:

    MESSAGE_PARTS = '(RFC822.SIZE BODY[HEADER.FIELDS (FROM DATE SUBJECT)] BODY)'    

    def fetch(self, mesg_nums):
        typ, data = self.mail.send_cmd('FETCH', mesg_nums, self.MESSAGE_PARTS)
        result = [ self.parse(data[i:i+2]) for i in range(0, len(data), 2) ]
        self.mail.verbose(pprint.pformat(result))
        return result

    def connect(self, args):
        if not args.host:
            try:
                from imap_config import HOSTNAME
                args.host = HOSTNAME
            except ImportError:
                args.host = None
        self.mail = Mail(args)
    
    def login(self, username):
        password = None
        if not username:         
            try:
                from imap_config import USERNAME, PASSWORD
                username, password = (USERNAME, PASSWORD)
            except ImportError:
                pass
        self.mail.login(username, password)

    def logout(self):
        self.mail.logout()

    def parse(self, data):
        mesg = parse_fetch.parse_fields(data[0][1])
        mesg['num'] = parse_fetch.parse_message_id(data[0][0])
        mesg['size'] = parse_fetch.parse_rfc822_size(data[0][0])
        mesg['num_attachments'] = len(parse_fetch.get_attachment_names(data[1]))
        return mesg

    def search(self, search_criterion):
        typ, data = self.mail.send_cmd('SEARCH', None, search_criterion)
        mesg_nums = data[0].replace(' ', ',')
        mesg = 'SEARCH returned {0} message(s).\n'
        mesg_count = (arg_nums.count(',') + 1) if mesg_nums else 0
        self.mail.verbose(mesg.format(mesg_count))
        return arg.nums

    def select(self, mailbox='INBOX'):
        typ, data = self.mail.send_cmd('SELECT', mailbox)
        mesg = 'Found {0} message(s) in {1!r}.\n'
        self.mail.verbose(mesg.format(data[0], mailbox))
开发者ID:abondis,项目名称:IMAP-Tools,代码行数:53,代码来源:detach.py


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