Last active
October 16, 2017 20:29
-
-
Save tomconte/4aa2d9e24d7f009b6f4abe7854934a74 to your computer and use it in GitHub Desktop.
Corrige le calendrier ICS exporté depuis le module emploi du temps de Educ-Horus.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
# Corrige le calendrier EducHorus en recopiant le champ DESCRIPTION | |
# dans le champ SUMMARY pour que les matières apparaissent dans les | |
# intitulés des évènements. | |
# Corrige également le fuseau horaire en Europe/Paris. | |
from dateutil.tz import gettz | |
from ics import Calendar | |
cal_file = 'ehorus.ics' | |
f = open(cal_file, 'r') | |
cal_text = f.read() | |
f.close() | |
cal = Calendar(cal_text) | |
for e in cal.events: | |
# Description | |
new_name = e.description.split(' : ')[1] | |
e.name = new_name | |
# Fuseau horaire | |
e.created.tzinfo = gettz('Europe/Paris') | |
e.begin.tzinfo = gettz('Europe/Paris') | |
e.end.tzinfo = gettz('Europe/Paris') | |
with open('fixed_'+cal_file, 'w') as f: | |
f.writelines(cal) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment