# Path: openid/extension.py
# class Extension(object):
#     """An interface for OpenID extensions.
# 
#     @ivar ns_uri: The namespace to which to add the arguments for this
#         extension
#     """
#     ns_uri = None
#     ns_alias = None
# 
#     def getExtensionArgs(self):
#         """Get the string arguments that should be added to an OpenID
#         message for this extension.
# 
#         @returns: A dictionary of completely non-namespaced arguments
#             to be added. For example, if the extension's alias is
#             'uncle', and this method returns {'meat':'Hot Rats'}, the
#             final message will contain {'openid.uncle.meat':'Hot Rats'}
#         """
#         raise NotImplementedError
# 
#     def toMessage(self, message=None):
#         """Add the arguments from this extension to the provided
#         message, or create a new message containing only those
#         arguments.
# 
#         @returns: The message with the extension arguments added
#         """
#         if message is None:
#             warnings.warn('Passing None to Extension.toMessage is deprecated. '
#                           'Creating a message assuming you want OpenID 2.',
#                           DeprecationWarning, stacklevel=2)
#             message = message_module.Message(message_module.OPENID2_NS)
# 
#         implicit = message.isOpenID1()
# 
#         try:
#             message.namespaces.addAlias(self.ns_uri, self.ns_alias,
#                                         implicit=implicit)
#         except KeyError:
#             if message.namespaces.getAlias(self.ns_uri) != self.ns_alias:
#                 raise
# 
#         message.updateArgs(self.ns_uri, self.getExtensionArgs())
#         return message
# 
# Path: openid/message.py
# class NamespaceAliasRegistrationError(Exception):
#     """
#     Raised when an alias or namespace URI has already been registered.
#     """
#     pass
# 
# def registerNamespaceAlias(namespace_uri, alias):
#     """
#     Registers a (namespace URI, alias) mapping in a global namespace
#     alias map.  Raises NamespaceAliasRegistrationError if either the
#     namespace URI or alias has already been registered with a
#     different value.  This function is required if you want to use a
#     namespace with an OpenID 1 message.
#     """
#     global registered_aliases
# 
#     if registered_aliases.get(alias) == namespace_uri:
#         return
# 
#     if namespace_uri in registered_aliases.values():
#         raise NamespaceAliasRegistrationError('Namespace uri %r already registered' % (namespace_uri,))
# 
#     if alias in registered_aliases:
#         raise NamespaceAliasRegistrationError('Alias %r already registered' % (alias,))
# 
#     registered_aliases[alias] = namespace_uri
# 
# Path: openid/oidutil.py
# def force_text(value):
#     """
#     Return a text object representing value in UTF-8 encoding.
#     """
#     if isinstance(value, six.text_type):
#         # It's already a text, just return it.
#         return value
#     elif isinstance(value, bytes):
#         # It's a byte string, decode it.
#         return value.decode('utf-8')
#     else:
#         # It's not a string, convert it.
#         return six.text_type(value)
# 
# def string_to_text(value, deprecate_msg):
#     """
#     Return input string coverted to text string.
# 
#     If input is text, it is returned as is.
#     If input is binary, it is decoded using UTF-8 to text.
#     """
#     assert isinstance(value, (six.text_type, six.binary_type))
#     if isinstance(value, six.binary_type):
#         warnings.warn(deprecate_msg, DeprecationWarning)
#         value = value.decode('utf-8')
#     return value


import logging
import six
from openid.extension import Extension
from openid.message import NamespaceAliasRegistrationError, registerNamespaceAlias
from openid.oidutil import force_text, string_to_text
        OpenID server needs more control over how the arguments are
        parsed than that method provides.

        >>> args = message.getArgs(ns_uri)
        >>> request.parseExtensionArgs(args)

        @param args: The unqualified simple registration arguments
        @type args: Dict[six.text_type, six.text_type], six.binary_type is deprecated

        @param strict: Whether requests with fields that are not
            defined in the simple registration specification should be
            tolerated (and ignored)
        @type strict: bool

        @returns: None; updates this object
        """
        for list_name in ['required', 'optional']:
            required = (list_name == 'required')
            items = args.get(list_name)
            if items:
                items = string_to_text(items, "Binary values for args are deprecated. Use text input instead.")
                for field_name in items.split(','):
                    try:
                        self.requestField(field_name, required, strict)
                    except ValueError:
                        if strict:
                            raise

        policy_url = args.get('policy_url')
        if policy_url is not None:

# Path: openid/extension.py
# class Extension(object):
#     """An interface for OpenID extensions.
# 
#     @ivar ns_uri: The namespace to which to add the arguments for this
#         extension
#     """
#     ns_uri = None
#     ns_alias = None
# 
#     def getExtensionArgs(self):
#         """Get the string arguments that should be added to an OpenID
#         message for this extension.
# 
#         @returns: A dictionary of completely non-namespaced arguments
#             to be added. For example, if the extension's alias is
#             'uncle', and this method returns {'meat':'Hot Rats'}, the
#             final message will contain {'openid.uncle.meat':'Hot Rats'}
#         """
#         raise NotImplementedError
# 
#     def toMessage(self, message=None):
#         """Add the arguments from this extension to the provided
#         message, or create a new message containing only those
#         arguments.
# 
#         @returns: The message with the extension arguments added
#         """
#         if message is None:
#             warnings.warn('Passing None to Extension.toMessage is deprecated. '
#                           'Creating a message assuming you want OpenID 2.',
#                           DeprecationWarning, stacklevel=2)
#             message = message_module.Message(message_module.OPENID2_NS)
# 
#         implicit = message.isOpenID1()
# 
#         try:
#             message.namespaces.addAlias(self.ns_uri, self.ns_alias,
#                                         implicit=implicit)
#         except KeyError:
#             if message.namespaces.getAlias(self.ns_uri) != self.ns_alias:
#                 raise
# 
#         message.updateArgs(self.ns_uri, self.getExtensionArgs())
#         return message
# 
# Path: openid/message.py
# class NamespaceAliasRegistrationError(Exception):
#     """
#     Raised when an alias or namespace URI has already been registered.
#     """
#     pass
# 
# def registerNamespaceAlias(namespace_uri, alias):
#     """
#     Registers a (namespace URI, alias) mapping in a global namespace
#     alias map.  Raises NamespaceAliasRegistrationError if either the
#     namespace URI or alias has already been registered with a
#     different value.  This function is required if you want to use a
#     namespace with an OpenID 1 message.
#     """
#     global registered_aliases
# 
#     if registered_aliases.get(alias) == namespace_uri:
#         return
# 
#     if namespace_uri in registered_aliases.values():
#         raise NamespaceAliasRegistrationError('Namespace uri %r already registered' % (namespace_uri,))
# 
#     if alias in registered_aliases:
#         raise NamespaceAliasRegistrationError('Alias %r already registered' % (alias,))
# 
#     registered_aliases[alias] = namespace_uri
# 
# Path: openid/oidutil.py
# def force_text(value):
#     """
#     Return a text object representing value in UTF-8 encoding.
#     """
#     if isinstance(value, six.text_type):
#         # It's already a text, just return it.
#         return value
#     elif isinstance(value, bytes):
#         # It's a byte string, decode it.
#         return value.decode('utf-8')
#     else:
#         # It's not a string, convert it.
#         return six.text_type(value)
# 
# def string_to_text(value, deprecate_msg):
#     """
#     Return input string coverted to text string.
# 
#     If input is text, it is returned as is.
#     If input is binary, it is decoded using UTF-8 to text.
#     """
#     assert isinstance(value, (six.text_type, six.binary_type))
#     if isinstance(value, six.binary_type):
#         warnings.warn(deprecate_msg, DeprecationWarning)
#         value = value.decode('utf-8')
#     return value


# Path: openid/extensions/sreg.py
import logging
import six
from openid.extension import Extension
from openid.message import NamespaceAliasRegistrationError, registerNamespaceAlias
from openid.oidutil import force_text, string_to_text

        OpenID server needs more control over how the arguments are
        parsed than that method provides.

        >>> args = message.getArgs(ns_uri)
        >>> request.parseExtensionArgs(args)

        @param args: The unqualified simple registration arguments
        @type args: Dict[six.text_type, six.text_type], six.binary_type is deprecated

        @param strict: Whether requests with fields that are not
            defined in the simple registration specification should be
            tolerated (and ignored)
        @type strict: bool

        @returns: None; updates this object
        """
        for list_name in ['required', 'optional']:
            required = (list_name == 'required')
            items = args.get(list_name)
            if items:
                items = string_to_text(items, "Binary values for args are deprecated. Use text input instead.")
                for field_name in items.split(','):
                    try:
                        self.requestField(field_name, required, strict)
                    except ValueError:
                        if strict:
                            raise

        policy_url = args.get('policy_url')
        if policy_url is not None:

            policy_url = string_to_text(args.get('policy_url'),