Appendix

Robot Chef plugin.py

from lml.plugin import PluginManager


class NoChefException(Exception):
    pass


class CuisineManager(PluginManager):
    def __init__(self):
        PluginManager.__init__(self, "cuisine")

    def get_a_plugin(self, food_name=None, **keywords):
        return PluginManager.get_a_plugin(self, key=food_name, **keywords)

    def raise_exception(self, key):
        raise NoChefException("Cannot find a chef")


class Chef(object):
    def make(self, **params):
        print("I am a chef")

Robot Chef Version 3

code difference with Robot Chef All In One solution: plugin.py

--- /home/docs/checkouts/readthedocs.org/user_builds/lml/checkouts/latest/examples/robotchef_allinone/robotchef_allinone/plugin.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/lml/checkouts/latest/examples/robotchef_allinone_lml/robotchef_allinone_lml/plugin.py
@@ -1,5 +1,19 @@
+from lml.plugin import PluginInfo, PluginManager
+
+
 class NoChefException(Exception):
     pass
+
+
+class CuisineManager(PluginManager):
+    def __init__(self):
+        PluginManager.__init__(self, "cuisine")
+
+    def get_a_plugin(self, food_name=None, **keywords):
+        return PluginManager.get_a_plugin(self, key=food_name, **keywords)
+
+    def raise_exception(self, key):
+        raise NoChefException("Cannot find a chef")
 
 
 class Chef(object):
@@ -7,32 +21,19 @@
         print("I am a chef")
 
 
+@PluginInfo("cuisine", tags=["Portable Battery"])
 class Boost(Chef):
     def make(self, food=None, **keywords):
         print("I can cook %s for robots" % food)
 
 
+@PluginInfo("cuisine", tags=["Fish and Chips"])
 class Fry(Chef):
     def make(self, food=None):
         print("I can fry " + food)
 
 
+@PluginInfo("cuisine", tags=["Cornish Scone", "Jacket Potato"])
 class Bake(Chef):
     def make(self, food=None):
         print("I can bake " + food)
-
-
-PLUGINS = {
-    "Portable Battery": Boost,
-    "Fish and Chips": Fry,
-    "Cornish Scone": Bake,
-    "Jacket Potato": Bake,
-}
-
-
-def get_a_plugin(food_name=None, **keywords):
-    plugin = PLUGINS.get(food_name)
-    if plugin is None:
-        raise NoChefException("Cannot find a chef")
-    plugin_cls = plugin()
-    return plugin_cls