diff --git a/lametro/events.py b/lametro/events.py index c32f2645..37882729 100644 --- a/lametro/events.py +++ b/lametro/events.py @@ -97,6 +97,10 @@ def _merge_events(self, events): web_event = LAMetroWebEvent(web_event) if event.is_spanish: + try: + assert event.key not in spanish_events + except AssertionError: + raise AssertionError('{0} already exists as a key with a value of {1}'.format(event.key, spanish_events[event.key])) spanish_events[event.key] = (event, web_event) else: english_events.append((event, web_event)) @@ -114,7 +118,7 @@ def _merge_events(self, events): if web_event.has_audio: event_audio.append(web_event['Audio']) - matches = spanish_events.get(event.partner_key, None) + matches = spanish_events.pop(event.partner_key, None) if matches: spanish_event, spanish_web_event = matches @@ -155,7 +159,7 @@ def scrape(self, window=None) : else: event_name = body_name - # Events can have an EventAgendaStatusName of "Final", "Final Revised", + # Events can have an EventAgendaStatusName of "Final", "Final Revised", # and "Final 2nd Revised." # We classify these events as "passed." status_name = event['EventAgendaStatusName'] @@ -209,7 +213,7 @@ def scrape(self, window=None) : note = "Agenda number, {}".format(item["EventItemAgendaNumber"]) agenda_item['notes'].append(note) - # The EventItemAgendaSequence provides + # The EventItemAgendaSequence provides # the line number of the Legistar agenda grid. agenda_item['extras']['item_agenda_sequence'] = item['EventItemAgendaSequence'] @@ -222,7 +226,7 @@ def scrape(self, window=None) : {event_name} on {event_date} ({legistar_api_url}). \ Contact Metro, and ask them to remove the duplicate EventItemAgendaSequence.' - raise ValueError(error_msg.format(event_name=e.name, + raise ValueError(error_msg.format(event_name=e.name, event_date=e.start_date.strftime("%B %d, %Y"), legistar_api_url=legistar_api_url)) @@ -329,11 +333,11 @@ def partner_search_string(self): @property def partner_key(self): - return (self._partner_name, self['EventDate'], self['EventTime']) + return (self._partner_name, self['EventDate']) @property def key(self): - return (self['EventBodyName'], self['EventDate'], self['EventTime']) + return (self['EventBodyName'], self['EventDate']) class LAMetroWebEvent(dict):