#NEWLINE# def unload( self , plugins ) : #NEWLINE# #INDENT# 'Takes either a plugin name or a list of plugins and unloads them.\n\n        Simply validates whether we have loaded a plugin by a given name, and\n        if so, clears all the data associated with it.\n\n        Keyword arguments:\n          plugins -- This can be either a single or list of plugin names.\n\n        Returns:\n          list -- A list of failed plugins, or an empty list.\n\n        Raises:\n          TypeError -- When the `plugins` argument is not a string or list.\n\n        ' #NEWLINE# if isinstance ( plugins , basestring ) : #NEWLINE# #INDENT# plugins = [ plugins . encode ( 'utf-8' ) ] #NEWLINE# #UNINDENT# if ( not isinstance ( plugins , list ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Plugins must be a string or list of plugins' ) #NEWLINE# #UNINDENT# failed_plugins = [ ] #NEWLINE# for plugin in plugins : #NEWLINE# #INDENT# self . logger . info ( ( 'Attempting to unload plugin: %s' % plugin ) ) #NEWLINE# if ( plugin not in self . plugins ) : #NEWLINE# #INDENT# self . logger . warning ( ( 'Plugin was never loaded: %s' % plugin ) ) #NEWLINE# failed_plugins . append ( plugin ) #NEWLINE# continue #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . _unregister_plugin_callbacks ( plugin ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . logger . exception ( "Didn't remove all plugin callbacks: %s" , plugin ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . _close_plugin_instance ( plugin ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . logger . exception ( ( "Didn't close plugin cleanly: %s" % plugin ) ) #NEWLINE# failed_plugins . append ( plugin ) #NEWLINE# #UNINDENT# del self . plugins [ plugin ] #NEWLINE# #UNINDENT# return failed_plugins