def _fromOpenIDArgs(self, openid_args):
        global registered_aliases

        ns_args = []

        # Resolve namespaces
        for rest, value in openid_args.iteritems():
            try:
                ns_alias, ns_key = rest.split('.', 1)
            except ValueError:
                ns_alias = NULL_NAMESPACE
                ns_key = rest

            if ns_alias == 'ns':
                self.namespaces.addAlias(value, ns_key)
            elif ns_alias == NULL_NAMESPACE and ns_key == 'ns':
                # null namespace
                self.namespaces.addAlias(value, NULL_NAMESPACE)
            else:
                ns_args.append((ns_alias, ns_key, value))

        # Ensure that there is an OpenID namespace definition
        openid_ns_uri = self.namespaces.getNamespaceURI(NULL_NAMESPACE)
        if openid_ns_uri is None:
            openid_ns_uri = OPENID1_NS

        self.setOpenIDNamespace(openid_ns_uri)

        # Actually put the pairs into the appropriate namespaces
        for (ns_alias, ns_key, value) in ns_args:
            ns_uri = self.namespaces.getNamespaceURI(ns_alias)
            if ns_uri is None:
                # Only try to map an alias to a default if it's an
                # OpenID 1.x message.
                if openid_ns_uri == OPENID1_NS:
                    for _alias, _uri in registered_aliases.iteritems():
                        if _alias == ns_alias:
                            ns_uri = _uri
                            break

                if ns_uri is None:
                    ns_uri = openid_ns_uri
                    ns_key = '%s.%s' % (ns_alias, ns_key)
                else:
                    self.namespaces.addAlias(ns_uri, ns_alias)

            self.setArg(ns_uri, ns_key, value)
dataset/ETHPy150Open CollabQ/CollabQ/openid/message.py/Message._fromOpenIDArgs/original