From aa70fb739bbcb4f7a5275fc6a8dac4b3b84579e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Wed, 4 Oct 2017 16:03:29 +0200 Subject: Added mechanism for various output formats --- run.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'run.py') diff --git a/run.py b/run.py index 3ce971f..a4248d5 100755 --- a/run.py +++ b/run.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 import base +import urllib.error import argparse @@ -21,14 +22,17 @@ backends = PluginManager() backends.setPluginPlaces(["./backends"]) backends.collectPlugins() ## Load frontends (not yet implemented) -# from yapsy.PluginManager import PluginManager -# frontends = PluginManager() -# frontends.setPluginPlaces(["./frontends"]) -# frontends.collectPlugins() +from yapsy.PluginManager import PluginManager +frontends = PluginManager() +frontends.setPluginPlaces(["./frontends"]) +frontends.collectPlugins() for pluginInfo in backends.getAllPlugins(): backends.activatePluginByName(pluginInfo.name) pluginInfo.plugin_object.register_restaurants() +for pluginInfo in frontends.getAllPlugins(): + frontends.activatePluginByName(pluginInfo.name) + if args.list : for k,i in base.foodsources.items(): @@ -37,14 +41,19 @@ if args.list : restlist = None if args.rest : restlist = args.rest.split(",") - +to_render = [] for k,i in base.foodsources.items() : if restlist and not i.name in restlist : continue try : food = i.get_food(ignore_nudelauswahl=True) - print("*"*20+i.human_name+"*"*20+"\n"+base.formt(food)) + to_render.append((i, food)) + # print("*"*20+i.human_name+"*"*20+"\n"+base.formt(food)) except base.NoMenuError: print(i.human_name + ": No menu found. This could be due to a holiday or due to an error in the script.") except urllib.error.HTTPError as e : print(i.human_name + ": Fetching menu failed: %s" % str(e)) + +for i in frontends.getAllPlugins(): + print(i.name) + i.plugin_object.render(to_render) -- cgit v1.2.3