本文整理汇总了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))