當前位置: 首頁>>代碼示例>>Python>>正文


Python IMAP.has_folder方法代碼示例

本文整理匯總了Python中pykolab.imap.IMAP.has_folder方法的典型用法代碼示例。如果您正苦於以下問題:Python IMAP.has_folder方法的具體用法?Python IMAP.has_folder怎麽用?Python IMAP.has_folder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pykolab.imap.IMAP的用法示例。


在下文中一共展示了IMAP.has_folder方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: IMAP

# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import has_folder [as 別名]
    else:
        domain = conf.get('kolab', 'primary_domain')

    imap = IMAP()
    imap.connect(domain=domain, login=False)

    backend = conf.get(domain, 'imap_backend')
    if backend == None:
        backend = conf.get('kolab', 'imap_backend')

    admin_login = conf.get(backend, 'admin_login')
    admin_password = conf.get(backend, 'admin_password')

    imap.login_plain(admin_login, admin_password, user)

    if not imap.has_folder(folder_pattern):
        print >> sys.stderr, \
                _("Cannot subscribe user to folder %r:") % (folder_pattern), \
                _("No such folder")
        sys.exit(1)

    _folders = imap.lm(folder_pattern)
    _subscribed_folders = imap.lsub()
    unsubscribed_folders = []

    for _folder in _folders:
        if _folder in _subscribed_folders:
            imap.unsubscribe(_folder)
            unsubscribed_folders.append(_folder)

    if len(unsubscribed_folders) > 0:
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:33,代碼來源:cmd_remove_user_subscription.py

示例2: description

# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import has_folder [as 別名]
def description():
    return """Obtain a list of ACL entries on a folder."""

def execute(*args, **kw):
    try:
        folder = conf.cli_args.pop(0)
    except IndexError, errmsg:
        folder = utils.ask_question(_("Folder name"))

    if len(folder.split('@')) > 1:
        domain = folder.split('@')[1]
    else:
        domain = conf.get('kolab', 'primary_domain')

    imap = IMAP()
    imap.connect(domain=domain)

    if not imap.has_folder(folder):
        print >> sys.stderr, _("No such folder %r") % (folder)

    else:
        acls = []
        folders = imap.list_folders(folder)
        for folder in folders:
            print "Folder", folder
            acls = imap.list_acls(folder)

            for acl in acls.keys():
                print "  %-13s %s" %(acls[acl], acl)

開發者ID:tpokorra,項目名稱:pykolab,代碼行數:31,代碼來源:cmd_list_mailbox_acls.py

示例3: _

# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import has_folder [as 別名]
        try:
            target_folder = conf.cli_args.pop(0)
            try:
                partition = conf.cli_args.pop(0)
            except IndexError, errmsg:
                partition = None
        except IndexError, errmsg:
            print >> sys.stderr, _("No target mailbox name specified")
    except IndexError, errmsg:
        print >> sys.stderr, _("No source mailbox name specified")
        sys.exit(1)

    if len(source_folder.split('@')) > 1:
        domain = source_folder.split('@')[1]
    else:
        domain = conf.get('kolab', 'primary_domain')

    imap = IMAP()
    imap.connect(domain=domain)

    if not imap.has_folder(source_folder):
        print >> sys.stderr, _("Source folder %r does not exist") % (source_folder)
        sys.exit(1)

    if imap.has_folder(target_folder) and partition == None:
        print >> sys.stderr, _("Target folder %r already exists") % (target_folder)
        sys.exit(1)

    imap.imap.rename(source_folder, target_folder, partition)

開發者ID:tpokorra,項目名稱:pykolab,代碼行數:31,代碼來源:cmd_rename_mailbox.py


注:本文中的pykolab.imap.IMAP.has_folder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。