diff options
Diffstat (limited to 'build.py')
-rw-r--r-- | build.py | 44 |
1 files changed, 24 insertions, 20 deletions
@@ -56,22 +56,25 @@ with open(org_fp, "r") as org: events.append(Event(line)) -url = "https://outlook.office365.com/owa/calendar/db2d3e0f0490459a80c4b837118e4bf1@wisc.edu/f6a2b5209cd6432c96f52939cacdbedd2266851683387467601/calendar.ics" -subprocess.run(["curl", url, "-o", "/home/nginx/pycal2org/uw-madison.ics"]) -proc = subprocess.Popen(["python3", "/home/nginx/pycal2org/pycal2org.py", "/home/nginx/pycal2org/uw-madison.ics", ">", "/home/nginx/pycal2org/uw-madison.org"]) -org = proc.stdout.read() -for line in org: - line = line.strip() - if not line: - continue - if not line[0] == "*": - continue - if ":private:" in line: - continue - if ":info:" in line: - continue - events.append(Event(line)) +subprocess.run(["python3", "/home/nginx/agenda/uw_madison_ics.py"]) + +org_fp = "/home/nginx/org/uw-madison.org" + +events = [] + +with open(org_fp, "r") as org: + for line in org: + line = line.strip() + if not line: + continue + if not line[0] == "*": + continue + if ":private:" in line: + continue + if ":info:" in line: + continue + events.append(Event(line)) # create html ------------------------------------------------------------------------------------- @@ -117,14 +120,15 @@ with open(__here__ / "public" / "index.html", "w") as html: f"<h3 id={id}><a href=#{id}>{day.isoformat()} {day.strftime('%A')}</a></h3>" ) for event in events: - if event.end: + try: + total = event.end - event.timestamp + assert total.days > 0 + elapsed = total - (event.end - day) if event.timestamp <= day and event.end >= day: - total = event.end - event.timestamp - elapsed = total - (event.end - day) - html.write( + html.write( f"(day {elapsed.days+1}/{total.days+1}) {event.description}<br>" ) - else: + except: if event.timestamp == day: html.write(f"{event.description}<br>") # increment |