From 3ca6f3c9734b2d854953ee4faf03f33f55a4e306 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 19 Jun 2022 15:21:28 -0700 Subject: [PATCH] NuWeather: minor cleanup --- NuWeather/formatter.py | 4 +--- NuWeather/plugin.py | 6 +++--- NuWeather/test.py | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/NuWeather/formatter.py b/NuWeather/formatter.py index 0368790..63701c5 100644 --- a/NuWeather/formatter.py +++ b/NuWeather/formatter.py @@ -27,11 +27,9 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. ### - -import re import string -from supybot import callbacks, conf, ircutils, log, utils +from supybot import ircutils, log try: import pendulum diff --git a/NuWeather/plugin.py b/NuWeather/plugin.py index fe81c3f..e9059de 100644 --- a/NuWeather/plugin.py +++ b/NuWeather/plugin.py @@ -60,7 +60,7 @@ class NuWeather(callbacks.Plugin): self.db = accountsdb.AccountsDB("NuWeather", 'NuWeather.db', self.registryValue(accountsdb.CONFIG_OPTION_NAME)) geocode_db_filename = conf.supybot.directories.data.dirize("NuWeather-geocode.json") if os.path.exists(geocode_db_filename): - with open(geocode_db_filename) as f: + with open(geocode_db_filename, encoding='utf-8') as f: self.geocode_db = json.load(f) else: self.log.info("NuWeather: Creating new geocode DB") @@ -72,7 +72,7 @@ class NuWeather(callbacks.Plugin): def _flush_geocode_db(self): geocode_db_filename = conf.supybot.directories.data.dirize("NuWeather-geocode.json") - with open(geocode_db_filename, 'w') as f: + with open(geocode_db_filename, 'w', encoding='utf-8') as f: json.dump(self.geocode_db, f) def die(self): @@ -91,7 +91,7 @@ class NuWeather(callbacks.Plugin): try: f = utils.web.getUrl(url, headers=HEADERS).decode('utf-8') data = json.loads(f) - except utils.web.Error as e: + except utils.web.Error: log.debug('NuWeather: error searching for %r from Nominatim backend:', location, exc_info=True) data = None if not data: diff --git a/NuWeather/test.py b/NuWeather/test.py index 5b4a8e1..b510d17 100644 --- a/NuWeather/test.py +++ b/NuWeather/test.py @@ -64,7 +64,6 @@ class NuWeatherTestCase(PluginTestCase): self.assertRegexp('weather Vancouver', 'Vancouver,') self.assertRegexp('weather LAX', 'Los Angeles') #self.assertRegexp('weather 76010', 'Arlington') # US ZIP codes not supported by Nominatim (default) - self.assertError('weather InvalidLocationTest') @unittest.skipUnless(network, NO_NETWORK_REASON) def testSavedLocation(self):