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