当前位置: 首页>>代码示例>>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;未经允许,请勿转载。