本文整理匯總了Python中openid.message.NamespaceMap.items方法的典型用法代碼示例。如果您正苦於以下問題:Python NamespaceMap.items方法的具體用法?Python NamespaceMap.items怎麽用?Python NamespaceMap.items使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類openid.message.NamespaceMap
的用法示例。
在下文中一共展示了NamespaceMap.items方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parseExtensionArgs
# 需要導入模塊: from openid.message import NamespaceMap [as 別名]
# 或者: from openid.message.NamespaceMap import items [as 別名]
def parseExtensionArgs(self, ax_args):
"""Parse attribute exchange key/value arguments into this
object.
@param ax_args: The attribute exchange fetch_response
arguments, with namespacing removed.
@type ax_args: Dict[six.text_type, six.text_type]
@returns: None
@raises ValueError: If the message has bad values for
particular fields
@raises KeyError: If the namespace mapping is bad or required
arguments are missing
"""
self._checkMode(ax_args)
aliases = NamespaceMap()
for key, value in six.iteritems(ax_args):
if key.startswith('type.'):
type_uri = value
alias = key[5:]
checkAlias(alias)
aliases.addAlias(type_uri, alias)
for type_uri, alias in aliases.items():
try:
count_s = ax_args['count.' + alias]
except KeyError:
value = ax_args['value.' + alias]
if value == '':
values = []
else:
values = [value]
else:
count = int(count_s)
values = []
for i in range(1, count + 1):
value_key = 'value.%s.%d' % (alias, i)
value = ax_args[value_key]
values.append(value)
self.data[type_uri] = values
示例2: test_iteration
# 需要導入模塊: from openid.message import NamespaceMap [as 別名]
# 或者: from openid.message.NamespaceMap import items [as 別名]
def test_iteration(self):
nsm = NamespaceMap()
uripat = 'http://example.com/foo%r'
nsm.add(uripat % 0)
for n in range(1, 23):
self.assertIn(uripat % (n - 1), nsm)
self.assertTrue(nsm.isDefined(uripat % (n - 1)))
nsm.add(uripat % n)
for (uri, alias) in nsm.items():
self.assertEqual(uri[22:], alias[3:])
for (uri, alias) in nsm.iteritems():
self.assertEqual(uri[22:], alias[3:])
self.assertEqual(len(tuple(nsm.iterAliases())), 23)
self.assertEqual(len(tuple(nsm.iterNamespaceURIs())), 23)