(self)
Enumerates through installed plugins and registers each according to
        the features provided. Only one plugin may be registered per feature.
        When more than one plugin is found, the first will be registered and
        all others listed as inactive.
Enumerates through installed plugins and registers each according to
        the features provided. Only one plugin may be registered per feature.
        When more than one plugin is found, the first will be registered and
        all others listed as inactive.
Enumerates through installed plugins and registers each according to the features provided . Only one plugin may be registered per feature . When more than one plugin is found the first will be registered and all others listed as inactive .
def load(self):
        """
        Enumerates through installed plugins and registers each according to
        the features provided. Only one plugin may be registered per feature.
        When more than one plugin is found, the first will be registered and
        all others listed as inactive.
        """
        info_files = list()
        directory_listing = os.listdir(self.path)
        for _file in directory_listing:
            if _file.endswith(INFO_FILE_EXTENSION):
                info_files.append(_file)

        for filename in info_files:
            plugin_name = filename[:-len(INFO_FILE_EXTENSION)]
            md = self.metadata_for_plugin(plugin_name)
            try:
                if md['type'].upper() in PLUGIN_TYPES:
                    for target in md['targets']:
                        target = target if isinstance(target, str) else tuple(target)
                        if not target in self._targets:
                            self._targets[target] = plugin_name
                        else:
                            msg = 'Did not register %s for %s. Plugin %s already registered.' % (plugin_name,
                                                                                                 target,
                                                                                                 self._targets[target])
                            self._register_plugin_with_error(plugin_name, msg)
                            self.log.warn(msg)
                    self._plugins[plugin_name] = md
                    self._types[md['type'].upper()].append(plugin_name)
                    self.log.info('Plugin (%s) loaded...' % plugin_name)
            except KeyError as e:
                msg = 'Invalid metadata for plugin (%s). Missing entry for %s.' % (plugin_name, e)
                self._register_plugin_with_error(plugin_name, msg)
                self.log.exception(msg)
            except Exception as e:
                msg = 'Loading plugin (%s) failed with exception: %s' % (plugin_name, e)
                self._register_plugin_with_error(plugin_name, msg)
                self.log.exception(msg)
def load ( self ) : info_files = list ( ) directory_listing = os . listdir ( self . path ) for _file in directory_listing : if _file . endswith ( INFO_FILE_EXTENSION ) : info_files . append ( _file ) for filename in info_files : plugin_name = filename [ : - len ( INFO_FILE_EXTENSION ) ] md = self . metadata_for_plugin ( plugin_name ) try : if md [ 'type' ] . upper ( ) in PLUGIN_TYPES : for target in md [ 'targets' ] : target = target if isinstance ( target , str ) else tuple ( target ) if not target in self . _targets : self . _targets [ target ] = plugin_name else : msg = 'Did not register %s for %s. Plugin %s already registered.' % ( plugin_name , target , self . _targets [ target ] ) self . _register_plugin_with_error ( plugin_name , msg ) self . log . warn ( msg ) self . _plugins [ plugin_name ] = md self . _types [ md [ 'type' ] . upper ( ) ] . append ( plugin_name ) self . log . info ( 'Plugin (%s) loaded...' % plugin_name ) except KeyError as e : msg = 'Invalid metadata for plugin (%s). Missing entry for %s.' % ( plugin_name , e ) self . _register_plugin_with_error ( plugin_name , msg ) self . log . exception ( msg ) except Exception as e : msg = 'Loading plugin (%s) failed with exception: %s' % ( plugin_name , e ) self . _register_plugin_with_error ( plugin_name , msg ) self . log . exception ( msg )