def get_current(self): fore = next(iter(self.iter_forecast())) ret = Current() for f in ('date', 'text', 'wind_direction', 'wind_speed', 'humidity'): setattr(ret, f, getattr(fore, f)) ret.temp = fore.high return ret
def get_current(self): obj = Current() obj.id = date.today() obj.date = date.fromtimestamp(self.doc['latestObservationTime']/1000) obj.temp = Temperature(max(self.doc['t2m'])[1], u'C') last_hour_precipitations = int(max(self.doc['Precipitation1h'])[1]) nebulosity = int(max(self.doc['TotalCloudCover'])[1]) wind_speed = int(max(self.doc['WindSpeedMS'])[1]) wind_direction = self.WINDS[int(max(self.doc['WindDirection'])[1] / 22.5)] obj.text = u'1h precipitations %d mm, wind %d m/s (%s), nebulosity %d/8' % ( last_hour_precipitations, wind_speed, wind_direction, nebulosity) return obj
def get_current(self, city_id): dom = self._get_weather_dom(city_id) current = dom.getElementsByTagName('yweather:condition')[0] return Current( parse_dt(current.getAttribute('date')).date(), float(current.getAttribute('temp')), unicode(current.getAttribute('text')), u'C')
def get_current(self): div = self.document.getroot().xpath( '//div[@class="bloc_details"]/ul/li/dl')[0] mdate = datetime.datetime.now() temp = self.get_temp_without_unit( div.xpath('./dd[@class="minmax"]')[0].text) mtxt = div.find('dd').find('img').attrib['title'] return Current(mdate, temp, mtxt, 'C')
def get_current(self): date = datetime.datetime.now() text = unicode( self.document.findall('//p[@class="wx-narrative"]') [0].text_content().strip()) temp = float( self.document.find( '//p[@class="wx-temp"]').text_content().strip().split(u'°')[0]) return Current(date, temp, text, u'F')
def get_current(self): obj = Current() obj.id = date.today() obj.date = date.fromtimestamp(self.doc['latestObservationTime'] / 1000) obj.temp = Temperature(max(self.doc['t2m'])[1], u'C') last_hour_precipitations = int(max(self.doc['Precipitation1h'])[1]) nebulosity = int(max(self.doc['TotalCloudCover'])[1]) wind_speed = int(max(self.doc['WindSpeedMS'])[1]) wind_direction = self.WINDS[int( max(self.doc['WindDirection'])[1] / 22.5)] obj.text = u'1h precipitations %d mm, wind %d m/s (%s), nebulosity %d/8' % ( last_hour_precipitations, wind_speed, wind_direction, nebulosity) return obj