本文整理汇总了Python中flanker.mime.message.headers.MimeHeaders.add方法的典型用法代码示例。如果您正苦于以下问题:Python MimeHeaders.add方法的具体用法?Python MimeHeaders.add怎么用?Python MimeHeaders.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flanker.mime.message.headers.MimeHeaders
的用法示例。
在下文中一共展示了MimeHeaders.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: headers_alternation_test
# 需要导入模块: from flanker.mime.message.headers import MimeHeaders [as 别名]
# 或者: from flanker.mime.message.headers.MimeHeaders import add [as 别名]
def headers_alternation_test():
headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')]
h = MimeHeaders(headers)
assert_false(h.have_changed())
h.prepend('Received', 'Yo')
ok_(h.have_changed())
h = MimeHeaders(headers)
del h['Mime-Version']
ok_(h.have_changed())
h = MimeHeaders(headers)
h['Mime-Version'] = 'a'
ok_(h.have_changed())
h = MimeHeaders(headers)
h.add('Mime-Version', 'a')
ok_(h.have_changed())
h = MimeHeaders(headers)
h.getall('Mime-Version')
h.get('o')
assert_false(h.have_changed())
示例2: headers_multiple_values_test
# 需要导入模块: from flanker.mime.message.headers import MimeHeaders [as 别名]
# 或者: from flanker.mime.message.headers.MimeHeaders import add [as 别名]
def headers_multiple_values_test():
headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')]
h = MimeHeaders(headers)
eq_(['1', '3'], h.getall('Mime-Version'))
# set re-sets all values for the message
h['Mime-Version'] = '5'
eq_(['5'], h.getall('Mime-Version'))
# use add to add more values
h.add('Received', '6')
eq_(['2', '4', '6'], h.getall('Received'))
# use prepend to insert header in the begining of the list
h.prepend('Received', '0')
eq_(['0', '2', '4', '6'], h.getall('Received'))
# delete removes it all!
del h['RECEIVED']
eq_([], h.getall('Received'))
示例3: add
# 需要导入模块: from flanker.mime.message.headers import MimeHeaders [as 别名]
# 或者: from flanker.mime.message.headers.MimeHeaders import add [as 别名]
def add(self, key, value):
MimeHeaders.add(self, key, value)
self._m[key] = headers.to_mime(normalize(key), remove_newlines(value))