def parse_response(self,response): if response is None: return None xml = etree.fromstring(response) time_series = self._read_xml(xml) if len(time_series) > 1: # retval is a StationCollection retval = StationCollection() for ts in time_series: st = self._timeseries_to_station(ts) retval.add_element(st) else: # retval is a Station retval = self._timeseries_to_station(time_series[0]) return retval
def parse_station_collection(self, cb_func, cb_args, desired_stations): """ Function to group Stations into a StationCollection - cb_func: the get_station function to call from the nerr collector - cb_args: arguments to pass along into the get_station function - desired_stations: list of stations that are to be added into the collections returns a StationCollection object """ if not isinstance(cb_args, dict): return None if not isinstance(desired_stations, list) or len(desired_stations) < 1: return None retval = StationCollection() for ds in desired_stations: elem = cb_func(ds.code, site_id=ds.id, metadata=ds, **cb_args) retval.add_element(elem) return retval