-
Notifications
You must be signed in to change notification settings - Fork 2
/
mensaplan.py
executable file
·35 lines (30 loc) · 1.07 KB
/
mensaplan.py
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
35
#!/usr/bin/python2
# -*- coding: utf-8 -*-
import KAMensa
import datetime
## On weekends, print plan for monday
date = datetime.date.today();
if date.weekday() == 5 :
date += datetime.timedelta(2)
elif date.weekday() == 6:
date += datetime.timedelta(1)
plan = KAMensa.mensaplan()
header = KAMensa.key_to_name('moltke') + " " + str(date)
print '*'*len(header) +'\n' + header + '\n' + '*'*len(header)
for line in plan.keys('moltke'):
meal = plan.meal('moltke',line,date)
if meal != None :
# Linie
print '\n' + str(KAMensa.key_to_name(line)) + ':'
for item in meal:
if 'closing_start' not in item.keys():
if 'nodata' not in item.keys():
print '|-'+ item['meal'] + ' ' + item['dish'] + ' ' + str(item['price_1']) + u'€ ' + item['info']
else:
print "No Data"
else:
close_start = datetime.datetime.fromtimestamp(int(item['closing_start'])).strftime('%d. %m. %Y')
close_end = datetime.datetime.fromtimestamp(int(item['closing_end'])).strftime('%d. %m. %Y')
print "|- Closed from %s to %s" % (close_start,close_end)
else:
print 'No Data'