コード例 #1
0
ファイル: manager.py プロジェクト: OmegaK2/Source.Python
    def _load_auth(self, provider):
        '''Loads the given provider'''

        # Send a message that the auth provider is being loaded
        AuthManagerLogger.log_message(
            '[SP Auth] ' + _auth_strings[
                'Loading'].get_string(provider=provider))

        # Is the provider loaded?
        if provider in self:

            # If so, send a message that the provider is already loaded
            AuthManagerLogger.log_message(
                '[SP Auth] ' + _auth_strings[
                    'Already Loaded'].get_string(provider=provider))

            # No need to go further
            return

        # Does the provider's file exist?
        if not AUTH_PROVIDER_PATH.joinpath(provider + '.py').isfile():

            # Send a message that the file does not exist
            AuthManagerLogger.log_message(
                '[SP Auth] ' + _auth_strings[
                    'No Module'].get_string(provider=provider))

            # No need to go further
            return

        # Attempt to load the provider
        self[provider] = __import__(
            'auth.providers.{0}'.format(provider), fromlist=[''])

        # Call the provider's load function
        self[provider].load()

        # Send a message that the provider was loaded
        AuthManagerLogger.log_message(
            '[SP Auth] ' + _auth_strings[
                'Load Successful'].get_string(provider=provider))
コード例 #2
0
ファイル: manager.py プロジェクト: MrMalina/Source.Python
    def load_auth(self, provider):
        '''Loads the given provider'''

        # Send a message that the auth provider is being loaded
        AuthManagerLogger.log_message(
            '[SP Auth] ' + _auth_strings[
                'Loading'].get_string(provider=provider))

        # Is the provider loaded?
        if provider in self:

            # If so, send a message that the provider is already loaded
            AuthManagerLogger.log_message(
                '[SP Auth] ' + _auth_strings[
                    'Already Loaded'].get_string(provider=provider))

            # No need to go further
            return

        # Does the provider's file exist?
        if not AUTH_PROVIDER_PATH.joinpath(provider + '.py').isfile():

            # Send a message that the file does not exist
            AuthManagerLogger.log_message(
                '[SP Auth] ' + _auth_strings[
                    'No Module'].get_string(provider=provider))

            # No need to go further
            return

        # Import the provider's module
        module = __import__(
            'auth.providers.{0}'.format(provider), fromlist=[''])

        # Loop through all objects in the module
        for module_object in dir(module):

            # Get the object's instance
            instance = getattr(module, module_object)

            # Is the current object a AuthBase instance?
            if isinstance(instance, AuthBase):

                # Found the instance
                break

        # Was no AuthBase instance found?
        else:

            # Raise an error that the object was not found
            raise NotImplementedError(
                'No AuthBase instance found in provider'
                ' "{0}"'.format(provider))

        # Attempt to call the provider's load function
        instance.load()

        # Add the provider to the dictionary
        self[provider] = instance

        # Send a message that the provider was loaded
        AuthManagerLogger.log_message(
            '[SP Auth] ' + _auth_strings[
                'Load Successful'].get_string(provider=provider))
コード例 #3
0
ファイル: manager.py プロジェクト: dsezen/Source.Python
    def load_auth(self, provider):
        """Load the given provider."""
        # Send a message that the auth provider is being loaded
        auth_manager_logger.log_message(
            '[SP Auth] ' + _auth_strings[
                'Loading'].get_string(provider=provider))

        # Is the provider loaded?
        if provider in self:

            # If so, send a message that the provider is already loaded
            auth_manager_logger.log_message(
                '[SP Auth] ' + _auth_strings[
                    'Already Loaded'].get_string(provider=provider))

            # No need to go further
            return

        # Does the provider's file exist?
        if not AUTH_PROVIDER_PATH.joinpath(provider + '.py').isfile():

            # Send a message that the file does not exist
            auth_manager_logger.log_message(
                '[SP Auth] ' + _auth_strings[
                    'No Module'].get_string(provider=provider))

            # No need to go further
            return

        # Import the provider's module
        module = import_module('auth.providers.{0}'.format(provider))

        # Loop through all objects in the module
        for module_object in dir(module):

            # Get the object's instance
            instance = getattr(module, module_object)

            # Is the current object a AuthBase instance?
            if isinstance(instance, AuthBase):

                # Found the instance
                break

        # Was no AuthBase instance found?
        else:

            # Raise an error that the object was not found
            raise NotImplementedError(
                'No AuthBase instance found in provider'
                ' "{0}"'.format(provider))

        # Attempt to call the provider's load function
        instance.load()

        # Add the provider to the dictionary
        self[provider] = instance

        # Send a message that the provider was loaded
        auth_manager_logger.log_message(
            '[SP Auth] ' + _auth_strings[
                'Load Successful'].get_string(provider=provider))