Example #1
0
    def _load_plugins(self):
        for section in self.config.sections():
            if not section.startswith(self._PLUGIN_PREFIX):
                continue

            name = section[len(self._PLUGIN_PREFIX):].strip()
            opts = dict(self.config.items(section))
            # load the plugin module and create an instance
            plugin = _util.load_dotted(opts['plugin'])
            plugin = plugin(
                name,
                dict(plugin.OPTIONS, **opts),
                self,
            )
            self._plugins[name] = plugin

        # inject attributes into plugins on a per plugin config
        # basis via config options of the form:
        # tie:plugin_local_identitier = global_name
        # or from the plugin internal config dict.
        for name, plugin in self._plugins.items():
            for key, value in plugin.options.items():
                if not key.startswith(self._TIE_PREFIX):
                    continue

                source = key[len(self._TIE_PREFIX):].strip()
                target = _weakref.proxy(self._plugins[value])
                setattr(self._plugins[name], source, target)

        # only after alll plugins are instantiated and properly
        # injected, they may connect to other plugins signals,
        # so we, sadly, have to live with some kind of bootstrap
        # method with some additional code
        for plugin in self._plugins.values():
            plugin.bootstrap()
Example #2
0
    def _load_plugins(self):
        for section in self.config.sections():
            if not section.startswith(self._PLUGIN_PREFIX):
                continue

            name = section[len(self._PLUGIN_PREFIX):].strip()
            opts = dict(self.config.items(section))
            # load the plugin module and create an instance
            plugin = _util.load_dotted(opts['plugin'])
            plugin = plugin(
                name,
                dict(plugin.OPTIONS, **opts),
                self,
            )
            self._plugins[name] = plugin


        # inject attributes into plugins on a per plugin config
        # basis via config options of the form:
        # tie:plugin_local_identitier = global_name
        # or from the plugin internal config dict.
        for name, plugin in self._plugins.iteritems():
            for key, value in plugin.options.iteritems():
                if not key.startswith(self._TIE_PREFIX):
                    continue

                source = key[len(self._TIE_PREFIX):].strip()
                target = _weakref.proxy(self._plugins[value])
                setattr(self._plugins[name], source, target)

        # only after alll plugins are instantiated and properly
        # injected, they may connect to other plugins signals,
        # so we, sadly, have to live with some kind of bootstrap
        # method with some additional code
        for plugin in self._plugins.values():
            plugin.bootstrap()
Example #3
0
 def _callable(self, label, options, callable):
     return _util.load_dotted(options["callable"])(options, self)
Example #4
0
 def _callable(self, label, options, callable):
     try:
         return _util.load_dotted(options["callable"])(options, self)
     except HistoryEmpty:
         _log.info("History is empty")
         self.klemmbrett.notify("The history is empty", "The history is empty")
Example #5
0
 def _callable(self, label, options, callable):
     try:
         return _util.load_dotted(options["callable"])(options, self)
     except HistoryEmpty:
         _log.info("History is empty")
         self.klemmbrett.notify("The history is empty", "The history is empty")