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


Python IMAP.get_metadata方法代碼示例

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


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

示例1: execute

# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import get_metadata [as 別名]
def execute(*args, **kw):
    """
        List mailboxes
    """

    imap = IMAP()

    if not conf.connect_server == None:
        imap.connect(server=conf.connect_server)
    else:
        imap.connect()

    print imap.get_metadata("")
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:15,代碼來源:cmd_server_info.py

示例2: test_005_user_folders_metadata_set

# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import get_metadata [as 別名]
    def test_005_user_folders_metadata_set(self):
        imap = IMAP()
        imap.connect()

        ac_folders = conf.get_raw('kolab', 'autocreate_folders')
        exec("ac_folders = %s" % (ac_folders))

        folders = []
        folders.extend(imap.lm('user/%(local)[email protected]%(domain)s' % (self.user)))
        folders.extend(imap.lm('user/%(local)s/*@%(domain)s' % (self.user)))

        for folder in folders:
            metadata = imap.get_metadata(folder)
            print metadata

            folder_name = '/'.join(folder.split('/')[2:]).split('@')[0]
            if ac_folders.has_key(folder_name):
                if ac_folders[folder_name].has_key('annotations'):
                    for _annotation in ac_folders[folder_name]['annotations'].keys():
                        if _annotation.startswith('/private'):
                            continue

                        _annotation_value = ac_folders[folder_name]['annotations'][_annotation]
                        self.assertTrue(metadata[metadata.keys().pop()].has_key(_annotation))
                        self.assertEqual(_annotation_value, metadata[metadata.keys().pop()][_annotation])
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:27,代碼來源:test_001_user_sync.py

示例3: IMAPDataHandler

# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import get_metadata [as 別名]
class IMAPDataHandler(object):
    """
        Collector handler to provide metadata from IMAP
    """

    def __init__(self, *args, **kw):
        # load pykolab conf
        conf = pykolab.getConf()
        if not hasattr(conf, 'defaults'):
            conf.finalize_conf(fatal=False)

        self.imap = IMAP()

    def register(self, callback):
        interests = {
                'GETMETADATA': {
                        'callback': self.get_imap_folder_metadata
                    },
                'GETACL': {
                        'callback': self.get_imap_folder_acl
                    }
            }

        callback(interests)

    def get_imap_folder_metadata(self, notification):
        notification = json.loads(notification)
        log.debug("GETMETADATA for %r" % (notification), level=9)

        # split the uri parameter into useful parts
        uri = parse_imap_uri(notification['uri'])
        folder_path = imap_folder_path(uri)

        # get metadata using pykolab's imap module
        metadata = {}
        try:
            self.imap.connect()
            metadata = self.imap.get_metadata(folder_path)[folder_path]
            self.imap.disconnect()
        except Exception, e:
            log.warning("Failed to get metadata for %r: %r", folder_path, e)

        notification['metadata'] = metadata

        return json.dumps(notification)
開發者ID:kolab-groupware,項目名稱:bonnie,代碼行數:47,代碼來源:imapdata.py

示例4: _

# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import get_metadata [as 別名]
        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, conf.user)
    else:
        imap.connect(domain=domain)

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

    else:
        metadata = []
        folders = imap.list_folders(folder)
        for folder in folders:
            print "Folder", folder.encode('utf-8')

            metadata = imap.get_metadata(folder)

            if metadata.has_key(folder):
                for annotation in metadata[folder].keys():
                    print "  %-49s %s" % (
                            annotation,
                            metadata[folder][annotation]
                        )
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:32,代碼來源:cmd_list_mailbox_metadata.py


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