當前位置: 首頁>>代碼示例>>Python>>正文


Python MimeHeaders.transform方法代碼示例

本文整理匯總了Python中flanker.mime.message.headers.MimeHeaders.transform方法的典型用法代碼示例。如果您正苦於以下問題:Python MimeHeaders.transform方法的具體用法?Python MimeHeaders.transform怎麽用?Python MimeHeaders.transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flanker.mime.message.headers.MimeHeaders的用法示例。


在下文中一共展示了MimeHeaders.transform方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: headers_transform_encodedword_test

# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import transform [as 別名]
def headers_transform_encodedword_test():
    # Create a header with non-ascii characters that will be stored in encoded-word format.
    headers = [('Subject', encoding.to_mime('Subject', u'Hello ✓'))]
    h = MimeHeaders(headers)

    # transform should decode it for us when we pass decode=True
    h.transform(lambda key,val: (key, val.replace(u'✓', u'☃')), decode=True)
    eq_(u'Hello ☃', h.get('Subject'))
開發者ID:mailgun,項目名稱:flanker,代碼行數:10,代碼來源:headers_test.py

示例2: headers_transform_test

# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import transform [as 別名]
def headers_transform_test():
    headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')]

    h = MimeHeaders(headers)

    # transform tracks whether anything actually changed
    h.transform(lambda key,val: (key, val))
    assert_false(h.have_changed())

    # ok, now something have changed, make sure we've preserved order and did not collapse anything
    h.transform(lambda key,val: ("X-{0}".format(key), "t({0})".format(val)))
    ok_(h.have_changed())

    eq_([('X-Mime-Version', 't(1)'), ('X-Received', 't(2)'), ('X-Mime-Version', 't(3)'), ('X-Received', 't(4)')], h.items())
開發者ID:Appono,項目名稱:flanker,代碼行數:16,代碼來源:headers_test.py

示例3: headers_transform_test

# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import transform [as 別名]
def headers_transform_test():
    headers = [("mime-version", "1"), ("rEceived", "2"), ("mime-version", "3"), ("ReceiveD", "4")]

    h = MimeHeaders(headers)

    # transform tracks whether anything actually changed
    h.transform(lambda key, val: (key, val))
    assert_false(h.have_changed())

    # ok, now something have changed, make sure we've preserved order and did not collapse anything
    h.transform(lambda key, val: ("X-{}".format(key), "t({})".format(val)))
    ok_(h.have_changed())

    eq_(
        [("X-Mime-Version", "t(1)"), ("X-Received", "t(2)"), ("X-Mime-Version", "t(3)"), ("X-Received", "t(4)")],
        h.items(),
    )
開發者ID:nickcatal,項目名稱:flanker,代碼行數:19,代碼來源:headers_test.py

示例4: transform

# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import transform [as 別名]
 def transform(self, func):
     MimeHeaders.transform(self, func)
     self._m._headers = self.items()
開發者ID:Appono,項目名稱:flanker,代碼行數:5,代碼來源:part.py


注:本文中的flanker.mime.message.headers.MimeHeaders.transform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。