blob: 36b2a34f67ecca87b7e19d4e4568ab9e75c5022f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
from mensa 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 = []
if not food :
continue
r = r+"*"*20+restaurant.human_name+"*"*20+"\n"#+base.formt(food)
if "pos" in options and restaurant.pos and "dist" in options :
## display distance to restaurant
r=r+"Distance: %.2f km\n" % base.dist(options["pos"], restaurant.pos)
food.sort(key=lambda foo: foo.category)
for i in food:
if options["only_student_prices"] :
price = base.only_student_prices(i.price)
else:
price = i.price
if options["only_veggie"] and options["only_veggie"] > i.veggie :
continue
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"+ price.ljust(20) + vegkeys[i.veggie]+"\n"
if i.desc :
r = r+"\t "+i.desc+"\n"
print(r)
def register_renderer(self) :
base.register_renderer(base.Renderer("plain-text", "Plain Text Renderer", self))
|