From aaf13eec16797ca2173bcc7ea88cc0ade303fb3c Mon Sep 17 00:00:00 2001 From: Ryan Stein Date: Sun, 29 Oct 2017 22:14:39 -0400 Subject: [PATCH] Port EvMenu and EvForm for Py3. --- evennia/utils/evform.py | 7 +++---- evennia/utils/evmenu.py | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/evennia/utils/evform.py b/evennia/utils/evform.py index 44d9f86cf4..488a0c46a4 100644 --- a/evennia/utils/evform.py +++ b/evennia/utils/evform.py @@ -140,7 +140,7 @@ from builtins import object, range import re import copy from evennia.utils.evtable import EvCell, EvTable -from evennia.utils.utils import all_from_module, to_str, to_unicode +from evennia.utils.utils import all_from_module, to_str, to_unicode, is_iter from evennia.utils.ansi import ANSIString # non-valid form-identifying characters (which can thus be @@ -161,7 +161,7 @@ def _to_ansi(obj, regexable=False): obj = _ANSI_ESCAPE.sub(r"||||", obj) if isinstance(obj, dict): return dict((key, _to_ansi(value, regexable=regexable)) for key, value in list(obj.items())) - elif hasattr(obj, "__iter__"): + elif is_iter(obj): return [_to_ansi(o) for o in obj] else: return ANSIString(to_unicode(obj), regexable=regexable) @@ -260,7 +260,6 @@ class EvForm(object): # get rectangles and assign EvCells for key, (iy, leftix, rightix) in list(cell_coords.items()): - # scan up to find top of rectangle dy_up = 0 if iy > 0: @@ -420,7 +419,7 @@ class EvForm(object): def __str__(self): "Prints the form" - return ANSIString("\n").join([line for line in self.form]) + return str(ANSIString("\n").join([line for line in self.form])) def __unicode__(self): "prints the form" diff --git a/evennia/utils/evmenu.py b/evennia/utils/evmenu.py index d3cd7ddb64..c5bdd730a6 100644 --- a/evennia/utils/evmenu.py +++ b/evennia/utils/evmenu.py @@ -167,7 +167,7 @@ from evennia import Command, CmdSet from evennia.utils import logger from evennia.utils.evtable import EvTable from evennia.utils.ansi import strip_ansi -from evennia.utils.utils import mod_import, make_iter, pad, m_len +from evennia.utils.utils import mod_import, make_iter, pad, m_len, is_iter from evennia.commands import cmdhandler # read from protocol NAWS later? @@ -726,7 +726,7 @@ class EvMenu(object): # validation of the node return values helptext = "" - if hasattr(nodetext, "__iter__"): + if is_iter(nodetext): if len(nodetext) > 1: nodetext, helptext = nodetext[:2] else: