from __future__ import print_function


class FetchResult(object):
    """Normalized result shared by Bayou Radar and direct NWS clients."""

    def __init__(self):
        self.alerts = {}
        self.successful_areas = set()
        self.failed_areas = set()
        self.errors = []
        self.source_by_area = {}
        self.primary_successful_areas = set()
        self.primary_failed_areas = set()
        self.fallback_areas = set()
        self.primary_healthy = True
        self.primary_source = "bayou_radar"
        self.fallback_source = "nws"

    def add_alert(self, alert):
        if alert.id in self.alerts:
            self.alerts[alert.id].merge(alert)
        else:
            self.alerts[alert.id] = alert
