本文整理汇总了Python中pykolab.imap.IMAP.set_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python IMAP.set_metadata方法的具体用法?Python IMAP.set_metadata怎么用?Python IMAP.set_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykolab.imap.IMAP
的用法示例。
在下文中一共展示了IMAP.set_metadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: description
# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_metadata [as 别名]
)
def description():
return """Create a mailbox or sub-folder of an existing mailbox."""
def execute(*args, **kw):
try:
mailbox = conf.cli_args.pop(0)
except IndexError, errmsg:
log.error(_("Invalid argument"))
sys.exit(1)
if not conf.metadata == None:
if len(conf.metadata.split('=')) == 2:
annotation = conf.metadata.split('=')[0]
annotation_value = conf.metadata.split('=')[1]
else:
log.error(_("Invalid argument for metadata"))
sys.exit(1)
imap = IMAP()
imap.connect()
admin_login = conf.get('cyrus-imap', 'admin_login')
imap.cm(mailbox)
if not conf.metadata == None:
imap.set_metadata(mailbox, conf.metadata.split('=')[0], conf.metadata.split('=')[1])
示例2: len
# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_metadata [as 别名]
if len(folder.split('@')) > 1:
domain = folder.split('@')[1]
elif not conf.user == None and len(conf.user.split('@')) > 1:
domain = conf.user.split('@')[1]
else:
domain = conf.get('kolab', 'primary_domain')
imap = IMAP()
if not conf.user == None:
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:
folders = imap.lm(folder)
for folder in folders:
imap.set_metadata(folder, metadata_path, metadata_value)