<commit_before>from datetime import datetime, timedelta
from icalendar import Calendar, Event, vText



def to_ical(head,events,first_monday):
    '''export events into iCal format
    the file is returned as a string
    first_monday corresponds to the monday date of week 1 in Gehol
    '''
    date_init = datetime.strptime(first_monday,'%d/%m/%Y')

    cal = Calendar()
    cal.add('prodid', 'https://bitbucket.org/odebeir/geholimport')
    cal.add('version', '2.0')

    for event in events:
        n = len(event['weeks'])
        for (i,sub) in enumerate(event['weeks']):
            summary = '%s%s (%d/%d)'%(head['mnemo'],event['type'],i+1,n)
            #add offset corresponding to week numbers for each event repetition
            delta = timedelta(days=(sub-1)*7+(event['day']))
            dtstart = date_init+delta + timedelta(hours = event['start'].hour, minutes = event['start'].minute)
            dtend = date_init+delta + timedelta(hours = event['end'].hour, minutes = event['end'].minute)

            organizer = head['title']+' titulaire : '+ head['tutor']
            location = event['location']

            cal_event = Event()

            cal_event.add('summary', summary)
            cal_event.add('dtstart', dtstart)
            cal_event.add('dtend', dtend)<commit_msg>added some additional metadata to ical output<commit_after>from datetime import datetime, timedelta
from icalendar import Calendar, Event, vText



def to_ical(head,events,first_monday):
    '''export events into iCal format
    the file is returned as a string
    first_monday corresponds to the monday date of week 1 in Gehol
    '''
    date_init = datetime.strptime(first_monday,'%d/%m/%Y')

    cal = Calendar()
    cal.add('prodid', 'https://bitbucket.org/odebeir/geholimport')
    cal.add('version', '2.0')
    cal.add('summary', head['title'])
    cal.add('x-wr-calname', "%s - %s"  % (head['mnemo'], head['title']))
    cal.add('x-wr-caldesc', "%s - %s (%s)" % (head['mnemo'], head['title'], head['tutor']))

    for event in events:
        n = len(event['weeks'])
        for (i,sub) in enumerate(event['weeks']):
            summary = '%s%s (%d/%d)'%(head['mnemo'],event['type'],i+1,n)
            #add offset corresponding to week numbers for each event repetition
            delta = timedelta(days=(sub-1)*7+(event['day']))
            dtstart = date_init+delta + timedelta(hours = event['start'].hour,
                                                  minutes = event['start'].minute)
            dtend = date_init+delta + timedelta(hours = event['end'].hour,
                                                minutes = event['end'].minute)

            organizer = head['title']+' titulaire : '+ head['tutor']
            location = event['location']

            cal_event = Event()

            cal_event.add('summary', summary)
            cal_event.add('dtstart', dtstart)
            cal_event.add('dtend', dtend)
{'fraction_non_alphanumeric': 0.1526405451448041, 'fraction_numerical': 0.0040885860306643955, 'mean_word_length': 2.6930817610062894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '346326', 'n_tokens_mistral': 901, 'n_tokens_neox': 850, 'n_words': 209}