当前位置: 首页>>代码示例>>Python>>正文


Python IMAP.delete_mailfolder方法代码示例

本文整理汇总了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))
开发者ID:tpokorra,项目名称:pykolab,代码行数:34,代码来源:cmd_delete_mailbox.py

示例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)

开发者ID:detrout,项目名称:pykolab,代码行数:31,代码来源:cmd_delete_mailbox.py


注:本文中的pykolab.imap.IMAP.delete_mailfolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。