Port a few miscellaneous items.

This commit is contained in:
Ryan Stein 2017-10-29 22:21:38 -04:00
parent b5cf27fc18
commit ee58e59e7e
3 changed files with 7 additions and 6 deletions

View file

@ -7,7 +7,6 @@ make sure to homogenize self.caller to always be the account object
for easy handling. for easy handling.
""" """
from past.builtins import cmp
from django.conf import settings from django.conf import settings
from evennia.comms.models import ChannelDB, Msg from evennia.comms.models import ChannelDB, Msg
from evennia.accounts.models import AccountDB from evennia.accounts.models import AccountDB
@ -711,7 +710,7 @@ class CmdPage(COMMAND_DEFAULT_CLASS):
if not self.args or not self.rhs: if not self.args or not self.rhs:
pages = pages_we_sent + pages_we_got 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 number = 5
if self.args: if self.args:

View file

@ -753,7 +753,9 @@ def initialize_nick_templates(in_template, out_template):
# create the regex for in_template # create the regex for in_template
regex_string = fnmatch.translate(in_template) regex_string = fnmatch.translate(in_template)
# we must account for a possible line break coming over the wire # 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 # validate the templates
regex_args = [match.group(2) for match in _RE_NICK_ARG.finditer(regex_string)] regex_args = [match.group(2) for match in _RE_NICK_ARG.finditer(regex_string)]

View file

@ -708,7 +708,7 @@ class ANSIString(with_metaclass(ANSIMeta, str)):
if not isinstance(string, str): if not isinstance(string, str):
string = string.decode('utf-8') 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._raw_string = string
ansi_string._clean_string = clean_string ansi_string._clean_string = clean_string
ansi_string._code_indexes = code_indexes ansi_string._code_indexes = code_indexes
@ -716,7 +716,7 @@ class ANSIString(with_metaclass(ANSIMeta, str)):
return ansi_string return ansi_string
def __str__(self): def __str__(self):
return self._raw_string.encode('utf-8') return self._raw_string
def __unicode__(self): def __unicode__(self):
""" """
@ -849,7 +849,7 @@ class ANSIString(with_metaclass(ANSIMeta, str)):
if not slice_indexes: if not slice_indexes:
return ANSIString('') return ANSIString('')
try: try:
string = self[slc.start]._raw_string string = self[slc.start or 0]._raw_string
except IndexError: except IndexError:
return ANSIString('') return ANSIString('')
last_mark = slice_indexes[0] last_mark = slice_indexes[0]