当前位置: 首页>>代码示例>>Python>>正文


Python NamespaceMap.iterNamespaceURIs方法代码示例

本文整理汇总了Python中openid.message.NamespaceMap.iterNamespaceURIs方法的典型用法代码示例。如果您正苦于以下问题:Python NamespaceMap.iterNamespaceURIs方法的具体用法?Python NamespaceMap.iterNamespaceURIs怎么用?Python NamespaceMap.iterNamespaceURIs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openid.message.NamespaceMap的用法示例。


在下文中一共展示了NamespaceMap.iterNamespaceURIs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_iteration

# 需要导入模块: from openid.message import NamespaceMap [as 别名]
# 或者: from openid.message.NamespaceMap import iterNamespaceURIs [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)
开发者ID:ziima,项目名称:python-openid,代码行数:20,代码来源:test_message.py

示例2: parseExtensionArgs

# 需要导入模块: from openid.message import NamespaceMap [as 别名]
# 或者: from openid.message.NamespaceMap import iterNamespaceURIs [as 别名]
    def parseExtensionArgs(self, ax_args):
        """Given attribute exchange arguments, populate this FetchRequest.

        @param ax_args: Attribute Exchange arguments from the request.
            As returned from L{Message.getArgs<openid.message.Message.getArgs>}.
        @type ax_args: dict

        @raises KeyError: if the message is not consistent in its use
            of namespace aliases.

        @raises NotAXMessage: If ax_args does not include an Attribute Exchange
            mode.

        @raises AXError: If the data to be parsed does not follow the
            attribute exchange specification. At least when
            'if_available' or 'required' is not specified for a
            particular attribute type.
        """
        # Raises an exception if the mode is not the expected value
        self._checkMode(ax_args)

        aliases = NamespaceMap()

        for key, value in six.iteritems(ax_args):
            if key.startswith('type.'):
                alias = key[5:]
                type_uri = value
                aliases.addAlias(type_uri, alias)

                count_key = 'count.' + alias
                count_s = ax_args.get(count_key)
                if count_s:
                    try:
                        count = int(count_s)
                        if count <= 0:
                            raise AXError("Count %r must be greater than zero, got %r" % (count_key, count_s,))
                    except ValueError:
                        if count_s != UNLIMITED_VALUES:
                            raise AXError("Invalid count value for %r: %r" % (count_key, count_s,))
                        count = count_s
                else:
                    count = 1

                self.add(AttrInfo(type_uri, alias=alias, count=count))

        required = toTypeURIs(aliases, ax_args.get('required'))

        for type_uri in required:
            self.requested_attributes[type_uri].required = True

        if_available = toTypeURIs(aliases, ax_args.get('if_available'))

        all_type_uris = required + if_available

        for type_uri in aliases.iterNamespaceURIs():
            if type_uri not in all_type_uris:
                raise AXError(
                    'Type URI %r was in the request but not '
                    'present in "required" or "if_available"' % (type_uri,))

        self.update_url = ax_args.get('update_url')
开发者ID:ziima,项目名称:python-openid,代码行数:63,代码来源:ax.py


注:本文中的openid.message.NamespaceMap.iterNamespaceURIs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。