-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.py
49 lines (42 loc) · 1.44 KB
/
example.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from zermelo.zermelo import Zermelo
import datetime
import time
import pytz
import json
Z = Zermelo('je school', 'je koppelcode', True)
eind_datum = 7
# start en eind datum ophalen
nu = datetime.date.today()
start = nu
end = start + datetime.timedelta(days=eind_datum)
start = int(time.mktime(start.timetuple()))
end = int(time.mktime(end.timetuple()))
# user
user = Z.get_user()[0]
print("Hallo {} {} welkom bij de python-zermelo-api".format(user['firstName'],user['lastName']))
# afspraken
print("afspraken:")
afspraken = Z.get_afspraken(start, end)
afspraken = sorted(afspraken, key=lambda d: d['start'])
4
startDate_old = 0
for afspraak in afspraken:
startDate = datetime.datetime.fromtimestamp(
int(afspraak['start'])
).date()
if startDate != startDate_old:
print("-----------------------")
print(afspraak['startTimeSlotName']+' '+afspraak['subjects'][0]+' in '+afspraak['locations'][0])
startDate_old = startDate
if len(afspraken) == 0:
print("Er zijn geen afspraken in de komende {} dagen".format(eind_datum))
# mededelingen
print("mededelingen:")
mededelingen = sorted(Z.get_mededelingen(), key=lambda d: d['start'])
for mededeling in mededelingen:
print("-----------------------")
print(mededeling['title']+'\n'+mededeling['text'])
if len(mededelingen) == 0:
print("Er zijn geen mededelingen")
print("status:")
print(Z.get_status())