Skip to content

Commit

Permalink
generalized top-level fetcher functions
Browse files Browse the repository at this point in the history
  • Loading branch information
phobson committed Mar 8, 2016
1 parent 0c12bb5 commit 1752ee0
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions cloudside/station.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,27 +711,23 @@ def getStationByID(sta_id):
return sta


def getASOSData(station, startdate, enddate, filename=None):
def _fetch_data(fetcher_name, station, startdate, enddate, filename):
if not isinstance(station, WeatherStation):
station = getStationByID(station)

data = station.getASOSData(startdate, enddate, filename=filename)
return data
fetcher = getattr(station, fetcher_name)
return fetcher(startdate, enddate, filename=filename)


def getWundergroundData(station, startdate, enddate, filename=None):
if not isinstance(station, WeatherStation):
station = getStationByID(station)
def getASOSData(station, startdate, enddate, filename=None):
return _fetch_data('getASOSData', station, startdate, enddate, filename)

data = station.getWundergroundData(startdate, enddate, filename=filename)
return data

def getWundergroundData(station, startdate, enddate, filename=None):
return _fetch_data('getWundergroundData', station, startdate, enddate, filename)

def getWunderground_NonAirportData(station, startdate, enddate, filename=None):
if not isinstance(station, WeatherStation):
station = getStationByID(station)

data = station.getWunderground_NonAirportData(startdate, enddate, filename=filename)
return data
def getWunderground_NonAirportData(station, startdate, enddate, filename=None):
return _fetch_data('getWunderground_NonAirportData', station, startdate, enddate, filename)


0 comments on commit 1752ee0

Please sign in to comment.