diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2017-10-04 16:03:29 +0200 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2017-10-04 16:03:29 +0200 |
commit | aa70fb739bbcb4f7a5275fc6a8dac4b3b84579e6 (patch) | |
tree | 7765ef60ffaa4f96723e7cec32504005f622aee7 /frontends/plain-text.py | |
parent | 6672aad7101f3593fde1009c36d0dde92ebc6512 (diff) | |
download | mensa-aa70fb739bbcb4f7a5275fc6a8dac4b3b84579e6.tar.gz mensa-aa70fb739bbcb4f7a5275fc6a8dac4b3b84579e6.tar.bz2 mensa-aa70fb739bbcb4f7a5275fc6a8dac4b3b84579e6.zip |
Added mechanism for various output formats
Diffstat (limited to 'frontends/plain-text.py')
-rw-r--r-- | frontends/plain-text.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/frontends/plain-text.py b/frontends/plain-text.py new file mode 100644 index 0000000..71cbf42 --- /dev/null +++ b/frontends/plain-text.py @@ -0,0 +1,22 @@ +import base +from yapsy.IPlugin import IPlugin +class TextRenderer(IPlugin) : + def render (self, foods, **options) : + ## Expects list of tuples with (Restaurant, Foodlist) + r = "" + vegkeys = [ "", "Vegetarian", "Vegan" ] + for restaurant, food in foods : + cat = [] + r = r+"*"*20+restaurant.human_name+"*"*20+"\n"#+base.formt(food) + food.sort(key=lambda foo: foo.category) + for i in food: + if not i.category in cat : + cat.append(i.category) + if not i.category == None : + r=r+ i.category+"\n" + r=r+"\t" + i.name.ljust(80) + "\t"+ i.price.ljust(20) + vegkeys[i.veggie]+"\n" + if i.desc : + r = r+"\t "+i.desc+"\n" + print(r) + + |