diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2018-03-06 11:05:23 +0100 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2018-03-06 11:05:23 +0100 |
commit | 6000a3a6e5acf073a224e74be590407616eeeffb (patch) | |
tree | 129c4fd932a749a92d845ba2521c250438c0bb95 /mensa | |
parent | 7355b3e3503ca95e1ee11ebb814c3f2551143a86 (diff) | |
download | mensa-6000a3a6e5acf073a224e74be590407616eeeffb.tar.gz mensa-6000a3a6e5acf073a224e74be590407616eeeffb.tar.bz2 mensa-6000a3a6e5acf073a224e74be590407616eeeffb.zip |
--no-parallel option to fix studentenwerk behaviour, option to show only student prices to avoid clutter
Diffstat (limited to 'mensa')
-rw-r--r-- | mensa/base.py | 3 | ||||
-rw-r--r-- | mensa/frontends/html.py | 6 | ||||
-rw-r--r-- | mensa/frontends/plain-text.py | 6 | ||||
-rwxr-xr-x | mensa/logic.py | 5 |
4 files changed, 16 insertions, 4 deletions
diff --git a/mensa/base.py b/mensa/base.py index fa7346a..a6e8cfa 100644 --- a/mensa/base.py +++ b/mensa/base.py @@ -57,3 +57,6 @@ def register_restaurant(restaurant): def register_renderer(renderer) : global renderers renderers[renderer.name] = renderer + +def only_student_prices(price): + return price.split("/")[0] diff --git a/mensa/frontends/html.py b/mensa/frontends/html.py index 8ffec37..8a5618f 100644 --- a/mensa/frontends/html.py +++ b/mensa/frontends/html.py @@ -14,6 +14,10 @@ class HTMLRenderer(IPlugin) : r = r+"<div class=\"restaurant\"><h3>"+esc(restaurant.human_name)+"</h3>"+"\n"#+base.formt(food) 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 : @@ -22,7 +26,7 @@ class HTMLRenderer(IPlugin) : cat.append(i.category) if not i.category == None : r=r+ "<h4>"+esc(i.category)+"</h4><ul class=\"food-by-cat\">\n" - r=r+"<li class=\"fooditem\" ><span class=\"name\">" + esc(i.name) + "</span><span class=\"price\">"+ esc(i.price) + "</span><span class=\"veggie\">"+ esc(vegkeys[i.veggie])+"</span>\n" + r=r+"<li class=\"fooditem\" ><span class=\"name\">" + esc(i.name) + "</span><span class=\"price\">"+ esc(price) + "</span><span class=\"veggie\">"+ esc(vegkeys[i.veggie])+"</span>\n" if i.desc : r = r+"<div class=\"description\">"+esc(i.desc)+"</div>\n" r = r+"</div>" diff --git a/mensa/frontends/plain-text.py b/mensa/frontends/plain-text.py index 7a31371..9147133 100644 --- a/mensa/frontends/plain-text.py +++ b/mensa/frontends/plain-text.py @@ -12,13 +12,17 @@ class TextRenderer(IPlugin) : r = r+"*"*20+restaurant.human_name+"*"*20+"\n"#+base.formt(food) 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"+ i.price.ljust(20) + vegkeys[i.veggie]+"\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) diff --git a/mensa/logic.py b/mensa/logic.py index 75b2465..cae2421 100755 --- a/mensa/logic.py +++ b/mensa/logic.py @@ -28,9 +28,10 @@ def init_renderers(): pluginInfo.plugin_object.register_renderer() -def get_food(restlist=False, **options) : +def get_food(restlist=False, no_parallel=False,**options) : foodl = [] - if parallel : + + if parallel and not no_parallel: r = [] for k,i in base.foodsources.items() : if restlist and not i.name in restlist : |