From 2404848a4e3536e7867ae958cf22f390c0b8956e Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 10 Sep 2016 18:07:18 +0200 Subject: [PATCH] Currency: Add Python 3 support. --- Currency/__init__.py | 7 ++++--- Currency/config.py | 5 ++--- Currency/plugin.py | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Currency/__init__.py b/Currency/__init__.py index adf90f0..39f97db 100644 --- a/Currency/__init__.py +++ b/Currency/__init__.py @@ -43,14 +43,15 @@ # contributions. __contributors__ = {} -import config -import plugin +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. # Add more reloads here if you add third-party modules and want them to be # reloaded when this plugin is reloaded. Don't forget to import them as well! if world.testing: - import test + from . import test Class = plugin.Class configure = config.configure diff --git a/Currency/config.py b/Currency/config.py index 374cdee..c129cd1 100644 --- a/Currency/config.py +++ b/Currency/config.py @@ -27,7 +27,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### -import plugin +from . import plugin import supybot.conf as conf import supybot.utils as utils @@ -45,8 +45,7 @@ class CurrencyCommand(registry.String): def setValue(self, s): m = plugin.Currency.currencyCommands if s not in m: - raise registry.InvalidRegistryValue,\ - format('Command must be one of %L.', m) + raise registry.InvalidRegistryValue(format('Command must be one of %L.', m)) registry.String.setValue(self, s) Currency = conf.registerPlugin('Currency') diff --git a/Currency/plugin.py b/Currency/plugin.py index 2fe6034..6f3bc97 100644 --- a/Currency/plugin.py +++ b/Currency/plugin.py @@ -65,8 +65,8 @@ def xe(self, irc, msg, args, number, curr1, curr2): irc.error(self._symbolError, Raise=True) url = 'http://www.xe.com/ucc/convert.cgi?Amount=%s&From=%s&To=%s' try: - text = utils.web.getUrl(url % (number, curr1, curr2)) - except utils.web.Error, e: + text = utils.web.getUrl(url % (number, curr1, curr2)).decode() + except utils.web.Error as e: irc.error(str(e), Raise=True) err = self._xeCurrError.search(text) if err is not None: @@ -98,8 +98,8 @@ def yahoo(self, irc, msg, args, number, curr1, curr2): url = r'http://finance.yahoo.com/d/quotes.csv?'\ r's=%s%s=X&f=sl1d1t1ba&e=.csv' % (curr1, curr2) try: - text = utils.web.getUrl(url) - except utils.web.Error, e: + text = utils.web.getUrl(url).decode() + except utils.web.Error as e: irc.error(str(e), Raise=True) if 'N/A' in text: irc.error('You used an incorrect currency symbol.', Raise=True)