|
@@ -40,10 +40,10 @@ unordered = []
|
40
|
40
|
l = time.localtime()
|
41
|
41
|
this_week = datetime.datetime.now().isocalendar()[1]
|
42
|
42
|
|
43
|
|
-unordered += amica.get_restaurants(use_old)
|
44
|
|
-unordered += juvenes.get_restaurants(use_old)
|
45
|
|
-unordered += sodexo.get_restaurants(use_old)
|
46
|
|
-unordered += pikante.get_restaurants(use_old)
|
|
43
|
+unordered += amica.get_restaurants(use_old, this_week)
|
|
44
|
+unordered += juvenes.get_restaurants(use_old, this_week)
|
|
45
|
+unordered += sodexo.get_restaurants(use_old, this_week)
|
|
46
|
+unordered += pikante.get_restaurants(use_old, this_week)
|
47
|
47
|
|
48
|
48
|
print(unordered)
|
49
|
49
|
|
|
@@ -103,7 +103,6 @@ file_footer = """
|
103
|
103
|
</body>
|
104
|
104
|
</html>
|
105
|
105
|
""".format(stamp=time.strftime("%d.%m.%Y %H:%M:%S"))
|
106
|
|
-print(file_footer)
|
107
|
106
|
|
108
|
107
|
def find_last_day_with_foods(restaurants):
|
109
|
108
|
last_day = 0
|
|
@@ -152,7 +151,7 @@ def write_day(day, header, outfname, last_day, restaurants, prefix, resources_pr
|
152
|
151
|
with open(outfname, "w", encoding="utf-8") as fout:
|
153
|
152
|
import types
|
154
|
153
|
def write(self, writable):
|
155
|
|
- print("Writing {}: {}".format(type(writable), writable))
|
|
154
|
+ #print("Writing {}: {}".format(type(writable), writable))
|
156
|
155
|
self.write_orig(writable)
|
157
|
156
|
fout.write_orig = fout.write
|
158
|
157
|
fout.write = types.MethodType(write, fout)
|
|
@@ -221,7 +220,7 @@ def write_day(day, header, outfname, last_day, restaurants, prefix, resources_pr
|
221
|
220
|
part_count += 1
|
222
|
221
|
|
223
|
222
|
# add missing () around allergies
|
224
|
|
- part = re.sub(" (([MLGK]|VL|Ve|Veg|Hot)(,([MLGK]|VL|Ve|Veg|Hot|))+)$", " (\\1)", part)
|
|
223
|
+ part = re.sub(" (([MLGKA]|VL|Ve|VE|Veg|Hot)(, *([MLGKA]|VL|Ve|VE|Veg|Hot|))+)$", " (\\1)", part)
|
225
|
224
|
match = re.match("^(.*) \\(([^\\)]+)\\)$", part)
|
226
|
225
|
if match:
|
227
|
226
|
# fix allergy issues
|
|
@@ -306,8 +305,8 @@ def write_day(day, header, outfname, last_day, restaurants, prefix, resources_pr
|
306
|
305
|
fout.write("eatable_foods[\"{a}\"] = [{eatable_food_number}];\n".format(a=a, eatable_food_number=",".join(str(e) for e in eatable_food_numbers[a])))
|
307
|
306
|
fout.write("maybe_eatable_foods[\"{a}\"] = [{maybe_eatable_food_number}];\n".format(a=a, maybe_eatable_food_number=",".join(str(e) for e in maybe_eatable_food_numbers[a])))
|
308
|
307
|
allergy_string = ",".join('"{a}"'.format(a=a) for a in allergies)
|
309
|
|
- fout.write("var allergies = {allergies}];\n".format(allergies = allergy_string))
|
310
|
|
- fout.write("var food_count = $foodnum;\n")
|
|
308
|
+ fout.write("var allergies = [{allergies}];\n".format(allergies = allergy_string))
|
|
309
|
+ fout.write("var food_count = {foodnum};\n".format(foodnum = foodnum))
|
311
|
310
|
fout.write("window.onload = function() { set_allergies(); show_warning(); };\n")
|
312
|
311
|
fout.write("</script>\n")
|
313
|
312
|
fout.write("</div></div>{file_footer}".format(file_footer=file_footer.format(resources_prefix=resources_prefix)))
|
|
@@ -333,9 +332,10 @@ def write_all_days(restaurants, prefix, title, resources_prefix):
|
333
|
332
|
def write_table(restaurants, prefix, title, resources_prefix):
|
334
|
333
|
last_day = find_last_day_with_foods(restaurants);
|
335
|
334
|
outfname = "{prefix}table.html".format(prefix=prefix)
|
336
|
|
- with open(outfname, "w") as fout:
|
|
335
|
+ with open(outfname, "w", encoding="utf-8") as fout:
|
337
|
336
|
header = "{title} vko {max_week}{max_week_daterange}".format(title=title, max_week=max_week, max_week_daterange=max_week_daterange)
|
338
|
|
- fout.write("{file_header}<h1>{header}</h1>\n".format(file_header=file_header, header=header))
|
|
337
|
+ fout.write(file_header.format(resources_prefix=resources_prefix))
|
|
338
|
+ fout.write("<h1>{header}</h1>\n".format(header=header))
|
339
|
339
|
fout.write("<div class=\"title\">\n")
|
340
|
340
|
|
341
|
341
|
write_days_header(fout, -1, last_day)
|
|
@@ -345,7 +345,7 @@ def write_table(restaurants, prefix, title, resources_prefix):
|
345
|
345
|
(title, open_hours, week, week_foods, info) = r
|
346
|
346
|
(title2, url) = info[0:2]
|
347
|
347
|
url = re.sub("&", " ", url)
|
348
|
|
- fout.write("<th><a href=\"{url}\">{title}</a></th>")
|
|
348
|
+ fout.write("<th><a href=\"{url}\">{title}</a></th>".format(url=url, title=title))
|
349
|
349
|
fout.write("</tr>\n")
|
350
|
350
|
for day in range(last_day):
|
351
|
351
|
fout.write("<tr><td>{day_name}</td>\n".format(day_name=day_names[day]))
|