def __init__(self, station_id, radar_id): assert radar_id in RADAR_TYPES, 'Unknown radar type %s' % radar_id data = {'station_id': station_id, 'radar_id': radar_id} if conf.resource_exists('radar', '%s.%s' % (station_id, radar_id)): data.update(conf.load('radar', '%s.%s' % (station_id, radar_id))) else: data.update(get_radar_report(station_id, radar_id)) conf.dump('radar', dict(data), '%s.%s' % (station_id, radar_id)) dict.__init__(self, data)
def __init__(self, query): if conf.resource_exists('uv',query): self.value = conf.load('uv',query) else: loc = Location(query) self.value = get_uv_index(**{ 'zipcode': loc.postal_code, 'city_name': loc.locality, 'state_code': loc.state }) conf.dump('uv',self.value,query)
def __init__(self, query, **kwargs): self.location = Location(query) self.year = kwargs.get('year',NOW.year) self.report_type = kwargs.get('report_type',0) assert self.report_type in range(5), 'Invalid report type' self.id = '%s.%s.%s'%(self.location,self.year,self.report_type_text) if conf.resource_exists('sun',self.id): dict.__init__(self, conf.load('sun',self.id)) else: data = get_sun_report(year=self.year,location=self.location,**kwargs) conf.dump('sun', data, self.id) dict.__init__(self, data)
def __init__(self, *args, **kwargs): sep = '+' if not args: raise TypeError('You must declare a location to geocode') if isinstance(args[0], float): sep = ',' query = sep.join(map(lambda x: quote_plus(str(x)), args)) live = kwargs.pop('live', None) if conf.resource_exists('geo', query) and not live: dict.__init__(self, conf.load('geo', query)) else: data = geocode(query, **kwargs) conf.dump('geo', data, query) dict.__init__(self, data) del data del live
def __init__(self, region): if conf.resource_exists('alerts', '%s.cap' % region): dict.__init__(self, conf.load('alerts', '%s.cap' % region)) else: dict.__init__(self, get_cap_alert(region)) conf.dump('alerts', dict(self), '%s.cap' % region)
def __init__(self, state): if conf.resource_exists('alerts', '%s.state' % state): dict.__init__(self, conf.load('alerts', '%s.state' % state)) else: dict.__init__(self, get_state_alert(state)) conf.dump('alerts', dict(self), '%s.state' % state)
def __init__(self, zone): if conf.resource_exists('alerts', '%s.zone' % zone): dict.__init__(self, conf.load('alerts', '%s.zone' % zone)) else: dict.__init__(self, get_zone_alert(zone)) conf.dump('alerts', dict(self), '%s.zone' % zone)
def parse(): for event in get_quake_events(): event = Event(event) conf.dump('earthquake', dict(event), event.id) yield event
def parse(): for station in get_weather_observations(): station = Station(station) conf.dump('observations',dict(station),station.id) yield station