<commit_before>import urllib
from icalendar import Calendar

class NetworkCalendar:
    def __init__(self, url):
        self.url = url
        self.calendar = self.parse(self.request())

    def request(self):
        self.raw_ics = urllib.urlopen(self.url).read()
        return self.raw_ics

    def parse(self, ics_str):
        return Calendar.from_ical(ics_str)

    def next_event(self):
        events = []

        for component in self.calendar.walk():
            if component.name != 'VEVENT':
                continue
            events.append(component);

        def compare(a, b):
            return cmp(a.get('dtstart').dt, b.get('dtstart').dt);

        sorted_events = sorted(events, compare)

        return sorted_events[0]<commit_msg>When searching for next event, ignore events in the past. Return None if it can't find a future event.  Only consider compare datetime ojbects.<commit_after>import urllib
from icalendar import Calendar

class NetworkCalendar:
    def __init__(self, url):
        self.url = url
        self.calendar = self.parse(self.request())

    def request(self):
        self.raw_ics = urllib.urlopen(self.url).read()
        return self.raw_ics

    def parse(self, ics_str):
        return Calendar.from_ical(ics_str)

    def next_event(self):
        events = []

        next_event = None
        unaware_right_now = datetime.now()
        utc = pytz.UTC
        right_now = utc.localize(unaware_right_now)

        for component in self.calendar.walk():
            if component.name != 'VEVENT':
                continue

            # Ignore Events with no time 
            if type(component.get('dtstart').dt) == date:
                continue

            # If event is in past
            if component.get('dtstart').dt < right_now:
                continue

            if not next_event or component.get('dtstart').dt < next_event.get('dtstart').dt:
                next_event = component

        return next_event
{'fraction_non_alphanumeric': 0.09721518987341772, 'fraction_numerical': 0.0005063291139240507, 'mean_word_length': 2.1464968152866244, 'pattern_counts': {'":': 0, '<': 5, '<?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': '848854', 'n_tokens_mistral': 581, 'n_tokens_neox': 551, 'n_words': 144}