From 451e3e48e55ce9d47048b9691b5e3a05f42cb046 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 11 Feb 2019 20:07:10 +0100 Subject: [PATCH] [modules/weather] Fix location display for "auto" When "auto" is used, the location was never shown. Also, document the "showcity" parameter. fixes #360 --- bumblebee/modules/weather.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bumblebee/modules/weather.py b/bumblebee/modules/weather.py index be6fa5e..4925d69 100644 --- a/bumblebee/modules/weather.py +++ b/bumblebee/modules/weather.py @@ -10,6 +10,7 @@ Parameters: * weather.location: Set location (ISO 3166 country code), defaults to 'auto' for getting location from http://ipinfo.io If set to a comma-separated list, left-click and right-click can be used to rotate the locations * weather.unit: metric (default), kelvin, imperial + * weather.showcity: If set to true, show location information, otherwise hide it (defaults to true) * weather.apikey: API key from http://api.openweathermap.org """ @@ -66,10 +67,7 @@ class Module(bumblebee.engine.Module): return u"{}°{}".format(self._temperature, self._unit_suffix()) def city(self): - city = self._location[self._index] - if city == "auto": - city = "" - city = re.sub('[_-]', ' ', city) + city = re.sub('[_-]', ' ', self._city) return u"{} ".format(city) def output(self, widget): @@ -112,6 +110,7 @@ class Module(bumblebee.engine.Module): self._city = location["city"] weather_url = "{url}&lat={lat}&lon={lon}".format(url=weather_url, lat=coord[0], lon=coord[1]) else: + self._city = self._location[self._index] weather_url = "{url}&q={city}".format(url=weather_url, city=self._location[self._index]) weather = requests.get(weather_url).json() self._temperature = int(weather['main']['temp'])