Beispiel #1
0
    def load_plugins(self):
        """Load plugins from entry points."""
        for entry_point in iter_entry_points(group='hashmal.plugin'):
            plugin_maker = entry_point.load()
            plugin_instance = plugin_maker()

            dock_tool_name = plugin_instance.dock_class.tool_name
            plugin_instance.name = dock_tool_name if dock_tool_name else entry_point.name
            plugin_instance.instantiate_dock(self)
            # Don't load plugins with unknown category metadata.
            if plugin_instance.dock.category not in Category.categories():
                continue

            self.loaded_plugins.append(plugin_instance)

        # Fail if core plugins aren't present.
        for req in required_plugins:
            if req not in [i.name for i in self.loaded_plugins]:
                print('Required plugin "{}" not found.\nTry running setup.py.'.format(req))
                sys.exit(1)

        self.update_enabled_plugins()
        self.plugins_loaded = True
        for i in self.waiting_augmentations:
            self.do_augment_hook(*i)
Beispiel #2
0
    def load_plugin(self, plugin_maker, name):
        plugin_instance = plugin_maker()

        tool_name = plugin_instance.ui_class.tool_name
        plugin_instance.name = tool_name if tool_name else name
        plugin_instance.instantiate_ui(self)
        # Don't load plugins with unknown category metadata.
        if plugin_instance.ui.category not in Category.categories():
            return

        self.loaded_plugins.append(plugin_instance)
Beispiel #3
0
    def load_plugin(self, plugin_maker, name):
        plugin_instance = plugin_maker()

        dock_tool_name = plugin_instance.dock_class.tool_name
        plugin_instance.name = dock_tool_name if dock_tool_name else name
        plugin_instance.instantiate_dock(self)
        # Don't load plugins with unknown category metadata.
        if plugin_instance.dock.category not in Category.categories():
            return

        self.loaded_plugins.append(plugin_instance)
Beispiel #4
0
    def load_plugin(self, plugin_maker, name):
        plugin_instance = plugin_maker()

        tool_name = plugin_instance.ui_class.tool_name
        plugin_instance.name = tool_name if tool_name else name
        plugin_instance.instantiate_ui(self)
        # Only required plugins can be Core plugins.
        if plugin_instance.ui.category == Category.Core and tool_name not in required_plugins:
            return
        # Don't load plugins with unknown category metadata.
        if plugin_instance.ui.category not in Category.categories():
            return

        self.loaded_plugins.append(plugin_instance)
Beispiel #5
0
    def create_menu(self, menu):
        """Add plugins to menu."""
        _categories = OrderedDict()
        for c in sorted([x[0] for x in Category.categories()]):
            _categories[c] = []
        for plugin in self.loaded_plugins:
            _categories[plugin.dock.category[0]].append(plugin)

        shortcuts = add_shortcuts(_categories.keys())
        categories = OrderedDict()
        for k, v in zip(shortcuts, _categories.values()):
            categories[k] = v
        for i in categories.keys():
            plugins = categories[i]
            if len(plugins) == 0:
                continue
            category_menu = menu.addMenu(i)
            for plugin in sorted(plugins, key = lambda x: x.name):
                category_menu.addAction(plugin.dock.toggleViewAction())