Skip to content

Instantly share code, notes, and snippets.

@sielicki
Last active December 21, 2018 09:24
Show Gist options
  • Save sielicki/9c1639da8d5142d98762fe55f89d8677 to your computer and use it in GitHub Desktop.
Save sielicki/9c1639da8d5142d98762fe55f89d8677 to your computer and use it in GitHub Desktop.
{"last_check":"2018-06-08T00:22:24Z","pypi_version":"10.0.1"}
home = /usr/bin
include-system-site-packages = false
version = 3.6.5
arrow==0.4.2
cssselect==1.0.3
ics==0.4
lxml==4.2.5
pkg-resources==0.0.0
python-dateutil==2.7.3
six==1.11.0
#!/usr/bin/env python3
import urllib.request, ics, lxml.etree, arrow
from lxml.cssselect import CSSSelector
from dateutil import parser
def gencal():
url = "https://registrar.wisc.edu/dates/"
sel = CSSSelector(".tribe-event-date-start , .tribe-events-list-event-title")
htmlparser = lxml.etree.HTMLParser()
response = urllib.request.urlopen(url)
print("Grabbed calendar from: {}".format(url))
tree = lxml.etree.parse(response, htmlparser)
selected = sel(tree)
tuples = zip(*[iter(selected)] * 2)
cal = ics.Calendar()
print("Parsing events")
for tup in tuples:
name, date = tup
new_event = ics.Event()
new_event.name = name.text
new_event.begin = arrow.get(parser.parse(date.text))
new_event.make_all_day()
cal.events.add(new_event)
print("Found {} events".format(len(cal.events)))
print("Writing calendar to uwmadison.ics")
with open('uwmadison.ics', 'w') as output:
output.writelines(cal)
print("Wrote calendar to uwmadison.ics")
if __name__ == '__main__':
gencal()
BEGIN:VCALENDAR
PRODID:ics.py - http://git.io/lLljaA
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181212
SUMMARY:Last Fall 2018 class day
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190201
SUMMARY:Deadline for students to add\, swap\, or change sections in a Spring term class (after: need department permission)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190215
SUMMARY:Deadline for students (except Graduate) to request pass/fail or credit/audit options for a Spring term class
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180905
SUMMARY:Instruction for Fall 2018 begins
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190313
SUMMARY:Schedule of Classes released for Fall 2019
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180914
SUMMARY:Deadline for students to add\, swap\, or change sections in a Fall term class (after: need department permission)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180912
SUMMARY:Deadline for students to drop a Fall term class and have no record of it on transcript (after: will show as DR)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180928
SUMMARY:Deadline for students (except Graduate) to request pass/fail or credit/audit options for a Fall term class
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190122
SUMMARY:Instruction for Spring 2019 begins
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181112
SUMMARY:Students begin enrolling for Spring term classes according to their appointment times
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190130
SUMMARY:Deadline for students to drop a Spring term class and have no record of it on transcript (after: will show as DR)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190329
SUMMARY:Deadline for students to add a Spring term class with department permission (after: need academic dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190516
SUMMARY:Deadline for instructors to submit Spring term final grades by 11:59 pm
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190325
SUMMARY:Enrollment appointment times for Summer term assigned to students this week
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190512
SUMMARY:Official degree conferral date on diploma for students graduating at the end of Spring term 2019
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190503
SUMMARY:Last Spring 2019 class day
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181102
SUMMARY:Deadline for students to add a Fall term class with department permission (after: need academic dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180904
SUMMARY:Deadline for students to cancel Fall enrollment and have no Fall term record on transcript
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190201
SUMMARY:Deadline for students to drop a Spring term class and receive 100% tuition adjustment
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190215
SUMMARY:Deadline for students to drop a Spring term class and receive 50% tuition adjustment
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190329
SUMMARY:Deadline for Graduate students to request pass/fail or credit/audit options for a Spring term class
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180928
SUMMARY:Deadline for students to drop a Fall term class and receive 50% tuition adjustment
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190401
SUMMARY:Students begin enrolling for Summer term classes according to their appointment times
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181223
SUMMARY:Official degree conferral date on diploma for students graduating at the end of Fall term 2018
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180914
SUMMARY:Deadline for students to begin initial Fall enrollment (after: $50 late fee\, need dept. & academic dean permission)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190215
SUMMARY:Deadline for students (except Graduate) to change variable credits (after: need instructor permission & dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181212
SUMMARY:Deadline for Graduate students to withdraw from the Fall term
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181102
SUMMARY:Deadline for Graduate students to drop a Fall term class (after: need instructor\, advisor\, & academic dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190125
SUMMARY:Deadline for students (except Special and Guest) to begin initial Spring term enrollment without $50 late fee
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181123
SUMMARY:Deadline for students to change Honors Optional class status (after: need instructor permission & academic dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190503
SUMMARY:Deadline for Graduate students to withdraw from the Spring term
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180914
SUMMARY:Deadline for students to drop a Fall term class and receive 100% tuition adjustment
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190121
SUMMARY:Deadline for students to cancel Spring enrollment and have no Spring term record on transcript
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181102
SUMMARY:Deadline for Graduate students to change variable credits (after: need instructor permission & dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190401
SUMMARY:Enrollment appointment times for Fall term assigned to students this week
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180907
SUMMARY:Deadline for students (except Special and Guest) to begin initial Fall term enrollment without $50 late fee
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181226
SUMMARY:Deadline for instructors to submit Fall term final grades by 11:59 pm
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190329
SUMMARY:Deadline for Graduate students to drop a Spring term class (after: need instructor\, advisor\, & academic dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181123
SUMMARY:Deadline for students (except Graduate) to withdraw from Fall term
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190329
SUMMARY:Deadline for students (except Graduate) to drop a Spring term class (after: need academic dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190329
SUMMARY:Deadline for Graduate students to change variable credits (after: need instructor permission & dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180928
SUMMARY:Deadline for students (except Graduate) to change variable credits (after: need instructor permission & dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190419
SUMMARY:Deadline for students (except Graduate) to withdraw from Spring term
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20180723
SUMMARY:Preferred date for students enrolled in a class with an eText textbook to request opting out of purchase
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190408
SUMMARY:Students begin enrolling for Fall term classes according to their appointment times
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181105
SUMMARY:Enrollment appointment times for Spring term assigned to students this week
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190201
SUMMARY:Deadline for students to begin initial Spring enrollment (after: $50 late fee\, need dept. & academic dean permission)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181102
SUMMARY:Deadline for students (except Graduate) to drop a Fall term class (after: need academic dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20181102
SUMMARY:Deadline for Graduate students to request pass/fail or credit/audit options for a Fall term class
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20181221T092322Z
DTSTART;VALUE=DATE:20190419
SUMMARY:Deadline for students to change Honors Optional class status (after: need instructor permission & academic dean approval)
TRANSP:OPAQUE
UID:[email protected]
END:VEVENT
END:VCALENDAR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment