Added RU menu scripts
This commit is contained in:
parent
f586c10dd2
commit
4ebdbe3863
3 changed files with 41 additions and 0 deletions
36
menu/handler.py
Normal file
36
menu/handler.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import json
|
||||
from datetime import date, datetime
|
||||
|
||||
FILE = 'menu_data.json'
|
||||
|
||||
|
||||
def string_to_date(date_string):
|
||||
datetime_object = datetime.strptime(date_string, '%Y-%m-%d')
|
||||
return datetime_object.date()
|
||||
|
||||
|
||||
def get_cleaned_data():
|
||||
with open(FILE) as f:
|
||||
data = json.load(f)
|
||||
indexes_to_delete = []
|
||||
for i in range(0, len(data)):
|
||||
current_date = string_to_date(data[i]['date'])
|
||||
if current_date < date.today():
|
||||
indexes_to_delete.append(i)
|
||||
print('Indexes to delete:')
|
||||
print(indexes_to_delete)
|
||||
for i in indexes_to_delete:
|
||||
del data[i]
|
||||
return data
|
||||
|
||||
|
||||
def write_cleaned_data(data):
|
||||
with open(FILE, 'w') as f:
|
||||
json.dump(data, f)
|
||||
|
||||
|
||||
def main():
|
||||
write_cleaned_data(get_cleaned_data())
|
||||
print('DONE')
|
||||
|
||||
main()
|
1
menu/menu_data.json
Normal file
1
menu/menu_data.json
Normal file
|
@ -0,0 +1 @@
|
|||
[{"restaurant_id": 0, "meal": [{"name": "midi", "foodcategory": [{"name": "Entr\u00e9es", "dishes": [{"name": "POTAGE TOMATE VERMICELLE"}, {"name": "PAMPLEMOUSSE"}, {"name": "POIREAUX"}, {"name": "OEUF MAYONNAISE"}, {"name": "MACEDOINE/TOMATE"}, {"name": "HARICOT VERT/TOMATE"}, {"name": "FEUILLETE FROMAGE"}, {"name": "BETTERAVE/MAIS"}, {"name": "AVOCAT"}]}, {"name": "Plats du jour", "dishes": [{"name": "VEG TORTIS PLEUROTTES"}, {"name": "VEG PROTEINE GALETTE BETTERAVE"}, {"name": "VEG PAELLA VERTE"}, {"name": ""}, {"name": "PUREE POIS CASSES"}, {"name": "PATE SPAGHETTI"}, {"name": "CAROTTE VICHY"}]}, {"name": "P\u00e2tes, Grillades, V\u00e9g\u00e9tariens", "dishes": [{"name": "menu non communiqu\u00e9"}]}, {"name": "Desserts", "dishes": [{"name": "FRUITS"}, {"name": "YAOURTS"}, {"name": "FROMAGE"}, {"name": "PATISSERIES"}]}]}], "id": 693388, "date": "2020-03-16"}, {"restaurant_id": 0, "meal": [{"name": "midi", "foodcategory": [{"name": "Entr\u00e9es", "dishes": [{"name": "SALAMI"}, {"name": "SALADE BEAUCAIRE"}, {"name": "RIZ EXOTIQUE"}, {"name": "RADIS NOIR RAPE"}, {"name": "QUICHE LORRAINE"}, {"name": "POTAGE LEGUME MAISON"}, {"name": "HARICOTS BLANCS"}, {"name": "ENDIVES AUX NOIX"}, {"name": "COURGETTE RAPEE AU CUMIN"}]}, {"name": "Plats du jour", "dishes": [{"name": "CUISSE POULET"}, {"name": "OMELETTE POMME DE TERRE"}, {"name": "FILET DE LIEU"}, {"name": ""}, {"name": "POMME RISSOLEE"}, {"name": "HARICOT VERT PERSILLE"}]}, {"name": "P\u00e2tes, Grillades, V\u00e9g\u00e9tariens", "dishes": [{"name": "PATES COQUILLETTE CARBONARA"}, {"name": ""}, {"name": "STEAK HACHE"}, {"name": "FAUX FILET"}, {"name": "FILET DE LIEU"}, {"name": ""}, {"name": "FRITES"}, {"name": ""}, {"name": "VEG RISOTTO POTIRON ROMA"}]}, {"name": "Desserts", "dishes": [{"name": "FRUITS"}, {"name": "YAOURTS"}, {"name": "FROMAGE"}, {"name": "PATISSERIES"}]}]}], "id": 693389, "date": "2020-03-17"}, {"restaurant_id": 0, "meal": [{"name": "midi", "foodcategory": [{"name": "Entr\u00e9es", "dishes": [{"name": "TOMATE MOZZARELLA"}, {"name": "SURIMI"}, {"name": "SAUCISSON A L'AIL"}, {"name": "SALADE COLESLAW"}, {"name": "SOUPE DE POTIRON"}, {"name": "OEUF ROUILLE"}, {"name": "HARICOTS BLANCS"}, {"name": "FRIAND FROMAGE"}, {"name": "BETTERAVE RAPEE"}]}, {"name": "Plats du jour", "dishes": [{"name": "PALERON BRAISE"}, {"name": "ENCORNET A L'AMERICAINE"}, {"name": ""}, {"name": "SALSIFIS PORTUGAISE"}, {"name": "PATE MACARONIS"}]}, {"name": "P\u00e2tes, Grillades, V\u00e9g\u00e9tariens", "dishes": [{"name": "PATES PENNE RIGATE CAMPAGNARDE"}, {"name": ""}, {"name": "ESCALOPE DE POULET"}, {"name": "BAVETTE"}, {"name": "FILET DE CABILLAUD"}, {"name": ""}, {"name": "FRITES"}, {"name": ""}, {"name": "VEG GALETTE DE QUINOA"}]}, {"name": "Desserts", "dishes": [{"name": "FRUITS"}, {"name": "YAOURTS"}, {"name": "FROMAGE"}, {"name": "PATISSERIES"}]}]}], "id": 693395, "date": "2020-03-18"}, {"restaurant_id": 0, "meal": [{"name": "midi", "foodcategory": [{"name": "Entr\u00e9es", "dishes": [{"name": "SARDINE"}, {"name": "SALADE DE LENTILLE"}, {"name": "SALADE DE PATE"}, {"name": "RILLETTE"}, {"name": "SOUPE A L'OIGNON"}, {"name": "PIZZA"}, {"name": "CELERI RAVE"}, {"name": "CAROTTE RAPEE"}]}, {"name": "Plats du jour", "dishes": [{"name": "SAUCISSE DE PORC"}, {"name": "CASSOULET"}, {"name": "CROUSTADE DE LA MER"}, {"name": ""}, {"name": "BLE"}, {"name": "PANACHE DE LEGUMES"}]}, {"name": "P\u00e2tes, Grillades, V\u00e9g\u00e9tariens", "dishes": [{"name": "PATES TORTI INDIENNE"}, {"name": ""}, {"name": "STEAK HACHE"}, {"name": "BAVETTE"}, {"name": "FILET DE HOKI"}, {"name": ""}, {"name": "FRITES"}, {"name": ""}, {"name": "VEG KOCHARI"}]}, {"name": "Desserts", "dishes": [{"name": "FRUITS"}, {"name": "YAOURTS"}, {"name": "FROMAGE"}, {"name": "PATISSERIES"}]}]}], "id": 693396, "date": "2020-03-19"}, {"restaurant_id": 0, "meal": [{"name": "midi", "foodcategory": [{"name": "Entr\u00e9es", "dishes": [{"name": "TARTE MEDITERANEENE"}, {"name": "TABOULE INDIENNE"}, {"name": "SOUPE DE POISSON"}, {"name": "OEUF MAYONNAISE"}, {"name": "MAQUEREAU VIN BLANC"}, {"name": "CONCOMBRE YAOURT"}, {"name": "CHORIZO"}, {"name": "BETTERAVE/POMME"}]}, {"name": "Plats du jour", "dishes": [{"name": "COTE DE PORC"}, {"name": "PIZZA VEGETARIENNE"}, {"name": "CHOU FARCI"}, {"name": ""}, {"name": "RIZ PILAFF"}, {"name": "ENDIVE AU GRATIN"}]}, {"name": "P\u00e2tes, Grillades, V\u00e9g\u00e9tariens", "dishes": [{"name": "PATES MILANAISE"}, {"name": ""}, {"name": "STEAK HACHE"}, {"name": "STEAK DE THON"}, {"name": "BAVETTE"}, {"name": ""}, {"name": "FRITES"}, {"name": ""}, {"name": "VEG LASAGE EPINARD BREBIS"}]}, {"name": "Desserts", "dishes": [{"name": "FRUITS"}, {"name": "YAOURTS"}, {"name": "FROMAGE"}, {"name": "PATISSERIES"}]}]}], "id": 693397, "date": "2020-03-20"}]
|
4
menu/menu_update.sh
Executable file
4
menu/menu_update.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#/bin/bash!
|
||||
touch lock
|
||||
curl "https://webservices-v2.crous-mobile.fr/ws/v1/regions/5/restaurants/114/menus" > menu_data.json && python3 handler.py
|
||||
rm lock
|
Loading…
Reference in a new issue