本文整理匯總了Python中webob.acceptparse.Accept.parse方法的典型用法代碼示例。如果您正苦於以下問題:Python Accept.parse方法的具體用法?Python Accept.parse怎麽用?Python Accept.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類webob.acceptparse.Accept
的用法示例。
在下文中一共展示了Accept.parse方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: from_settings
# 需要導入模塊: from webob.acceptparse import Accept [as 別名]
# 或者: from webob.acceptparse.Accept import parse [as 別名]
def from_settings(cls, settings):
"""Create a new instance based on the `settings` dict.
The locales supported by the application are read from the
"locales" key. The format of the value is the same as that of
the Accept-Language header, i.e.:
<locale1>;q=<q1>,<locale2>;q=<q2>,...
The q-values indicate the quality of the locale, but are
optional.
"""
locales = list(Accept.parse(settings.get("locales", "")))
return cls(locales)
示例2: test_parse_accept_badq
# 需要導入模塊: from webob.acceptparse import Accept [as 別名]
# 或者: from webob.acceptparse.Accept import parse [as 別名]
def test_parse_accept_badq():
assert list(Accept.parse("value1; q=0.1.2")) == [('value1', 1)]