本文整理匯總了Python中pykolab.imap.IMAP.delete_mailfolder方法的典型用法代碼示例。如果您正苦於以下問題:Python IMAP.delete_mailfolder方法的具體用法?Python IMAP.delete_mailfolder怎麽用?Python IMAP.delete_mailfolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pykolab.imap.IMAP
的用法示例。
在下文中一共展示了IMAP.delete_mailfolder方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: execute
# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import delete_mailfolder [as 別名]
def execute(*args, **kw):
"""
Delete mailbox
"""
if len(conf.cli_args) < 1:
print >> sys.stderr, _("No mailbox specified")
sys.exit(1)
imap = IMAP()
imap.connect()
delete_folders = []
while len(conf.cli_args) > 0:
folder = conf.cli_args.pop(0)
folders = imap.list_folders(folder)
if len(folders) < 1:
print >> sys.stderr, _("No such folder(s): %s") % (folder)
delete_folders.extend(folders)
if len(delete_folders) == 0:
print >> sys.stderr, _("No folders to delete.")
sys.exit(1)
for delete_folder in delete_folders:
try:
imap.delete_mailfolder(delete_folder)
except Exception, errmsg:
log.error(_("Could not delete mailbox '%s'") % (delete_folder))
示例2: __init__
# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import delete_mailfolder [as 別名]
from pykolab.imap import IMAP
from pykolab.translate import _
log = pykolab.getLogger('pykolab.cli')
conf = pykolab.getConf()
def __init__():
commands.register('delete_mailbox', execute, description=description(), aliases=['dm'])
def description():
return """Delete a mailbox or sub-folder. Note that the mailbox or folder is removed recursively."""
def execute(*args, **kw):
"""
Delete mailbox
"""
try:
delete_folder = conf.cli_args.pop(0)
except IndexError, e:
print >> sys.stderr, _("No mailbox specified")
sys.exit(1)
imap = IMAP()
imap.connect()
delete_folders = imap.lm(delete_folder)
for delete_folder in delete_folders:
imap.delete_mailfolder(delete_folder)