From 045a83c6cc1ec6e588e954678bb2e17461ce1ba6 Mon Sep 17 00:00:00 2001 From: Griatch Date: Wed, 7 Dec 2022 19:34:27 +0100 Subject: [PATCH] Fix justify m_len call. Fixes #3019 --- Makefile | 2 +- evennia/utils/evmenu.py | 13 ++----------- evennia/utils/evtable.py | 1 - evennia/utils/utils.py | 9 ++++----- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 373c253269..5d707a6e04 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ default: @echo " make test - run evennia test suite with all default values." @echo " make tests=evennia.path test - run only specific test or tests." @echo " make testp - run test suite using multiple cores." - @echo " make publish - publish evennia to pypi (requires pypi credentials) + @echo " make release - publish evennia to pypi (requires pypi credentials) install: pip install -e . diff --git a/evennia/utils/evmenu.py b/evennia/utils/evmenu.py index 163494f933..1430bc31d4 100644 --- a/evennia/utils/evmenu.py +++ b/evennia/utils/evmenu.py @@ -273,22 +273,12 @@ from django.conf import settings # i18n from django.utils.translation import gettext as _ - from evennia import CmdSet, Command from evennia.commands import cmdhandler from evennia.utils import logger from evennia.utils.ansi import strip_ansi from evennia.utils.evtable import EvColumn, EvTable -from evennia.utils.utils import ( - crop, - dedent, - is_iter, - m_len, - make_iter, - mod_import, - pad, - to_str, -) +from evennia.utils.utils import crop, dedent, is_iter, m_len, make_iter, mod_import, pad, to_str # read from protocol NAWS later? _MAX_TEXT_WIDTH = settings.CLIENT_DEFAULT_WIDTH @@ -1179,6 +1169,7 @@ class EvMenu: for icol in range(ncols): start = icol * split end = min(start + split, max_end) + print(f"col {icol}:", table[start:end]) cols_list.append(EvColumn(*table[start:end])) return str(EvTable(table=cols_list, border="none")) diff --git a/evennia/utils/evtable.py b/evennia/utils/evtable.py index 8517344f61..f6837a79a0 100644 --- a/evennia/utils/evtable.py +++ b/evennia/utils/evtable.py @@ -118,7 +118,6 @@ from copy import copy, deepcopy from textwrap import TextWrapper from django.conf import settings - from evennia.utils.ansi import ANSIString from evennia.utils.utils import display_len as d_len from evennia.utils.utils import is_iter, justify diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index aa58fe121e..3ad2bff9b5 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -34,13 +34,12 @@ from django.core.validators import validate_email as django_validate_email from django.utils import timezone from django.utils.html import strip_tags from django.utils.translation import gettext as _ +from evennia.utils import logger from simpleeval import simple_eval from twisted.internet import reactor, threads from twisted.internet.defer import returnValue # noqa - used as import target from twisted.internet.task import deferLater -from evennia.utils import logger - _MULTIMATCH_TEMPLATE = settings.SEARCH_MULTIMATCH_TEMPLATE _EVENNIA_DIR = settings.EVENNIA_DIR _GAME_DIR = settings.GAME_DIR @@ -288,8 +287,8 @@ def justify(text, width=None, align="l", indent=0, fillchar=" "): # absolute mode - just crop or fill to width abs_lines = [] for line in text.split("\n"): - nlen = len(line) - if len(line) < width: + nlen = m_len(line) + if m_len(line) < width: line += sp * (width - nlen) else: line = crop(line, width=width, suffix="") @@ -304,7 +303,7 @@ def justify(text, width=None, align="l", indent=0, fillchar=" "): for ip, paragraph in enumerate(paragraphs): if ip > 0: words.append(("\n", 0)) - words.extend((word, len(word)) for word in paragraph.split()) + words.extend((word, m_len(word)) for word in paragraph.split()) if not words: # Just whitespace!