本文整理匯總了Python中flanker.mime.message.headers.MimeHeaders.prepend方法的典型用法代碼示例。如果您正苦於以下問題:Python MimeHeaders.prepend方法的具體用法?Python MimeHeaders.prepend怎麽用?Python MimeHeaders.prepend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flanker.mime.message.headers.MimeHeaders
的用法示例。
在下文中一共展示了MimeHeaders.prepend方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: headers_alternation_test
# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import prepend [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 prepend [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: prepend
# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import prepend [as 別名]
def prepend(self, key, value):
MimeHeaders.prepend(self, key, value)
self._m._headers.insert(0, (normalize(key), remove_newlines(value)))