@@ -0,0 +1,1373 @@
+# -*- coding: utf-8 -*-%0Aimport datetime%0Aimport requests%0Aimport json%0A%0A%0Aclass ForecastWidget(object):%0A    full_text = %22%22%0A    uri = %22https://api.forecast.io/forecast/%7Bapi_key%7D/%7Blat%7D,%7Blon%7D?units=si&%22%5C%0A          %22exclude=minutely,hourly,daily%22%0A%0A    def __init__(self, api_key, lat, lon, interval=300):%0A        self.api_key = api_key%0A        self.lat = lat%0A        self.lon = lon%0A        self.interval = interval%0A        self.last_run = None%0A%0A    def output(self):%0A        if not self.last_run or datetime.datetime.now() %3E= %5C%0A                self.last_run + datetime.timedelta(seconds=self.interval):%0A            uri = self.uri.format(%0A                api_key=self.api_key,%0A                lat=self.lat,%0A                lon=self.lon)%0A            try:%0A                r = requests.get(uri, verify=True)%0A                w = json.loads(r.text)%0A%0A                self.last_run = datetime.datetime.now()%0A                self.full_text = ' %7Bweather%7D, %7Btemperature%7D%C2%B0C'.format(%0A                    weather=w%5B'currently'%5D%5B'summary'%5D.lower(),%0A                    temperature=round(w%5B'currently'%5D%5B'temperature'%5D))%0A            except:%0A                pass%0A%0A        if len(self.full_text) %3E 0:%0A            return %7B%0A                'name': %22weather%22,%0A                'full_text': self.full_text,%0A                'color': '#c3bf9f',%0A                'icon': 'mmbar/icons/temp.xbm',%0A            %7D%0A

add forecast widget