def parse_ics(icsfile):
    """Takes an icsfilename, parses it, and returns Events."""
    events = []

    cal = Calendar.from_ical(open(icsfile, 'rb').read())
    for component in cal.walk('vevent'):
        dtstart = component['dtstart'].dt
        rrule = component['rrule']

        freq, args = convert_rrule(rrule)
        args['dtstart'] = dtstart

        rrule = dateutil.rrule.rrule(freq, **args)

        summary = vText.from_ical(component.get('summary', u''))
        description = vText.from_ical(component.get('description', u''))
        organizer = vText.from_ical(component.get('organizer', u''))

        # TODO: Find an event id.  If it's not there, then compose one
        # with dtstart, summary, and organizer.
        event_id = "::".join((str(dtstart), summary, organizer))

        events.append(Event(event_id, rrule, summary, description))
    return events
def parse_ics ( icsfile ) : events = [ ] cal = Calendar . from_ical ( open ( icsfile , 'rb' ) . read ( ) ) for component in cal . walk ( 'vevent' ) : dtstart = component [ 'dtstart' ] . dt rrule = component [ 'rrule' ] freq , args = convert_rrule ( rrule ) args [ 'dtstart' ] = dtstart rrule = dateutil . rrule . rrule ( freq , ** args ) summary = vText . from_ical ( component . get ( 'summary' , u'' ) ) description = vText . from_ical ( component . get ( 'description' , u'' ) ) organizer = vText . from_ical ( component . get ( 'organizer' , u'' ) ) event_id = "::" . join ( ( str ( dtstart ) , summary , organizer ) ) events . append ( Event ( event_id , rrule , summary , description ) ) return events
Takes an icsfilename, parses it, and returns Events.