# HG changeset patch # User Paul Boddie # Date 1505759781 -7200 # Node ID 0fff3a8647bc49af7e49026a22cc93b87e61d0ac # Parent 7819b77d9330ef54bbe0ccb6129cc64817095aa6 Added a convenience function for parsing a calendar file. diff -r 7819b77d9330 -r 0fff3a8647bc imiptools/data.py --- a/imiptools/data.py Fri Sep 15 00:03:38 2017 +0200 +++ b/imiptools/data.py Mon Sep 18 20:36:21 2017 +0200 @@ -658,6 +658,23 @@ return ("VFREEBUSY", {}, record) +def parse_calendar(f, encoding): + + """ + Parse the iTIP content from 'f' having the given 'encoding'. Return a + mapping from object types to collections of calendar objects. + """ + + cal = parse_object(f, encoding, "VCALENDAR") + d = {} + + for objtype, values in cal.items(): + d[objtype] = l = [] + for value in values: + l.append(Object({objtype : value})) + + return d + def parse_object(f, encoding, objtype=None): """