add to git
This commit is contained in:
commit
2956a715e3
5 changed files with 91 additions and 0 deletions
23
parse_json.py
Normal file
23
parse_json.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from json import load
|
||||
from datetime import time, datetime
|
||||
from ical.calendar import Calendar
|
||||
from ical.event import Event
|
||||
from ical.calendar_stream import IcsCalendarStream
|
||||
|
||||
calendar = Calendar()
|
||||
CLASS = "tech"
|
||||
|
||||
CLASS_START = time(hour=10, minute=52)
|
||||
CLASS_END = time(hour=12, minute=7)
|
||||
|
||||
for key, value in load(open(f"{CLASS}.json")).items():
|
||||
value = value.strip()
|
||||
if value.lower() == "pa day" or value.lower() == "pd day" or "break" in value.lower():
|
||||
continue
|
||||
day = datetime.strptime(key, "%Y %B %d").date()
|
||||
calendar.events.append(
|
||||
Event(summary=value.title(), start=datetime.combine(day, CLASS_START), end=datetime.combine(day, CLASS_END))
|
||||
)
|
||||
|
||||
with open(f"{CLASS}.ics", "w") as ics_file:
|
||||
ics_file.write(IcsCalendarStream.calendar_to_ics(calendar))
|
Loading…
Add table
Add a link
Reference in a new issue