From fed4b3699b4dd18ce6b4436da41645fd25dddb23 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 7 Mar 2016 11:43:13 +0000 Subject: [PATCH] Fix show log command for Py3K The behavior of lambda filters has changed in Python 3 such that you can no longer treat them directly as lists. Trivially reimplement them as list comprehensions. Also correct a missing minimum loglevel fallback default. --- lib/mudpy/misc.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/mudpy/misc.py b/lib/mudpy/misc.py index 41d3ab6..bcb50c2 100644 --- a/lib/mudpy/misc.py +++ b/lib/mudpy/misc.py @@ -1003,10 +1003,8 @@ def log(message, level=0): syslog_name = universe.categories["internal"]["logging"].get("syslog") timestamp = time.asctime()[4:19] - # turn the message into a list of lines - lines = filter( - lambda x: x != "", [(x.rstrip()) for x in message.split("\n")] - ) + # turn the message into a list of nonempty lines + lines = [x for x in [(x.rstrip()) for x in message.split("\n")] if x != ""] # send the timestamp and line to a file if file_name: @@ -1058,7 +1056,7 @@ def get_loglines(level, start, stop): """Return a specific range of loglines filtered by level.""" # filter the log lines - loglines = filter(lambda x: x[0] >= level, universe.loglines) + loglines = [x for x in universe.loglines if x[0] >= level] # we need these in several places total_count = str(len(universe.loglines)) @@ -2207,8 +2205,8 @@ def command_show(actor, parameters): level = int(arguments[1]) else: level = -1 - elif 0 <= actor.owner.account.get("loglevel") <= 9: - level = actor.owner.account.get("loglevel") + elif 0 <= actor.owner.account.get("loglevel", 0) <= 9: + level = actor.owner.account.get("loglevel", 0) else: level = 1 if level > -1 and start > -1 and stop > -1: -- 2.11.0