aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/mathemensa.py29
-rw-r--r--backends/satyam.py2
-rw-r--r--backends/singh.py4
-rw-r--r--backends/studentenwerk.py6
4 files changed, 24 insertions, 17 deletions
diff --git a/backends/mathemensa.py b/backends/mathemensa.py
index b98ab1d..ea0cf72 100644
--- a/backends/mathemensa.py
+++ b/backends/mathemensa.py
@@ -16,7 +16,8 @@ class Mathemensa(IPlugin) :
r = Restaurant("Mathemensa", "Mathemensa", self, "dummy")
register_restaurant(r)
- def get_food_items(self) :
+ def get_food_items(self, **kwargs) :
+ weekdays = ["MONTAG", "DIENSTAG", "MITTWOCH", "DONNERSTAG", "FREITAG"]
weekday = datetime.datetime.today().weekday()
if weekday > 4 :
print("Error: No food today")
@@ -30,15 +31,19 @@ class Mathemensa(IPlugin) :
document = html5lib.parse(the_page, treebuilder="lxml")
sel = CSSSelector('.Menu__accordion')
fl = []
- for k in sel(document)[0][weekday] :
- if k.tag.endswith("ul") :
- for j in k :
- price = j[1].text
- st = str(etree.tostring(j)).split("\\n")[2].split("<")[0]
- name = j[0].text + ", " + etree.fromstring("<p>%s</p>"%st).text.strip() # really extremely dirty hack
- veg = 0
-
- if "(v)" in name or "Gemüseplatte" in name :
- veg = 1
- fl.append(Food(name, price, "Menü", veg))
+ for i in sel(document)[0] :
+ h2sel = CSSSelector('h2')
+ if not weekdays[weekday] in i[0].text.upper() :
+ continue
+ for k in i :
+ if k.tag.endswith("ul") :
+ for j in k :
+ price = j[1].text
+ st = str(etree.tostring(j)).split("\\n")[2].split("<")[0]
+ name = j[0].text + ", " + etree.fromstring("<p>%s</p>"%st).text.strip() # really extremely dirty hack
+ veg = 0
+
+ if "(v)" in name or "Gemüseplatte" in name :
+ veg = 1
+ fl.append(Food(name, price, "Menü", veg))
return fl
diff --git a/backends/satyam.py b/backends/satyam.py
index a20d6bb..ec488f3 100644
--- a/backends/satyam.py
+++ b/backends/satyam.py
@@ -11,7 +11,7 @@ class Satyam(IPlugin):
def register_restaurants(self) :
r = Restaurant("Satyam", "Satyam", self, "dummy")
register_restaurant(r)
- def get_food_items(self) :
+ def get_food_items(self, **kwargs) :
s = sys.stderr
sys.stderr = open("/dev/null", "w")
user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'
diff --git a/backends/singh.py b/backends/singh.py
index a3b3119..ae8b291 100644
--- a/backends/singh.py
+++ b/backends/singh.py
@@ -12,7 +12,8 @@ class Signh(IPlugin) :
def register_restaurants(self) :
r = Restaurant("Singh", "Mathe-Café", self, "dummy")
register_restaurant(r)
- def get_food_items(self) :
+ def get_food_items(self, **kwargs) :
+ s = sys.stderr
sys.stderr = open("/dev/null", "w")
weekday = datetime.datetime.today().weekday()
if weekday > 4 :
@@ -46,6 +47,7 @@ class Signh(IPlugin) :
elif "VEGAN" in vegsel(k)[0].text :
veg = 2
fl.append(Food(name, price, "Essen", veg, desc))
+ sys.stderr = s
return fl
if __name__ == "__main__":
diff --git a/backends/studentenwerk.py b/backends/studentenwerk.py
index ce6d2fd..48b15d3 100644
--- a/backends/studentenwerk.py
+++ b/backends/studentenwerk.py
@@ -12,7 +12,7 @@ import multiprocessing
from yapsy import NormalizePluginNameForModuleName as normalize
-mensenliste = {"TU Hardenberg" : "mensa-tu-hardenbergstra%C3%9Fe", "TU Marchstraße": "cafeteria-tu-marchstra%C3%9Fe", "TU Skyline": "cafeteria-tu-skyline", "TU Architektur": "cafeteria-tu-architektur", "TU Ackerstraße": "cafeteria-tu-ackerstra%C3%9Fe"}
+mensenliste = {"TU Hardenbergstraße" : "mensa-tu-hardenbergstra%C3%9Fe", "TU Marchstraße": "cafeteria-tu-marchstra%C3%9Fe", "TU Skyline": "cafeteria-tu-skyline", "TU Architektur": "cafeteria-tu-architektur", "TU Ackerstraße": "cafeteria-tu-ackerstra%C3%9Fe"}
@@ -23,7 +23,7 @@ def pr_f(j) :
class Studentenwerk(IPlugin) :
def register_restaurants (self) :
- mensenliste = {"TU Hardenberg" : "mensa-tu-hardenbergstra%C3%9Fe", "TU Marchstraße": "cafeteria-tu-marchstra%C3%9Fe", "TU Skyline": "cafeteria-tu-skyline", "TU Architektur": "cafeteria-tu-architektur", "TU Ackerstraße": "cafeteria-tu-ackerstra%C3%9Fe"}
+ mensenliste = {"TU Hardenbergstraße" : "mensa-tu-hardenbergstra%C3%9Fe", "TU Marchstraße": "cafeteria-tu-marchstra%C3%9Fe", "TU Skyline": "cafeteria-tu-skyline", "TU Architektur": "cafeteria-tu-architektur", "TU Ackerstraße": "cafeteria-tu-ackerstra%C3%9Fe"}
for h,n in mensenliste.items() :
r = Restaurant(normalize(h), h, self, "dummy", [n])
register_restaurant(r)
@@ -48,7 +48,7 @@ class Studentenwerk(IPlugin) :
for m in meals :
namesel = CSSSelector('.bold')
nm = namesel(m)[0].text
- if ignore_nudelauswahl and "Nudelauswahl" in nm:
+ if ignore_nudelauswahl and "Nudelauswahl" in nm :
continue
pricesel = CSSSelector('.col-md-3')
veg = 0