LogToIrc: Run 2to3

This commit is contained in:
Valentin Lorentz 2021-03-10 22:35:59 +01:00
parent e9ef8b22c0
commit 436277a9ed
3 changed files with 13 additions and 10 deletions

View File

@ -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

View File

@ -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 = ''

View File

@ -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')