class fetch_weather_data(): def __init__(self): pass def SearchLocation(self,location): self.lon_and_lat = LongitudeAndLatitude(location) if self.lon_and_lat.valid() == False: return 0 return self.lon_and_lat.size() def detailOfLocation(self): assert(self.lon_and_lat.size() > 0 & "message") def detailOfWeatherData(self,index): lonlat_iter = self.lon_and_lat.fetch(index) if lonlat_iter == None: return None query_weather = QueryWeatherJson() query_weather.set("astro", "zh-CN") if query_weather.execute(lonlat_iter.getLonLan()) == False: return None query_weather.paser() return query_weather.weatherJson
if len(self.jsonbody) < 1: return None self.weatherJson = WeatherJson(self.jsonbody["product"], self.jsonbody["init"], self.jsonbody["dataseries"]) class WeatherJson: def __init__(self, product, date, weather_data): self.product = product self.date = date self.weather_data = weather_data if __name__ == "__main__": print "weather-TestNo1" b = LongitudeAndLatitude("gangu") b.valid() tmpIter = b.fetch(1) print tmpIter.getLonLan() c = QueryWeatherJson() c.set("astro", "zh-CN") if c.execute(tmpIter.getLonLan()) == False: print "error" # tmpIter.getLonLan() c.paser() # print c.weatherJson.product # print c.weatherJson.date # print c.weatherJson.weather_data print "success"