From 436277a9edcbdc952eada4a40bda3de5514a158b Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 10 Mar 2021 22:35:59 +0100 Subject: [PATCH] LogToIrc: Run 2to3 --- plugins/LogToIrc/__init__.py | 3 ++- plugins/LogToIrc/config.py | 6 +++--- plugins/LogToIrc/plugin.py | 14 ++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/LogToIrc/__init__.py b/plugins/LogToIrc/__init__.py index d3467667c..88d827376 100644 --- a/plugins/LogToIrc/__init__.py +++ b/plugins/LogToIrc/__init__.py @@ -35,6 +35,7 @@ Allows for sending the bot's logging output to channels or users. import supybot import supybot.world as world +import importlib __author__ = supybot.authors.jemfinch __maintainer__ = supybot.authors.limnoria_core @@ -50,7 +51,7 @@ __contributors__ = {} from . import config from . import plugin from importlib import reload -reload(plugin) # In case we're being reloaded. +importlib.reload(plugin) # In case we're being reloaded. if world.testing: from . import test diff --git a/plugins/LogToIrc/config.py b/plugins/LogToIrc/config.py index 4f4ceed9e..8ded7cbd5 100644 --- a/plugins/LogToIrc/config.py +++ b/plugins/LogToIrc/config.py @@ -28,7 +28,7 @@ ### import logging -from itertools import imap + import supybot.log as log import supybot.conf as conf @@ -97,7 +97,7 @@ def configure(advanced): targets = anything('Which channels or users would you like to ' 'send log messages to?') conf.supybot.plugins.LogToIrc.targets.set(targets) - except registry.InvalidRegistryValue, e: + except registry.InvalidRegistryValue as e: output(str(e)) targets = '' colorized = yn('Would you like these messages to be colored?') @@ -109,6 +109,6 @@ def configure(advanced): level = something('What would you like the minimum priority ' 'level to be which will be logged to IRC?') conf.supybot.plugins.LogToIrc.level.set(level) - except registry.InvalidRegistryValue, e: + except registry.InvalidRegistryValue as e: output(str(e)) level = '' diff --git a/plugins/LogToIrc/plugin.py b/plugins/LogToIrc/plugin.py index 4a5d36ab5..1f9f417ca 100644 --- a/plugins/LogToIrc/plugin.py +++ b/plugins/LogToIrc/plugin.py @@ -67,8 +67,8 @@ class IrcHandler(logging.Handler): try: if not irc.driver.connected: continue - except AttributeError, e: - print '*** AttributeError, shouldn\'t happen: %s' % e + except AttributeError as e: + print('*** AttributeError, shouldn\'t happen: %s' % e) continue networks = conf.supybot.plugins.LogToIrc.networks() if networks and irc.network not in networks: @@ -96,22 +96,24 @@ class IrcHandler(logging.Handler): # baaaaaad. irc.sendMsg(msg) else: - print '*** Not sending to %s' % utils.quoted(target) + print('*** Not sending to %s' % utils.quoted(target)) class IrcFormatter(log.Formatter): - def formatException(self, (E, e, tb)): + def formatException(self, xxx_todo_changeme): + (E, e, tb) = xxx_todo_changeme L = [utils.exnToString(e), '::'] frames = utils.stackTrace(frame=tb.tb_frame).split() L.extend(frames) del tb - while sum(imap(len, L)) > 350: + while sum(map(len, L)) > 350: L.pop() return ' '.join(L) class ColorizedIrcFormatter(IrcFormatter): - def formatException(self, (E, e, tb)): + def formatException(self, xxx_todo_changeme1): + (E, e, tb) = xxx_todo_changeme1 if conf.supybot.plugins.LogToIrc.color(): s = IrcFormatter.formatException(self, (E, e, tb)) return ircutils.mircColor(s, fg='red')