本文整理汇总了Python中pykolab.imap.IMAP.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python IMAP.fetch方法的具体用法?Python IMAP.fetch怎么用?Python IMAP.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykolab.imap.IMAP
的用法示例。
在下文中一共展示了IMAP.fetch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import fetch [as 别名]
def execute(*args, **kw):
"""
List messages in a folder
"""
try:
folder = conf.cli_args.pop(0)
except:
log.error(_("Specify a folder"))
sys.exit(1)
imap = IMAP()
imap.connect()
_folder = imap.lm(imap_utf7.encode(folder))
if _folder == None or _folder == []:
log.error(_("No such folder"))
sys.exit(1)
imap.set_acl(folder, 'cyrus-admin', 'lrs')
imap.select(imap_utf7.encode(folder))
if conf.list_deleted:
typ, data = imap.search(None, 'ALL')
else:
typ, data = imap.search(None, '(ALL UNDELETED)')
num_messages = len(data[0].split())
for num in data[0].split():
typ, flags = imap.fetch(num, 'FLAGS')
flags = flags[0].split()
if len(flags) >= 3:
# Any flags are set
if flags[2] == '(\\Deleted))':
print num, '\Deleted'
elif flags[2] == '(\\Deleted':
print num, '\Deleted'
elif '\\Deleted' in flags[3:]:
print num, '\Deleted'
elif '\\Deleted))' in flags[3:]:
print num, '\Deleted'
else:
print num
else:
print num
imap.set_acl(folder, 'cyrus-admin', '')