def _create_plugin(self, config):
        """
        Creates a plugin from its config.

        Params:
            config:       plugin configuration as read by ait.config
        Returns:
            plugin:       a Plugin
        Raises:
            ValueError:   if any of the required config values are missing
        """
        if config is None:
            raise ValueError('No plugin config to create plugin from.')

        name = config.pop('name', None)
        if name is None:
            raise(cfg.AitConfigMissing('plugin name'))

        # TODO I don't think we actually care about this being unique? Left over from
        # previous conversations about stuff?
        module_name = name.rsplit('.', 1)[0]
        class_name = name.rsplit('.', 1)[-1]
        if class_name in [x.name for x in (self.outbound_streams +
                                           self.inbound_streams +
                                           self.servers +
                                           self.plugins)]:
            raise ValueError(
                'Plugin "{}" already loaded. Only one plugin of a given name is allowed'.
                format(class_name)
            )

        plugin_inputs = config.pop('inputs', None)
        if plugin_inputs is None:
            log.warn('No plugin inputs specified for {}'.format(name))
            plugin_inputs = [ ]

        subscribers = config.pop('outputs', None)
        if subscribers is None:
            log.warn('No plugin outputs specified for {}'.format(name))
            subscribers = [ ]

        # try to create plugin
        module = import_module(module_name)
        plugin_class = getattr(module, class_name)
        instance = plugin_class(plugin_inputs,
                                subscribers,
                                zmq_args={'zmq_context': self.broker.context,
                                          'zmq_proxy_xsub_url': self.broker.XSUB_URL,
                                          'zmq_proxy_xpub_url': self.broker.XPUB_URL},
                                **config
        )

        return instance
def _create_plugin ( self , config ) : if config is None : raise ValueError ( 'No plugin config to create plugin from.' ) name = config . pop ( 'name' , None ) if name is None : raise ( cfg . AitConfigMissing ( 'plugin name' ) ) module_name = name . rsplit ( '.' , 1 ) [ 0 ] class_name = name . rsplit ( '.' , 1 ) [ - 1 ] if class_name in [ x . name for x in ( self . outbound_streams + self . inbound_streams + self . servers + self . plugins ) ] : raise ValueError ( 'Plugin "{}" already loaded. Only one plugin of a given name is allowed' . format ( class_name ) ) plugin_inputs = config . pop ( 'inputs' , None ) if plugin_inputs is None : log . warn ( 'No plugin inputs specified for {}' . format ( name ) ) plugin_inputs = [ ] subscribers = config . pop ( 'outputs' , None ) if subscribers is None : log . warn ( 'No plugin outputs specified for {}' . format ( name ) ) subscribers = [ ] module = import_module ( module_name ) plugin_class = getattr ( module , class_name ) instance = plugin_class ( plugin_inputs , subscribers , zmq_args = { 'zmq_context' : self . broker . context , 'zmq_proxy_xsub_url' : self . broker . XSUB_URL , 'zmq_proxy_xpub_url' : self . broker . XPUB_URL } , ** config ) return instance
Creates a plugin from its config.

        Params:
            config:       plugin configuration as read by ait.config
        Returns:
            plugin:       a Plugin
        Raises:
            ValueError:   if any of the required config values are missing