本文整理匯總了Python中pykolab.imap.IMAP.search方法的典型用法代碼示例。如果您正苦於以下問題:Python IMAP.search方法的具體用法?Python IMAP.search怎麽用?Python IMAP.search使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pykolab.imap.IMAP
的用法示例。
在下文中一共展示了IMAP.search方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: execute
# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import search [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', '')