本文整理匯總了Python中email.message.get_labels方法的典型用法代碼示例。如果您正苦於以下問題:Python message.get_labels方法的具體用法?Python message.get_labels怎麽用?Python message.get_labels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類email.message
的用法示例。
在下文中一共展示了message.get_labels方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add
# 需要導入模塊: from email import message [as 別名]
# 或者: from email.message import get_labels [as 別名]
def add(self, message):
"""Add message and return assigned key."""
key = _singlefileMailbox.add(self, message)
if isinstance(message, BabylMessage):
self._labels[key] = message.get_labels()
return key
示例2: __setitem__
# 需要導入模塊: from email import message [as 別名]
# 或者: from email.message import get_labels [as 別名]
def __setitem__(self, key, message):
"""Replace the keyed message; raise KeyError if it doesn't exist."""
_singlefileMailbox.__setitem__(self, key, message)
if isinstance(message, BabylMessage):
self._labels[key] = message.get_labels()
示例3: get_labels
# 需要導入模塊: from email import message [as 別名]
# 或者: from email.message import get_labels [as 別名]
def get_labels(self):
"""Return a list of user-defined labels in the mailbox."""
self._lookup()
labels = set()
for label_list in self._labels.values():
labels.update(label_list)
labels.difference_update(self._special_labels)
return list(labels)
示例4: _pre_mailbox_hook
# 需要導入模塊: from email import message [as 別名]
# 或者: from email.message import get_labels [as 別名]
def _pre_mailbox_hook(self, f):
"""Called before writing the mailbox to file f."""
f.write('BABYL OPTIONS:%sVersion: 5%sLabels:%s%s\037' %
(os.linesep, os.linesep, ','.join(self.get_labels()),
os.linesep))
示例5: _pre_mailbox_hook
# 需要導入模塊: from email import message [as 別名]
# 或者: from email.message import get_labels [as 別名]
def _pre_mailbox_hook(self, f):
"""Called before writing the mailbox to file f."""
babyl = b'BABYL OPTIONS:' + linesep
babyl += b'Version: 5' + linesep
labels = self.get_labels()
labels = (label.encode() for label in labels)
babyl += b'Labels:' + b','.join(labels) + linesep
babyl += b'\037'
f.write(babyl)