RAPLA-POC, LOGIN-Flow

This commit is contained in:
2023-11-29 11:10:01 +01:00
parent b07b25cf47
commit c373fa1428
10 changed files with 356 additions and 36 deletions

62
parseICAL.py Normal file
View File

@ -0,0 +1,62 @@
import icalendar
import datetime
import recurring_ical_events
def getWeek(weekstart: datetime, file: str, showsat: bool):
if weekstart == "today":
start_date = datetime.date.today()
else:
start_date = weekstart
start_date -= datetime.timedelta(days=start_date.weekday() % 7)
end_date = start_date + datetime.timedelta(days=7)
with open("calendars/" + file) as f:
calendar = icalendar.Calendar.from_ical(f.read())
events = recurring_ical_events.of(calendar).between(start_date, end_date)
eventl = []
for event in events:
estart = event["DTSTART"].dt
formstart = str(estart.hour) + ":" + str(estart.minute)
eend = event["DTEND"].dt
formend = str(eend.hour) + ":" + str(eend.minute)
forml = [formstart, formend]
for i in range(2):
if len(forml[i]) != 5:
if forml[i][-2] == ":":
forml[i] = forml[i] + "0"
if forml[i][1] == ":":
forml[i] = "0" + forml[i]
formstart = forml[0]
formend = forml[1]
eventdict = {
"start": formstart,
"end": formend,
"dur": str(event["DTEND"].dt - event["DTSTART"].dt)[:-3],
"name": event["SUMMARY"],
"room": event["LOCATION"],
"weekday": estart.weekday(),
"day": estart.day
}
eventl += [eventdict]
return eventl, daylist(start_date, showsat)
shortnames = ["mon", "tue", "wed", "thu", "fri", "sat"]
longnames = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]
def daylist(weekstart: datetime, showsat: bool):
weekday = weekstart
dayl = []
if showsat:
r = 6
else:
r = 5
for i in range(r):
dayl += [{
"day": weekday.day,
"short": shortnames[i],
"long": longnames[i],
}]
weekday += datetime.timedelta(days=1)
return dayl