# This is part of Kaylee # -- this code is licensed GPLv3 # Copyright 2015-2016 Clayton G. Hobbs # Portions Copyright 2013 Jezra from abc import ABCMeta, abstractmethod from gi.repository import GObject from gi.types import GObjectMeta class GObjectABCMeta(ABCMeta, GObjectMeta): pass class PluginBase(GObject.Object, metaclass=GObjectABCMeta): """Base class for Kaylee plugins Each Kaylee plugin module must define a subclass of this class, named ``Plugin``. """ __gsignals__ = { 'processed' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING,)) } def __init__(self, config, name): """Initialize the plugin All strings to be included in the corpus should be elements of ``corpus_strings`` by the end of __init__'s execution. Note however that the words required for number support are automatically included, so they need not be listed explicitly on a per-plugin basis. """ super().__init__() self.config = config self.name = name self.corpus_strings = set() @abstractmethod def recognizer_finished(self, recognizer, text): """Process a recognized voice command This method must return True if the command was handled by the plugin, and False otherwise. As soon as it has been determined that the command will be handled, this method must emit a ``processed`` signal with ``text`` as its parameter. """ pass