当前位置: 首页>>代码示例>>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;未经允许,请勿转载。