<commit_before>#! /usr/bin/env python

from icalendar import Calendar
from dateutil import tz
from datetime import datetime
import sys
import StringIO
import re

r_atendee = re.compile(r'mailto:', re.IGNORECASE)
def format_atendee(a):
    return r_atendee.sub('', a)

def main():
    cal = sys.stdin.read()
    tmpfile = StringIO.StringIO()
    tmpfile.write(cal)
    tmpfile.seek(0)
    tzical = tz.tzical(tmpfile)
    try:
        icaltz = tzical.get()
    except ValueError:
        # No Timezone in iCal, assume UTC?
        icaltz = tz.tzutc()
    cal = Calendar.from_ical(cal)
    for e in cal.walk('VEVENT'):
#        print e
#        print "--------"
        start = e['dtstart'].dt.replace(tzinfo=icaltz).astimezone(tz.tzlocal())
        end = e['dtend'].dt.replace(tzinfo=icaltz).astimezone(tz.tzlocal())
        print  'Event: %s' % e['summary'].encode('UTF-8')
        print  'Start: %s' % start.strftime('%a, %Y-%m-%d %H:%M %Z')
        print  'End:   %s' % end.strftime('%a, %Y-%m-%d %H:%M %Z')
        print  'Organizer: %s' % format_atendee(e['organizer'])
        print  'Status: %s' % e['status']
        print  'Location: %s' % e['location'].encode('UTF-8')
        if 'attendee' in e:
            print 'Atendee(s):'
            for a in e['attendee']:
                print " %s" % format_atendee(a)
        print '\n%s' % e['description'].encode('UTF-8')

if __name__ == "__main__":<commit_msg>Make location optional<commit_after>#! /usr/bin/env python

from icalendar import Calendar
from dateutil import tz
from datetime import datetime
import sys
import StringIO
import re

r_atendee = re.compile(r'mailto:', re.IGNORECASE)
def format_atendee(a):
    return r_atendee.sub('', a)

def main():
    cal = sys.stdin.read()
    tmpfile = StringIO.StringIO()
    tmpfile.write(cal)
    tmpfile.seek(0)
    tzical = tz.tzical(tmpfile)
    try:
        icaltz = tzical.get()
    except ValueError:
        # No Timezone in iCal, assume UTC?
        icaltz = tz.tzutc()
    cal = Calendar.from_ical(cal)
    for e in cal.walk('VEVENT'):
#        print e
#        print "--------"
        start = e['dtstart'].dt.replace(tzinfo=icaltz).astimezone(tz.tzlocal())
        end = e['dtend'].dt.replace(tzinfo=icaltz).astimezone(tz.tzlocal())
        print  'Event: %s' % e['summary'].encode('UTF-8')
        print  'Start: %s' % start.strftime('%a, %Y-%m-%d %H:%M %Z')
        print  'End:   %s' % end.strftime('%a, %Y-%m-%d %H:%M %Z')
        print  'Organizer: %s' % format_atendee(e['organizer'])
        print  'Status: %s' % e['status']
        if 'location' in e:
            print  'Location: %s' % e['location'].encode('UTF-8')
        if 'attendee' in e:
            print 'Atendee(s):'
            for a in e['attendee']:
                print " %s" % format_atendee(a)
        print '\n%s' % e['description'].encode('UTF-8')

if __name__ == "__main__":
{'fraction_non_alphanumeric': 0.17229376957883746, 'fraction_numerical': 0.0027845457709711106, 'mean_word_length': 2.588014981273408, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3454655', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1039, 'n_words': 233}