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


Python MimeHeaders.items方法代碼示例

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


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

示例1: headers_case_insensitivity_test

# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import items [as 別名]
def headers_case_insensitivity_test():
    h = MimeHeaders()
    h['Content-Type'] = 1
    eq_(1, h['Content-Type'])
    eq_(1, h['conTenT-TyPE'])
    ok_('cOnTenT-TyPE' in h)
    ok_('Content-Type' in h)
    eq_(1, h.get('Content-Type'))
    eq_(None, h.get('Content-Type2'))
    eq_([('Content-Type', 1)], h.items())
開發者ID:Appono,項目名稱:flanker,代碼行數:12,代碼來源:headers_test.py

示例2: headers_order_preserved_test

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

    # various types of iterations
    should_be = [('Mime-Version', '1'), ('Received', '2'), ('Mime-Version', '3'), ('Received', '4')]
    eq_(should_be, h.items())
    ok_(isinstance(h.items(), list))
    eq_(should_be, [p for p in h.iteritems()])

    # iterate over keys
    keys = ['Mime-Version', 'Received', 'Mime-Version', 'Received']
    eq_(keys, [p for p in h])
    eq_(keys, h.keys())
開發者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 items [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: headers_transform_test

# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import items [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


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