From ee58e59e7eb4069d8290c323a29bcb6f6e7366f7 Mon Sep 17 00:00:00 2001 From: Ryan Stein Date: Sun, 29 Oct 2017 22:21:38 -0400 Subject: [PATCH] Port a few miscellaneous items. --- evennia/commands/default/comms.py | 3 +-- evennia/typeclasses/attributes.py | 4 +++- evennia/utils/ansi.py | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/evennia/commands/default/comms.py b/evennia/commands/default/comms.py index 8ab75f8727..c806a08296 100644 --- a/evennia/commands/default/comms.py +++ b/evennia/commands/default/comms.py @@ -7,7 +7,6 @@ make sure to homogenize self.caller to always be the account object for easy handling. """ -from past.builtins import cmp from django.conf import settings from evennia.comms.models import ChannelDB, Msg from evennia.accounts.models import AccountDB @@ -711,7 +710,7 @@ class CmdPage(COMMAND_DEFAULT_CLASS): if not self.args or not self.rhs: pages = pages_we_sent + pages_we_got - pages.sort(lambda x, y: cmp(x.date_created, y.date_created)) + pages = sorted(pages, key=lambda page: page.date_created) number = 5 if self.args: diff --git a/evennia/typeclasses/attributes.py b/evennia/typeclasses/attributes.py index 2fdbc5d6b7..1d3b820226 100644 --- a/evennia/typeclasses/attributes.py +++ b/evennia/typeclasses/attributes.py @@ -753,7 +753,9 @@ def initialize_nick_templates(in_template, out_template): # create the regex for in_template regex_string = fnmatch.translate(in_template) # we must account for a possible line break coming over the wire - regex_string = regex_string[:-7] + r"(?:[\n\r]*?)\Z(?ms)" + + # NOTE-PYTHON3: fnmatch.translate format changed since Python2 + regex_string = regex_string[:-2] + r"(?:[\n\r]*?)\Z" # validate the templates regex_args = [match.group(2) for match in _RE_NICK_ARG.finditer(regex_string)] diff --git a/evennia/utils/ansi.py b/evennia/utils/ansi.py index a1a3ebf0e1..e69845abb8 100644 --- a/evennia/utils/ansi.py +++ b/evennia/utils/ansi.py @@ -708,7 +708,7 @@ class ANSIString(with_metaclass(ANSIMeta, str)): if not isinstance(string, str): string = string.decode('utf-8') - ansi_string = super(ANSIString, cls).__new__(ANSIString, to_str(clean_string), "utf-8") + ansi_string = super(ANSIString, cls).__new__(ANSIString, to_str(clean_string)) ansi_string._raw_string = string ansi_string._clean_string = clean_string ansi_string._code_indexes = code_indexes @@ -716,7 +716,7 @@ class ANSIString(with_metaclass(ANSIMeta, str)): return ansi_string def __str__(self): - return self._raw_string.encode('utf-8') + return self._raw_string def __unicode__(self): """ @@ -849,7 +849,7 @@ class ANSIString(with_metaclass(ANSIMeta, str)): if not slice_indexes: return ANSIString('') try: - string = self[slc.start]._raw_string + string = self[slc.start or 0]._raw_string except IndexError: return ANSIString('') last_mark = slice_indexes[0]