def _load_plugin(self, plugin_id): """ Load @plugin_id, register all its Actions, Content and TextSources. Return its sources. """ with pluginload.exception_guard(plugin_id): plugin = pluginload.load_plugin(plugin_id) self.register_text_sources(plugin.text_sources) self.register_action_decorators(plugin.action_decorators) self.register_content_decorators(plugin.content_decorators) return set(plugin.sources) return set()
def _load_plugin(self, plugin_id): """ Load @plugin_id, register all its Actions, Content and TextSources. Return its sources. """ with pluginload.exception_guard(plugin_id): plugin = pluginload.load_plugin(plugin_id) self.register_text_sources(plugin_id, plugin.text_sources) self.register_action_decorators(plugin_id, plugin.action_decorators) self.register_content_decorators(plugin_id, plugin.content_decorators) self.register_action_generators(plugin_id, plugin.action_generators) return set(plugin.sources) return set()
def get_contents_for_leaf(self, leaf, types=None): """Iterator of content sources for @leaf, providing @types (or None for all)""" for typ in self.content_decorators: if not isinstance(leaf, typ): continue for content in list(self.content_decorators[typ]): dsrc = None with pluginload.exception_guard(content, self._remove_source, content, is_decorator=True): dsrc = content.decorate_item(leaf) if dsrc: if types and not self.good_source_for_types(dsrc, types): continue yield self.get_canonical_source(dsrc)
def _cache_sources(self, sources): # Make sure that the toplevel sources are chached # either newly rescanned or the cache is fully loaded for src in set(sources): with pluginload.exception_guard(src, self._remove_source, src): self.rescanner.rescan_now(src, force_update=False)
def _initialize_sources(self, sources): for src in set(sources): with pluginload.exception_guard(src, self._remove_source, src): src.initialize()