Skip to content

Instantly share code, notes, and snippets.

@tomconte
Last active October 16, 2017 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomconte/4aa2d9e24d7f009b6f4abe7854934a74 to your computer and use it in GitHub Desktop.
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.
#!/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